Web3 Dictionary Logo
Web3 Dictionary
Contribute

Categories

AllBlockchainDappsDAOsDeFiNFTsRegulationSecuritySmart ContractsTokenomicsWalletsWeb3 GamingOthers
  1. Web3 Dictionary
  2. Smart Contracts
  3. Fallback Function
Smart Contracts

Fallback Function

A special function that executes when no other function matches a contract call.

Last Updated

2026-03-19

Related Concepts

Smart ContractSolidityEthereum Virtual Machine
Web3-Explorer Logo

Scale Blockchain Infra

AD

Smart contracts, protocol integrations, and scalable architecture for high-performance Web3 products.

See Blockchain Services

What is Fallback Function?

A fallback function is a specialized, unnamed function in a Solidity smart contract that serves as a "catch-all." It automatically executes when a contract receives a call with data that does not match any of its existing function signatures.

How does Fallback Function work?

  1. A transaction is sent to a contract with a 4-byte "function selector."
  2. The EVM checks the contract's code for a function that matches that selector.
  3. If no match is found, the EVM automatically triggers the fallback function.
  4. If the contract also receives Ether but no data, it triggers the receive function (if defined); otherwise, it defaults to the fallback.
  5. Fallback functions have a very limited gas stipend (2,300 gas) if triggered by a simple transfer or send call.

Why does Fallback Function matter?

Fallback functions provide a safety net for contracts, allowing them to handle unexpected interactions gracefully rather than simply failing. They are also crucial for the "Proxy" pattern, where a contract forwards all unknown calls to another implementation contract to enable upgradeability.

Key features of Fallback Function

  • Unnamed and can only have one per contract
  • Executed when no other function matches the call
  • Can be used to receive Ether (if marked payable)
  • Essential for proxy and upgradeable contract patterns
  • Must be written with strict security to prevent reentrancy

Examples of Fallback Function

Proxy contracts (like those used by Gnosis Safe or USDC) use a fallback function to take any incoming transaction and "forward" it to a different contract that contains the actual logic. This allows the main contract address to remain the same even when the logic is updated.

External References

  • Solidity Fallback Functions
  • Proxy and Upgradeable Contracts