Fallback function

A contract can have exactly one fallback function. A fallback function is an unnamed external function without any input or output parameters. EVM executes the fallback function on a contract if none of the other functions match the intended function calls. For example, the following code snippet defines a fallback function on the FallbackHelloWorld contract (lines 9-11):

When the preceding contract is called to receive ether via the send function, the send function will return false since the fallback function is not payable. To receive ether and add it to the total balance of the contract, the fallback function must be ...

Get Learn Ethereum now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.