How can I revert a transfer of ETH funds to my smart contract?
I would like to instantly revert any ETH being sent to my smart contract.


Any Ether transfers to a contract are automatically reverted, unless explicitly allowed by the contract, e.g. by:

  • using a payable function
  • using a receive or fallback function

If a function is called with a non-zero value and it's not payable, the transaction will be reverted. If no function is called (no transaction data), and there is no receive or payable fallback function, the transaction will also be reverted.

It's still possible to send Ether to the contract using the methods described by Lauri Peltonen, but above applies to regular transactions.


You can make it harder but not impossible.

To make it harder you can implement the receive function (https://solidity.readthedocs.io/en/v0.7.0/contracts.html#receive-ether-function) and always revert it if's being called. Of course you shouldn't have other payable functions then.

Even if you revert all Ether transfers with a receive function there are three ways the contract can have Ethers sent to it (https://ethereum.stackexchange.com/a/63988/31933):

  1. selfdestruction. Another contract self destructs (by using the selfdestruct functionality) and sends its remaining Ether to your contract

  2. Target of mining (so called coinbase address). Ether rewarded from mining can't be refused.

  3. Ether sent to the contract before the contract exists.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.