Cryo Explorer Ethereum Mainnet

Address Contract Verified

Address 0x277EF68a815459F9F36a488c93a2cccddcecB19c
Balance 0 ETH
Nonce 33
Code Size 5874 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

5874 bytes
0x6080604052600436106200007a5760003560e01c806372497422116200005557806372497422146200012357806377ab65cd146200015a578063d18af54d146200019e578063ec9e80bb14620001e2576200007a565b80631688f0b9146200007f5780633408e47014620000c357806353e5d93514620000f3575b600080fd5b3480156200008c57600080fd5b50620000ab6004803603810190620000a59190620009cb565b62000226565b604051620000ba919062000ab1565b60405180910390f35b348015620000d057600080fd5b50620000db620002c4565b604051620000ea919062000adf565b60405180910390f35b3480156200010057600080fd5b506200010b620002d1565b6040516200011a919062000b85565b60405180910390f35b6200014160048036038101906200013b919062000c50565b620002fe565b6040516200015192919062000dae565b60405180910390f35b3480156200016757600080fd5b50620001866004803603810190620001809190620009cb565b620003ae565b60405162000195919062000dec565b60405180910390f35b348015620001ab57600080fd5b50620001ca6004803603810190620001c4919062000e4e565b62000496565b604051620001d9919062000ab1565b60405180910390f35b348015620001ef57600080fd5b506200020e6004803603810190620002089190620009cb565b6200058c565b6040516200021d919062000ab1565b60405180910390f35b6000808380519060200120836040516020016200024592919062000f33565b6040516020818303038152906040528051906020012090506200026a85858362000635565b91508173ffffffffffffffffffffffffffffffffffffffff167f4f51faf6c4561ff95f067657e43439f0f856d97c04d9ec9070a6199ad418e23586604051620002b4919062000dec565b60405180910390a2509392505050565b6000804690508091505090565b606060405180602001620002e590620007a7565b6020820181038252601f19601f82011660405250905090565b6000806200030e8c8c8c62000226565b91508173ffffffffffffffffffffffffffffffffffffffff1663f6cc15d08a8a8a8a8a8a8a6040518863ffffffff1660e01b815260040162000357979695949392919062000fa7565b6020604051808303816000875af115801562000377573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200039d919062001055565b90509a509a98505050505050505050565b600080838051906020012083604051602001620003cd92919062000f33565b604051602081830303815290604052805190602001209050600060405180602001620003f990620007a7565b6020820181038252601f19601f820116604052508673ffffffffffffffffffffffffffffffffffffffff1660405160200162000437929190620010c9565b6040516020818303038152906040529050600060ff60f81b308484805190602001206040516020016200046e949392919062001196565b6040516020818303038152906040528051906020012090508060001c93505050509392505050565b6000808383604051602001620004ae9291906200122f565b6040516020818303038152906040528051906020012060001c9050620004d686868362000226565b9150600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161462000583578273ffffffffffffffffffffffffffffffffffffffff16631e52b518838888886040518563ffffffff1660e01b81526004016200054e94939291906200125f565b600060405180830381600087803b1580156200056957600080fd5b505af11580156200057e573d6000803e3d6000fd5b505050505b50949350505050565b600080838051906020012083620005a2620002c4565b604051602001620005b693929190620012b3565b604051602081830303815290604052805190602001209050620005db85858362000635565b91508173ffffffffffffffffffffffffffffffffffffffff167f4f51faf6c4561ff95f067657e43439f0f856d97c04d9ec9070a6199ad418e2358660405162000625919062000dec565b60405180910390a2509392505050565b6000620006428462000794565b62000684576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016200067b9062001357565b60405180910390fd5b6000604051806020016200069890620007a7565b6020820181038252601f19601f820116604052508573ffffffffffffffffffffffffffffffffffffffff16604051602001620006d6929190620010c9565b6040516020818303038152906040529050828151826020016000f59150600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff160362000765576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016200075c90620013c9565b60405180910390fd5b6000845111156200078c5760008060008651602088016000875af1036200078b57600080fd5b5b509392505050565b600080823b905060008111915050919050565b6102d180620013ec83390190565b6000604051905090565b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000620007f682620007c9565b9050919050565b6200080881620007e9565b81146200081457600080fd5b50565b6000813590506200082881620007fd565b92915050565b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b620008838262000838565b810181811067ffffffffffffffff82111715620008a557620008a462000849565b5b80604052505050565b6000620008ba620007b5565b9050620008c8828262000878565b919050565b600067ffffffffffffffff821115620008eb57620008ea62000849565b5b620008f68262000838565b9050602081019050919050565b82818337600083830152505050565b6000620009296200092384620008cd565b620008ae565b90508281526020810184848401111562000948576200094762000833565b5b6200095584828562000903565b509392505050565b600082601f8301126200097557620009746200082e565b5b81356200098784826020860162000912565b91505092915050565b6000819050919050565b620009a58162000990565b8114620009b157600080fd5b50565b600081359050620009c5816200099a565b92915050565b600080600060608486031215620009e757620009e6620007bf565b5b6000620009f78682870162000817565b935050602084013567ffffffffffffffff81111562000a1b5762000a1a620007c4565b5b62000a29868287016200095d565b925050604062000a3c86828701620009b4565b9150509250925092565b6000819050919050565b600062000a7162000a6b62000a6584620007c9565b62000a46565b620007c9565b9050919050565b600062000a858262000a50565b9050919050565b600062000a998262000a78565b9050919050565b62000aab8162000a8c565b82525050565b600060208201905062000ac8600083018462000aa0565b92915050565b62000ad98162000990565b82525050565b600060208201905062000af6600083018462000ace565b92915050565b600081519050919050565b600082825260208201905092915050565b60005b8381101562000b3857808201518184015260208101905062000b1b565b60008484015250505050565b600062000b518262000afc565b62000b5d818562000b07565b935062000b6f81856020860162000b18565b62000b7a8162000838565b840191505092915050565b6000602082019050818103600083015262000ba1818462000b44565b905092915050565b600080fd5b600080fd5b60008083601f84011262000bcc5762000bcb6200082e565b5b8235905067ffffffffffffffff81111562000bec5762000beb62000ba9565b5b60208301915083600182028301111562000c0b5762000c0a62000bae565b5b9250929050565b600060ff82169050919050565b62000c2a8162000c12565b811462000c3657600080fd5b50565b60008135905062000c4a8162000c1f565b92915050565b6000806000806000806000806000806101208b8d03121562000c775762000c76620007bf565b5b600062000c878d828e0162000817565b9a505060208b013567ffffffffffffffff81111562000cab5762000caa620007c4565b5b62000cb98d828e016200095d565b995050604062000ccc8d828e01620009b4565b985050606062000cdf8d828e0162000817565b975050608062000cf28d828e01620009b4565b96505060a08b013567ffffffffffffffff81111562000d165762000d15620007c4565b5b62000d248d828e0162000bb3565b955095505060c062000d398d828e0162000c39565b93505060e062000d4c8d828e01620009b4565b9250506101008b013567ffffffffffffffff81111562000d715762000d70620007c4565b5b62000d7f8d828e016200095d565b9150509295989b9194979a5092959850565b60008115159050919050565b62000da88162000d91565b82525050565b600060408201905062000dc5600083018562000aa0565b62000dd4602083018462000d9d565b9392505050565b62000de681620007e9565b82525050565b600060208201905062000e03600083018462000ddb565b92915050565b600062000e1682620007e9565b9050919050565b62000e288162000e09565b811462000e3457600080fd5b50565b60008135905062000e488162000e1d565b92915050565b6000806000806080858703121562000e6b5762000e6a620007bf565b5b600062000e7b8782880162000817565b945050602085013567ffffffffffffffff81111562000e9f5762000e9e620007c4565b5b62000ead878288016200095d565b935050604062000ec087828801620009b4565b925050606062000ed38782880162000e37565b91505092959194509250565b6000819050919050565b6000819050919050565b62000f0862000f028262000edf565b62000ee9565b82525050565b6000819050919050565b62000f2d62000f278262000990565b62000f0e565b82525050565b600062000f41828562000ef3565b60208201915062000f53828462000f18565b6020820191508190509392505050565b600062000f71838562000b07565b935062000f8083858462000903565b62000f8b8362000838565b840190509392505050565b62000fa18162000c12565b82525050565b600060c08201905062000fbe600083018a62000ddb565b62000fcd602083018962000ace565b818103604083015262000fe281878962000f63565b905062000ff3606083018662000f96565b62001002608083018562000ace565b81810360a083015262001016818462000b44565b905098975050505050505050565b6200102f8162000d91565b81146200103b57600080fd5b50565b6000815190506200104f8162001024565b92915050565b6000602082840312156200106e576200106d620007bf565b5b60006200107e848285016200103e565b91505092915050565b600081905092915050565b60006200109f8262000afc565b620010ab818562001087565b9350620010bd81856020860162000b18565b80840191505092915050565b6000620010d7828562001092565b9150620010e5828462000f18565b6020820191508190509392505050565b60007fff0000000000000000000000000000000000000000000000000000000000000082169050919050565b6000819050919050565b620011406200113a82620010f5565b62001121565b82525050565b60008160601b9050919050565b6000620011608262001146565b9050919050565b6000620011748262001153565b9050919050565b620011906200118a82620007e9565b62001167565b82525050565b6000620011a482876200112b565b600182019150620011b682866200117b565b601482019150620011c8828562000ef3565b602082019150620011da828462000ef3565b60208201915081905095945050505050565b6000620011f98262000a50565b9050919050565b60006200120d82620011ec565b9050919050565b62001229620012238262001200565b62001167565b82525050565b60006200123d828562000f18565b6020820191506200124f828462001214565b6014820191508190509392505050565b600060808201905062001276600083018762000aa0565b62001285602083018662000ddb565b818103604083015262001299818562000b44565b9050620012aa606083018462000ace565b95945050505050565b6000620012c1828662000ef3565b602082019150620012d3828562000f18565b602082019150620012e5828462000f18565b602082019150819050949350505050565b600082825260208201905092915050565b7f53696e676c65746f6e20636f6e7472616374206e6f74206465706c6f79656400600082015250565b60006200133f601f83620012f6565b91506200134c8262001307565b602082019050919050565b60006020820190508181036000830152620013728162001330565b9050919050565b7f437265617465322063616c6c206661696c656400000000000000000000000000600082015250565b6000620013b1601383620012f6565b9150620013be8262001379565b602082019050919050565b60006020820190508181036000830152620013e481620013a2565b905091905056fe608060405234801561001057600080fd5b506040516102d13803806102d18339818101604052810190610032919061014a565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16036100a1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610098906101fa565b60405180910390fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505061021a565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610117826100ec565b9050919050565b6101278161010c565b811461013257600080fd5b50565b6000815190506101448161011e565b92915050565b6000602082840312156101605761015f6100e7565b5b600061016e84828501610135565b91505092915050565b600082825260208201905092915050565b7f496e76616c69642073696e676c65746f6e20616464726573732070726f76696460008201527f6564000000000000000000000000000000000000000000000000000000000000602082015250565b60006101e4602283610177565b91506101ef82610188565b604082019050919050565b60006020820190508181036000830152610213816101d7565b9050919050565b60a9806102286000396000f3fe608060405273ffffffffffffffffffffffffffffffffffffffff600054167fa619486e0000000000000000000000000000000000000000000000000000000060003503604f578060005260206000f35b3660008037600080366000845af43d6000803e60008103606e573d6000fd5b3d6000f3fea2646970667358221220e3dcce0c967108a4f32bfc0ed20c923c1f2849ec587295bccf2782dad8fb9dc964736f6c63430008110033a2646970667358221220f86d117221d6edbf80998646bb329568b48f8b49473bf07df8efd2282239061264736f6c63430008110033

