Solidity: revert in transfer function

I’ve been learning Solidity lately, this is a note for noob.

While encountering

Error: Returned error: VM Exception while processing transaction: revert

We can debug the transaction using:

truffle debug --fetch-external 0xTxHash

Then, we can follow the code and look into the stacktrace. For me this time, I’m facing this:


Here msg.sender is my contract, why my contract revert when transfer ether to it. After a few digging, I learn the reason.

A contract receiving Ether must have at least one of the functions below

  • receive() external payable
  • fallback() external payable

You can follow the Reference to check more detail about these 2 functions.


  1. sending-ether


Leave a Reply

Your email address will not be published. Required fields are marked *