4

If the contract doesn't implement the receive or fallback function as payable, it can't receive funds?

1 Answers1

6

The last 2 ways listed for sending balance allow to send balance to a Smart Contract even if it doesn't implement receive and payable fallback functions:

You have multiple ways to transfer balance from a Smart Contract to another (I'm going to list 5 of them):

  • Using transfer function. Ex: contractAddress.transfer(1 ether)
  • Using send function. Ex: contractAddress.send(1 ether)
  • Using call function. Ex: contractAddress.call{value: msg.value}("");

To check the differences between these methods, check this article.

The first 3 approaches require that if the receiver is a Smart Contract, it needs to implement the receive() function or the fallback() function, both explicitly payable.

The recommended approach is using call (not transfer or send). To know why, check why the Access List feature was added in a previous network fork.

  • You can also send balance from one contract to another account by using the SELFDESTRUCT opcode.
  • And also it's important to know that you can transfer balance to a Smart Contract before its creation because Smart Contract addresses are deterministic over the address and the nonce of the deployer.

These two last considerations are really important because a Smart Contract can receive funds even without implementing receive() or fallback() functions.

Coreggon
  • 113
  • 5