Verified Source Code Full Match

Compiler: v0.8.17+commit.8df45f5f EVM: london Optimization: No
NXVProxy.sol 52 lines
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.7.0 <0.9.0;

/**
 * @title IProxy - Helper interface to access the singleton address of the Proxy on-chain.
 * @author Richard Meissner - @rmeissner
 */
interface IProxy {
    function masterCopy() external view returns (address);
}

/**
 * @title NXVProxy - Generic proxy contract allows to execute all transactions applying the code of a master contract.
 * @author Stefan George - <[email protected]>
 * @author Richard Meissner - <[email protected]>
 */
contract NXVProxy {
    // Singleton always needs to be first declared variable, to ensure that it is at the same location in the contracts to which calls are delegated.
    // To reduce deployment costs this variable is internal and needs to be retrieved via `getStorageAt`.
    address internal singleton;

    /**
     * @notice Constructor function sets address of singleton contract.
     * @param _singleton Singleton address.
     */
    constructor(address _singleton) {
        require(_singleton != address(0), "Invalid singleton address provided");
        singleton = _singleton;
    }

    /// @dev Fallback function forwards all transactions and returns all received return data.
    fallback() external payable {
        // solhint-disable-next-line no-inline-assembly
        assembly {
            let _singleton := and(sload(0), 0xffffffffffffffffffffffffffffffffffffffff)
            // 0xa619486e == keccak("masterCopy()"). The value is right padded to 32-bytes with 0s
            if eq(calldataload(0), 0xa619486e00000000000000000000000000000000000000000000000000000000) {
                mstore(0, _singleton)
                return(0, 0x20)
            }
            calldatacopy(0, 0, calldatasize())
            let success := delegatecall(gas(), _singleton, 0, calldatasize(), 0, 0)
            returndatacopy(0, 0, returndatasize())
            if eq(success, 0) {
                revert(0, returndatasize())
            }
            return(0, returndatasize())
        }
    }
}

