Ref - https://docs.soliditylang.org/en/v0.8.25/contracts.html#receive-ether-function

In Ethereum, the fallback function is a special function in a smart contract that is executed when the contract receives Ether and there is no other matching function signature for the call made. It is part of the low-level function set in Solidity and is commonly used for handling Ether transfers, handling unexpected function calls, or implementing custom logic for receiving Ether.

The fallback function is invoked when:

  1. The contract receives Ether via a plain transfer or call (i.e., no data is provided with the transaction or the data doesn't match any existing function signature).
  2. The function call data does not match any function selector in the contract.

Properties of fallback fn

<aside> 💡

There is another function called receive that is triggered only when ether is received.

</aside>

Code

// SPDX-License-Identifier: GPL-3.0

pragma solidity >=0.7.0 <0.9.0;

contract FundReceiver {
    event FallbackCalled();
    
    fallback() external payable {
        emit FallbackCalled();			
    }
}

Screenshot 2025-01-03 at 8.50.22 PM.png