Ethernaut Force

Receiving Ether

One of the main use cases of the Ethereum blockchain is to be able to transfer ether between accounts. There are two types of accounts: Externally Owned Accounts (EOA) or Contract Accounts.

When it comes to sending ether directly to Contract Accounts, there are two solidity functions that can be used: send() and transfer(). However, there are some requirements that contracts need to follow in order to be able to receive ether via those function calls, namely containing a receive function or a payable fallback function.

Note: The reason I am not mentioning that the receive function needs to be payable, is because it is payable by default, where fallback functions are flexible on the definition.

These are the following possibilities:

  • The target contract contains a payable fallback function;
  • The target contract contains a receive function;
  • The target contract contains either a payable fallback function or a receive function, where if the calldata attribute is empty, the receive function will be executed.

“If neither a receive Ether nor a

--

--

Diogo Pereira | diogo-pereira.com

I help organisations build cyber-resilient applications, bring security awareness and mindset growth tips to interested individuals