// .
NXVProxyFactory.sol 190 lines
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.7.0 <0.9.0;

import {NXVProxy} from "./NXVProxy.sol";
import {IProxyCreationCallback} from "./IProxyCreationCallback.sol";

interface INXV {
        function execTransaction(
        address to,
        uint256 value,
        bytes calldata data,
        uint8 operation,
        uint256 nonce,
        bytes memory signatures
    ) external payable returns (bool success);
}

/**
 * @title Proxy Factory - Allows to create a new proxy contract and execute a message call to the new proxy within one transaction.
 * @author Stefan George - @Georgi87
 */
contract NXVProxyFactory {
    event ProxyCreation(NXVProxy indexed proxy, address singleton);

    /// @dev Allows to retrieve the creation code used for the Proxy deployment. With this it is easily possible to calculate predicted address.
    function proxyCreationCode() public pure returns (bytes memory) {
        return type(NXVProxy).creationCode;
    }

    /**
     * @notice Internal method to create a new proxy contract using CREATE2. Optionally executes an initializer call to a new proxy.
     * @param _singleton Address of singleton contract. Must be deployed at the time of execution.
     * @param initializer (Optional) Payload for a message call to be sent to a new proxy contract.
     * @param salt Create2 salt to use for calculating the address of the new proxy contract.
     * @return proxy Address of the new proxy contract.
     */
    function deployProxy(address _singleton, bytes memory initializer, bytes32 salt) internal returns (NXVProxy proxy) {
        require(isContract(_singleton), "Singleton contract not deployed");

        bytes memory deploymentData = abi.encodePacked(type(NXVProxy).creationCode, uint256(uint160(_singleton)));
        // solhint-disable-next-line no-inline-assembly
        assembly {
            proxy := create2(0x0, add(0x20, deploymentData), mload(deploymentData), salt)
        }
        require(address(proxy) != address(0), "Create2 call failed");

        if (initializer.length > 0) {
            // solhint-disable-next-line no-inline-assembly
            assembly {
                if eq(call(gas(), proxy, 0, add(initializer, 0x20), mload(initializer), 0, 0), 0) {
                    revert(0, 0)
                }
            }
        }
    }

    /**
     * @notice Deploys a new proxy with `_singleton` singleton and `saltNonce` salt. Optionally executes an initializer call to a new proxy.
     * @param _singleton Address of singleton contract. Must be deployed at the time of execution.
     * @param initializer Payload for a message call to be sent to a new proxy contract.
     * @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.
     */
    function createProxyWithNonce(address _singleton, bytes memory initializer, uint256 saltNonce) public returns (NXVProxy proxy) {
        // If the initializer changes the proxy address should change too. Hashing the initializer data is cheaper than just concatinating it
        bytes32 salt = keccak256(abi.encodePacked(keccak256(initializer), saltNonce));
        proxy = deployProxy(_singleton, initializer, salt);
        emit ProxyCreation(proxy, _singleton);
    }

    /**
     * @notice Deploys a new chain-specific proxy with `_singleton` singleton and `saltNonce` salt. Optionally executes an initializer call to a new proxy.
     * @dev Allows to create a new proxy contract that should exist only on 1 network (e.g. specific governance or admin accounts)
     *      by including the chain id in the create2 salt. Such proxies cannot be created on other networks by replaying the transaction.
     * @param _singleton Address of singleton contract. Must be deployed at the time of execution.
     * @param initializer Payload for a message call to be sent to a new proxy contract.
     * @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.
     */
    function createChainSpecificProxyWithNonce(
        address _singleton,
        bytes memory initializer,
        uint256 saltNonce
    ) public returns (NXVProxy proxy) {
        // If the initializer changes the proxy address should change too. Hashing the initializer data is cheaper than just concatinating it
        bytes32 salt = keccak256(abi.encodePacked(keccak256(initializer), saltNonce, getChainId()));
        proxy = deployProxy(_singleton, initializer, salt);
        emit ProxyCreation(proxy, _singleton);
    }

    /**
     * @notice Deploy a new proxy with `_singleton` singleton and `saltNonce` salt.
     *         Optionally executes an initializer call to a new proxy and calls a specified callback address `callback`.
     * @param _singleton Address of singleton contract. Must be deployed at the time of execution.
     * @param initializer Payload for a message call to be sent to a new proxy contract.
     * @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.
     * @param callback Callback that will be invoked after the new proxy contract has been successfully deployed and initialized.
     */
    function createProxyWithCallback(
        address _singleton,
        bytes memory initializer,
        uint256 saltNonce,
        IProxyCreationCallback callback
    ) public returns (NXVProxy proxy) {
        uint256 saltNonceWithCallback = uint256(keccak256(abi.encodePacked(saltNonce, callback)));
        proxy = createProxyWithNonce(_singleton, initializer, saltNonceWithCallback);
        if (address(callback) != address(0)) callback.proxyCreated(proxy, _singleton, initializer, saltNonce);
    }

    /**
     * @notice Deploy a new proxy with `_singleton` singleton and `saltNonce` salt.
     *         Optionally executes an initializer call to a new proxy and calls execTransaction() function with signatures.
     * @param _singleton Address of singleton contract. Must be deployed at the time of execution.
     * @param initializer Payload for a message call to be sent to a new proxy contract.
     * @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.
     * @param to to address of Safe transaction.
     * @param value Ether value of Safe transaction.
     * @param data Data payload of Safe transaction.
     * @param operation Operation type of Safe transaction.
     * @param nonce Transaction nonce
     * @param signatures Signature data that should be verified.
     *                   Can be packed ECDSA signature ({bytes32 r}{bytes32 s}{uint8 v}), contract signature (EIP-1271) or approved hash.
     */
    function createProxyWithTransaction(
        address _singleton,
        bytes memory initializer,
        uint256 saltNonce,
        address to,
        uint256 value,
        bytes calldata data,
        uint8 operation,
        uint256 nonce,
        bytes memory signatures
    ) public payable returns (NXVProxy wallet, bool success) {
        wallet = createProxyWithNonce(_singleton, initializer, saltNonce);
        success = INXV(address(wallet)).execTransaction(to, value, data, operation, nonce, signatures);
    }

    /**
     * @notice Calculate proxy address with `_singleton` singleton, `initializer` initializer data, and `saltNonce` salt.
     * @param _singleton Address of singleton contract. Must be deployed at the time of execution.
     * @param initializer Payload for a message call to be sent to a new proxy contract.
     * @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.
     */
    function calculateNXVAddress(
        address _singleton,
        bytes memory initializer,
        uint256 saltNonce
    ) public view returns (address) {
        bytes32 salt = keccak256(abi.encodePacked(keccak256(initializer), saltNonce));
        bytes memory deploymentData = abi.encodePacked(type(NXVProxy).creationCode, uint256(uint160(_singleton)));
        bytes32 hash = keccak256(abi.encodePacked(
            bytes1(0xff),
            address(this),
            salt,
            keccak256(deploymentData)
        ));

        return address(uint160(uint256(hash)));
    }

    /**
     * @notice Returns true if `account` is a contract.
     * @dev This function will return false if invoked during the constructor of a contract,
     *      as the code is not actually created until after the constructor finishes.
     * @param account The address being queried
     * @return True if `account` is a contract
     */
    function isContract(address account) internal view returns (bool) {
        uint256 size;
        // solhint-disable-next-line no-inline-assembly
        assembly {
            size := extcodesize(account)
        }
        return size > 0;
    }

    /**
     * @notice Returns the ID of the chain the contract is currently deployed on.
     * @return The ID of the current chain as a uint256.
     */
    function getChainId() public view returns (uint256) {
        uint256 id;
        // solhint-disable-next-line no-inline-assembly
        assembly {
            id := chainid()
        }
        return id;
    }
}

