false
false
0
The new Blockscout UI is now open source! Learn how to deploy it here
- We're indexing this chain right now. Some of the counts may be inaccurate.

Contract Address Details

0xBD89A1CE4DDe368FFAB0eC35506eEcE0b1fFdc54

Contract Name
SafeToL2Setup
Creator
Balance
0 ETH
Tokens
Fetching tokens...
Transactions
0 Transactions
Transfers
0 Transfers
Gas Used
Fetching gas used...
Last Balance Update
5618269
Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
Contract name:
SafeToL2Setup




Optimization enabled
false
Compiler version
v0.7.6+commit.7338295f




EVM Version
default




Verified at
2026-01-28T16:05:22.238668Z

contracts/libraries/SafeToL2Setup.sol

// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.7.0 <0.9.0;

import {SafeStorage} from "../libraries/SafeStorage.sol";

/**
 * @title Safe to L2 Setup Contract
 * @dev This contract expects the singleton to be the {Safe} by default. Even if there are more
 * {SafeL2} proxies deployed, the average gas cost on L2s is significantly lower, making the
 * current design more economically efficient overall.
 * @notice This contract facilitates the deployment of a Safe to the same address on all networks by
 *         automatically changing the singleton to the L2 version when not on chain ID 1.
 */
contract SafeToL2Setup is SafeStorage {
    /**
     * @dev Address of the contract.
     *      This is used to ensure that the contract is only ever `DELEGATECALL`-ed.
     */
    address private immutable SELF;

    /**
     * @notice Event indicating a change of master copy address.
     * @param singleton New master copy address
     */
    event ChangedMasterCopy(address singleton);

    /**
     * @notice Initializes a new {SafeToL2Setup} instance.
     */
    constructor() {
        SELF = address(this);
    }

    /**
     * @notice Modifier ensure a function is only called via `DELEGATECALL`. Will revert otherwise.
     */
    modifier onlyDelegateCall() {
        require(address(this) != SELF, "SafeToL2Setup should only be called via delegatecall");
        _;
    }

    /**
     * @notice Modifier to prevent using initialized Safes.
     */
    modifier onlyNonceZero() {
        require(nonce == 0, "Safe must have not executed any tx");
        _;
    }

    /**
     * @notice Modifier to ensure that the specified account is a contract.
     *
     */
    modifier onlyContract(address account) {
        require(codeSize(account) != 0, "Account doesn't contain code");
        _;
    }

    /**
     * @notice Setup the Safe with the provided L2 singleton if needed.
     * @dev This function checks that the chain ID is not 1, and if it isn't updates the singleton
     *      to the provided L2 singleton.
     */
    function setupToL2(address l2Singleton) external onlyDelegateCall onlyNonceZero onlyContract(l2Singleton) {
        if (chainId() != 1) {
            singleton = l2Singleton;
            emit ChangedMasterCopy(l2Singleton);
        }
    }

    /**
     * @notice Returns the current chain ID.
     */
    function chainId() private view returns (uint256 result) {
        /* solhint-disable no-inline-assembly */
        /// @solidity memory-safe-assembly
        assembly {
            result := chainid()
        }
        /* solhint-enable no-inline-assembly */
    }

    /**
     * @notice Returns the code size of the specified account.
     */
    function codeSize(address account) internal view returns (uint256 result) {
        /* solhint-disable no-inline-assembly */
        /// @solidity memory-safe-assembly
        assembly {
            result := extcodesize(account)
        }
        /* solhint-enable no-inline-assembly */
    }
}
        

contracts/libraries/SafeStorage.sol

// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.7.0 <0.9.0;

/**
 * @title SafeStorage - Storage layout of the Safe contracts to be used in libraries.
 * @dev Should be always the first base contract of a library that is used with a Safe.
 * @author Richard Meissner - @rmeissner
 */
contract SafeStorage {
    // From /common/Singleton.sol
    address internal singleton;
    // From /common/ModuleManager.sol
    mapping(address => address) internal modules;
    // From /common/OwnerManager.sol
    mapping(address => address) internal owners;
    uint256 internal ownerCount;
    uint256 internal threshold;

    // From /Safe.sol
    uint256 internal nonce;
    bytes32 internal _deprecatedDomainSeparator;
    mapping(bytes32 => uint256) internal signedMessages;
    mapping(address => mapping(bytes32 => uint256)) internal approvedHashes;
}
          

Compiler Settings

{"outputSelection":{"*":{"*":["*"],"":["*"]}},"optimizer":{"runs":200,"enabled":false},"metadata":{"useLiteralContent":true},"libraries":{}}
              

Contract ABI

[{"type":"constructor","stateMutability":"nonpayable","inputs":[]},{"type":"event","name":"ChangedMasterCopy","inputs":[{"type":"address","name":"singleton","internalType":"address","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setupToL2","inputs":[{"type":"address","name":"l2Singleton","internalType":"address"}]}]
              

Deployed ByteCode

0x608060405234801561001057600080fd5b506004361061002b5760003560e01c8063fe51f64314610030575b600080fd5b6100726004803603602081101561004657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610074565b005b7f000000000000000000000000bd89a1ce4dde368ffab0ec35506eece0b1ffdc5473ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff161415610119576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260348152602001806102a96034913960400191505060405180910390fd5b600060055414610174576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806102dd6022913960400191505060405180910390fd5b80600061018082610295565b14156101f4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601c8152602001807f4163636f756e7420646f65736e277420636f6e7461696e20636f64650000000081525060200191505060405180910390fd5b60016101fe6102a0565b1461029157816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507f75e41bc35ff1bf14d81d1d2f649c0084a0f974f9289c803ec9898eeec4c8d0b882604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a15b5050565b6000813b9050919050565b60004690509056fe53616665546f4c3253657475702073686f756c64206f6e6c792062652063616c6c6564207669612064656c656761746563616c6c53616665206d7573742068617665206e6f7420657865637574656420616e79207478a264697066735822122023649cd94e3067c8a913b2bbb4a32dc4fea9be2d0f070a4b7403c3e4e8db452464736f6c63430007060033