---
# System prepended metadata

title: Fallback Handler Documentation

---


Based on 
- https://github.com/safe-global/safe-contracts/blob/main/contracts/Safe.sol#L27 
- https://github.com/safe-global/safe-contracts/blob/main/contracts/base/FallbackManager.sol#L50

# Fallback Handler Documentation

The Safe contract, a multisignature wallet on Ethereum, contains a module named `FallbackManager`. This module manages a "fallback handler" that provides additional read-only functionality for the Safe contract.

## Fallback Handler in the Safe Contract

A fallback handler is set up during the `setup` function call in the `Safe` contract and can also be set using the `setFallbackHandler` function in the `FallbackManager` contract. The `setFallbackHandler` function emits a `ChangedFallbackHandler` event whenever the handler is updated.

The `FallbackManager` contract also includes a fallback function that forwards all calls to the fallback handler if one is set. This function appends the caller's address (without padding) to the calldata, which can be used in the handler for additional verification scenarios. Note that in the next call frame, the `msg.sender` will be the `FallbackManager`'s address, so having the original caller's address may be helpful.

This fallback function only forwards calls that include data and do not include value (i.e., no ether is sent).

## Important Considerations

When creating a fallback handler for the Safe contract, it's important to keep a few things in mind:

1. **Read-only**: The fallback handler should not change the state of the Safe contract or the fallback handler contract itself. This ensures that the fallback handler cannot be used to manipulate or take over the Safe contract.

2. **Efficient**: The fallback handler is called when no other function matches, so it should be as efficient as possible to avoid wasting gas.

3. **Secure**: As with any smart contract, the fallback handler should be thoroughly tested and audited to ensure it doesn't contain any bugs or vulnerabilities that could be exploited.

4. **Cannot be the Safe contract itself**: To avoid potential attack vectors, the fallback handler cannot be set to the Safe contract itself.

## Authors
- Stefan George - [@Georgi87](https://github.com/Georgi87)
- Richard Meissner - [@rmeissner](https://github.com/rmeissner)

Please note that this information is based on the `Safe` contract as of the date this document was created and could change in the future. Always refer to the latest version of the contract when developing or auditing smart contracts.