`fallback` is a special function that is executed either when - a function that does not exist is called or - Ether is sent directly to a contract but `receive()` does not exist or `msg.data` is not empty To better understand the conditions under which Solidity calls the `receive` or `fallback` function, refer to the flowchart below: ``` send Ether | msg.data is empty? / \ yes no | | receive() exists? Matches function? / \ / \ yes no yes no | | | | receive() fallback() function() fallback() ``` > The first 4 bytes of msg.data are the function selector > The receive function is specifically designed to handle Ether transfers without data and is automatically invoked when Ether is sent. The fallback function is used for handling calls with data or when the receive function is not defined. The fallback function can also handle Ether transfers with data. ![[Pasted image 20250305134736.png]]