Using a Safe Fallback Handler is security-critical. Because fallback handlers
can execute arbitrary external logic within a Safe Smart Account, only use
handlers from trusted sources that have undergone thorough security audits.
How it works
When a fallback handler is configured, it is invoked whenever a transaction is sent to the Safe and the function selector in the calldata does not match any function defined in the Safe singleton contract. When forwarding a call, the Safe:- delegates execution to the configured fallback handler
- appends the original caller’s address to the calldata

Examples
The following fallback handlers demonstrate common patterns and real-world use cases for extending Safe Smart Accounts.TokenCallbackHandler
Source code:TokenCallbackHandler Handles callbacks from supported token standards, enabling Safe accounts to receive tokens safely. Supported interfaces:
ERC1155TokenReceiverERC777TokensRecipientERC721TokenReceiver
CompatibilityFallbackHandler
Source code:CompatibilityFallbackHandler Extends
TokenCallbackHandler and adds several compatibility and utility features:
- Implements ERC-1271 via
isValidSignature, enabling on-chain signature verification - Provides a
simulatefunction that performs a staticdelegatecalland then reverts, allowing off-chain simulation without state changes - Exposes helper functions:
getMessageHash: Generates a message hash scoped to the calling SafeencodeMessageDataForSafe: Encodes messages using the Safe’s domain separator and a predefined type hashgetMessageHashForSafe: Combines encoding and hashing into a final message hashgetModules: Returns a paginated list (first 10 entries) of enabled Safe modules
ExtensibleFallbackHandler
Source code:ExtensibleFallbackHandler Allows assigning different fallback handlers to specific function selectors, enabling fine-grained control over how unmatched calls are handled.
Safe4337Module as fallback handler
Source code:Safe4337Module Implements the
validateUserOp function defined by ERC-4337, enabling Safe Smart Accounts to act as ERC-4337–compatible smart contract wallets.