// .
IProxyCreationCallback.sol 20 lines
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.7.0 <0.9.0;
import {NXVProxy} from "./NXVProxy.sol";

/**
 * @title IProxyCreationCallback
 * @dev An interface for a contract that implements a callback function to be executed after the creation of a proxy instance.
 */
interface IProxyCreationCallback {
    /**
     * @dev Function to be called after the creation of a NXVProxy instance.
     * @param proxy The newly created NXVProxy instance.
     * @param _singleton The address of the singleton contract used to create the proxy.
     * @param initializer The initializer function call data.
     * @param saltNonce The nonce used to generate the salt for the proxy deployment.
     */
    function proxyCreated(NXVProxy proxy, address _singleton, bytes calldata initializer, uint256 saltNonce) external;
}

// .

Read Contract

calculateNXVAddress 0x77ab65cd → address
getChainId 0x3408e470 → uint256
proxyCreationCode 0x53e5d935 → bytes

Write Contract 4 functions

These functions modify contract state and require a wallet transaction to execute.

createChainSpecificProxyWithNonce 0xec9e80bb
address _singleton
bytes initializer
uint256 saltNonce
returns: address
createProxyWithCallback 0xd18af54d
address _singleton
bytes initializer
uint256 saltNonce
address callback
returns: address
createProxyWithNonce 0x1688f0b9
address _singleton
bytes initializer
uint256 saltNonce
returns: address
createProxyWithTransaction 0x72497422
address _singleton
bytes initializer
uint256 saltNonce
address to
uint256 value
bytes data
uint8 operation
uint256 nonce
bytes signatures
returns: address, bool

Recent Transactions

No transactions found for this address