Cryo Explorer Ethereum Mainnet

Address Contract Partially Verified

Address 0x22C08C358f62f35B742D023Bf2fAF67e30e5376E
Balance 0.240000 ETH
Nonce 1
Code Size 7777 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

7777 bytes
0x6080604052600436106101d85760003560e01c80636352211e1161010257806395d89b4111610095578063cd85cdb511610064578063cd85cdb51461055d578063d1058e5914610572578063e985e9c51461057a578063f2fde38b146105b557600080fd5b806395d89b41146104e8578063a22cb465146104fd578063b88d4fde1461051d578063c87b56dd1461053d57600080fd5b806386b8703b116100d157806386b8703b146104845780638da5cb5b1461049f5780638ecad721146104bd578063902d55a5146104d257600080fd5b80636352211e146103f75780636c0360eb1461042d57806370a0823114610442578063715018a61461046f57600080fd5b806323cf0a221161017a578063379607f511610149578063379607f51461038f5780633ccfd60b146103a257806342842e0e146103b757806355f804b3146103d757600080fd5b806323cf0a221461032d57806325fd90f3146103405780632be095611461035a57806330503c4e1461036f57600080fd5b8063095ea7b3116101b6578063095ea7b314610282578063150b7a02146102a457806318160ddd146102e957806323b872dd1461030d57600080fd5b806301ffc9a7146101dd57806306fdde0314610212578063081812fc14610234575b600080fd5b3480156101e957600080fd5b506101fd6101f83660046116b6565b6105d5565b60405190151581526020015b60405180910390f35b34801561021e57600080fd5b5061022761065d565b6040516102099190611732565b34801561024057600080fd5b5061026a61024f366004611745565b6005602052600090815260409020546001600160a01b031681565b6040516001600160a01b039091168152602001610209565b34801561028e57600080fd5b506102a261029d366004611773565b6106eb565b005b3480156102b057600080fd5b506102d06102bf36600461179f565b630a85bd0160e11b95945050505050565b6040516001600160e01b03199091168152602001610209565b3480156102f557600080fd5b506102ff60085481565b604051908152602001610209565b34801561031957600080fd5b506102a261032836600461183e565b6107d2565b6102a261033b36600461187f565b610999565b34801561034c57600080fd5b506007546101fd9060ff1681565b34801561036657600080fd5b506102a2610a8a565b34801561037b57600080fd5b50600b5461026a906001600160a01b031681565b6102a261039d366004611745565b610ae8565b3480156103ae57600080fd5b506102a2610b9c565b3480156103c357600080fd5b506102a26103d236600461183e565b610c19565b3480156103e357600080fd5b506102a26103f2366004611944565b610d11565b34801561040357600080fd5b5061026a610412366004611745565b6004602052600090815260409020546001600160a01b031681565b34801561043957600080fd5b50610227610d53565b34801561044e57600080fd5b506102ff61045d36600461198d565b60036020526000908152604090205481565b34801561047b57600080fd5b506102a2610d60565b34801561049057600080fd5b506102ff66b1a2bc2ec5000081565b3480156104ab57600080fd5b506000546001600160a01b031661026a565b3480156104c957600080fd5b506102ff601481565b3480156104de57600080fd5b506102ff61271081565b3480156104f457600080fd5b50610227610d9d565b34801561050957600080fd5b506102a26105183660046119aa565b610daa565b34801561052957600080fd5b506102a26105383660046119e8565b610e16565b34801561054957600080fd5b50610227610558366004611745565b610efb565b34801561056957600080fd5b506102a2610f65565b6102a2610fbf565b34801561058657600080fd5b506101fd610595366004611a68565b600660209081526000928352604080842090915290825290205460ff1681565b3480156105c157600080fd5b506102a26105d036600461198d565b611177565b60006307f5828d60e41b6001600160e01b03198316148061060657506380ac58cd60e01b6001600160e01b03198316145b806106215750635b5e139f60e01b6001600160e01b03198316145b8061063c57506301ffc9a760e01b6001600160e01b03198316145b806106575750630a85bd0160e11b6001600160e01b03198316145b92915050565b6001805461066a90611a96565b80601f016020809104026020016040519081016040528092919081815260200182805461069690611a96565b80156106e35780601f106106b8576101008083540402835291602001916106e3565b820191906000526020600020905b8154815290600101906020018083116106c657829003601f168201915b505050505081565b6000818152600460205260409020546001600160a01b03163381148061073457506001600160a01b038116600090815260066020908152604080832033845290915290205460ff165b6107765760405162461bcd60e51b815260206004820152600e60248201526d1393d517d055551213d49256915160921b60448201526064015b60405180910390fd5b60008281526005602052604080822080546001600160a01b0319166001600160a01b0387811691821790925591518593918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b6000818152600460205260409020546001600160a01b038481169116146108285760405162461bcd60e51b815260206004820152600a60248201526957524f4e475f46524f4d60b01b604482015260640161076d565b6001600160a01b0382166108725760405162461bcd60e51b81526020600482015260116024820152701253959053125117d49150d25412515395607a1b604482015260640161076d565b336001600160a01b038416148061089f57506000818152600560205260409020546001600160a01b031633145b806108cd57506001600160a01b038316600090815260066020908152604080832033845290915290205460ff165b61090a5760405162461bcd60e51b815260206004820152600e60248201526d1393d517d055551213d49256915160921b604482015260640161076d565b6001600160a01b0380841660008181526003602090815260408083208054600019019055938616808352848320805460010190558583526004825284832080546001600160a01b03199081168317909155600590925284832080549092169091559251849392917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b60075460ff166109bc5760405163914edb0f60e01b815260040160405180910390fd5b6127108161ffff166008546109d19190611ae7565b106109ef57604051637364ba1760e01b815260040160405180910390fd5b610a0466b1a2bc2ec5000061ffff8316611aff565b341015610a2457604051632c1d501360e11b815260040160405180910390fd5b60148161ffff161115610a4a57604051632493f4c960e11b815260040160405180910390fd5b60085460005b8261ffff168161ffff161015610a83576000610a6a6111c4565b9050610a7633826112f0565b5060019182019101610a50565b5060085550565b6000546001600160a01b03163314610ab5576040516330cd747160e01b815260040160405180910390fd5b60075460ff1615610ad9576040516376c855ed60e01b815260040160405180910390fd5b6007805460ff19166001179055565b610af233826113fb565b15610b8357600b54604051632142170760e11b8152336004820152306024820152604481018390526001600160a01b03909116906342842e0e90606401600060405180830381600087803b158015610b4957600080fd5b505af1158015610b5d573d6000803e3d6000fd5b50505050610b6b33826112f0565b60088054906000610b7b83611b1e565b919050555050565b6040516359dc379f60e01b815260040160405180910390fd5b600c546001600160a01b03163314610c015760405162461bcd60e51b815260206004820152602260248201527f4e6f742063616c6c61626c6520657863657074206279207465616d2077616c6c604482015261195d60f21b606482015260840161076d565b600c54610c17906001600160a01b0316476114ad565b565b610c248383836107d2565b6001600160a01b0382163b1580610ccd5750604051630a85bd0160e11b8082523360048301526001600160a01b03858116602484015260448301849052608060648401526000608484015290919084169063150b7a029060a4016020604051808303816000875af1158015610c9d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cc19190611b39565b6001600160e01b031916145b610d0c5760405162461bcd60e51b815260206004820152601060248201526f155394d0519157d49150d2541251539560821b604482015260640161076d565b505050565b6000546001600160a01b03163314610d3c576040516330cd747160e01b815260040160405180910390fd5b8051610d4f90600a906020840190611604565b5050565b600a805461066a90611a96565b6000546001600160a01b03163314610d8b576040516330cd747160e01b815260040160405180910390fd5b600080546001600160a01b0319169055565b6002805461066a90611a96565b3360008181526006602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b610e218484846107d2565b6001600160a01b0383163b1580610eb65750604051630a85bd0160e11b808252906001600160a01b0385169063150b7a0290610e67903390899088908890600401611b56565b6020604051808303816000875af1158015610e86573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610eaa9190611b39565b6001600160e01b031916145b610ef55760405162461bcd60e51b815260206004820152601060248201526f155394d0519157d49150d2541251539560821b604482015260640161076d565b50505050565b6000818152600460205260409020546060906001600160a01b0316610f335760405163b0ce759160e01b815260040160405180910390fd5b600a610f3e836114fe565b604051602001610f4f929190611baf565b6040516020818303038152906040529050919050565b6000546001600160a01b03163314610f90576040516330cd747160e01b815260040160405180910390fd5b60075460ff16610fb35760405163914edb0f60e01b815260040160405180910390fd5b6007805460ff19169055565b600b54604051630ee64c8d60e41b81523360048201526000916001600160a01b03169063ee64c8d090602401600060405180830381865afa158015611008573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526110309190810190611c56565b80516008549192509060005b8281101561116f5760006001600160a01b03166004600086848151811061106557611065611cfd565b6020908102919091018101518252810191909152604001600020546001600160a01b0316141561115f57600b5484516001600160a01b03909116906342842e0e90339030908890869081106110bc576110bc611cfd565b60209081029190910101516040516001600160e01b031960e086901b1681526001600160a01b0393841660048201529290911660248301526044820152606401600060405180830381600087803b15801561111657600080fd5b505af115801561112a573d6000803e3d6000fd5b505050506111513385838151811061114457611144611cfd565b60200260200101516112f0565b8161115b81611b1e565b9250505b61116881611b1e565b905061103c565b506008555050565b6000546001600160a01b031633146111a2576040516330cd747160e01b815260040160405180910390fd5b600080546001600160a01b0319166001600160a01b0392909216919091179055565b600954600090815b600a8110156112d6576000828152600460205260409020546001600160a01b03161561120457816111fc81611b1e565b9250506112c6565b600b546040516331a9108f60e11b8152600481018490526001600160a01b0390911690636352211e90602401602060405180830381865afa925050508015611269575060408051601f3d908101601f1916820190925261126691810190611d13565b60015b6112b757611275611d30565b806308c379a014156112ab575061128a611d4c565b8061129557506112ad565b6112a0836001611ae7565b600955509092915050565b505b3d6000803e3d6000fd5b826112c181611b1e565b935050505b6112cf81611b1e565b90506111cc565b5060405163b009d33760e01b815260040160405180910390fd5b6001600160a01b03821661133a5760405162461bcd60e51b81526020600482015260116024820152701253959053125117d49150d25412515395607a1b604482015260640161076d565b6000818152600460205260409020546001600160a01b0316156113905760405162461bcd60e51b815260206004820152600e60248201526d1053149150511657d3525395115160921b604482015260640161076d565b6001600160a01b038216600081815260036020908152604080832080546001019055848352600490915280822080546001600160a01b0319168417905551839291907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b600b546040516331a9108f60e11b8152600481018390526000916001600160a01b031690636352211e90602401602060405180830381865afa925050508015611461575060408051601f3d908101601f1916820190925261145e91810190611d13565b60015b6114975761146d611d30565b806308c379a014156112ab5750611482611d4c565b8061148d57506112ad565b6000915050610657565b6001600160a01b03848116911614905092915050565b600080600080600085875af1905080610d0c5760405162461bcd60e51b815260206004820152601360248201527211551217d514905394d1915497d19052531151606a1b604482015260640161076d565b6060816115225750506040805180820190915260018152600360fc1b602082015290565b8160005b811561154c578061153681611b1e565b91506115459050600a83611dec565b9150611526565b60008167ffffffffffffffff811115611567576115676118a3565b6040519080825280601f01601f191660200182016040528015611591576020820181803683370190505b5090505b84156115fc576115a6600183611e00565b91506115b3600a86611e17565b6115be906030611ae7565b60f81b8183815181106115d3576115d3611cfd565b60200101906001600160f81b031916908160001a9053506115f5600a86611dec565b9450611595565b949350505050565b82805461161090611a96565b90600052602060002090601f0160209004810192826116325760008555611678565b82601f1061164b57805160ff1916838001178555611678565b82800160010185558215611678579182015b8281111561167857825182559160200191906001019061165d565b50611684929150611688565b5090565b5b808211156116845760008155600101611689565b6001600160e01b0319811681146116b357600080fd5b50565b6000602082840312156116c857600080fd5b81356116d38161169d565b9392505050565b60005b838110156116f55781810151838201526020016116dd565b83811115610ef55750506000910152565b6000815180845261171e8160208601602086016116da565b601f01601f19169290920160200192915050565b6020815260006116d36020830184611706565b60006020828403121561175757600080fd5b5035919050565b6001600160a01b03811681146116b357600080fd5b6000806040838503121561178657600080fd5b82356117918161175e565b946020939093013593505050565b6000806000806000608086880312156117b757600080fd5b85356117c28161175e565b945060208601356117d28161175e565b935060408601359250606086013567ffffffffffffffff808211156117f657600080fd5b818801915088601f83011261180a57600080fd5b81358181111561181957600080fd5b89602082850101111561182b57600080fd5b9699959850939650602001949392505050565b60008060006060848603121561185357600080fd5b833561185e8161175e565b9250602084013561186e8161175e565b929592945050506040919091013590565b60006020828403121561189157600080fd5b813561ffff811681146116d357600080fd5b634e487b7160e01b600052604160045260246000fd5b601f8201601f1916810167ffffffffffffffff811182821017156118df576118df6118a3565b6040525050565b600067ffffffffffffffff831115611900576119006118a3565b604051611917601f8501601f1916602001826118b9565b80915083815284848401111561192c57600080fd5b83836020830137600060208583010152509392505050565b60006020828403121561195657600080fd5b813567ffffffffffffffff81111561196d57600080fd5b8201601f8101841361197e57600080fd5b6115fc848235602084016118e6565b60006020828403121561199f57600080fd5b81356116d38161175e565b600080604083850312156119bd57600080fd5b82356119c88161175e565b9150602083013580151581146119dd57600080fd5b809150509250929050565b600080600080608085870312156119fe57600080fd5b8435611a098161175e565b93506020850135611a198161175e565b925060408501359150606085013567ffffffffffffffff811115611a3c57600080fd5b8501601f81018713611a4d57600080fd5b611a5c878235602084016118e6565b91505092959194509250565b60008060408385031215611a7b57600080fd5b8235611a868161175e565b915060208301356119dd8161175e565b600181811c90821680611aaa57607f821691505b60208210811415611acb57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b60008219821115611afa57611afa611ad1565b500190565b6000816000190483118215151615611b1957611b19611ad1565b500290565b6000600019821415611b3257611b32611ad1565b5060010190565b600060208284031215611b4b57600080fd5b81516116d38161169d565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090611b8990830184611706565b9695505050505050565b60008151611ba58185602086016116da565b9290920192915050565b600080845481600182811c915080831680611bcb57607f831692505b6020808410821415611beb57634e487b7160e01b86526022600452602486fd5b818015611bff5760018114611c1057611c3d565b60ff19861689528489019650611c3d565b60008b81526020902060005b86811015611c355781548b820152908501908301611c1c565b505084890196505b505050505050611c4d8185611b93565b95945050505050565b60006020808385031215611c6957600080fd5b825167ffffffffffffffff80821115611c8157600080fd5b818501915085601f830112611c9557600080fd5b815181811115611ca757611ca76118a3565b8060051b9150604051611cbc858401826118b9565b81815291830184019184810188841115611cd557600080fd5b938501935b83851015611cf15784518152938501938501611cda565b50979650505050505050565b634e487b7160e01b600052603260045260246000fd5b600060208284031215611d2557600080fd5b81516116d38161175e565b600060033d1115611d495760046000803e5060005160e01c5b90565b600060443d1015611d5a5790565b6040516003193d81016004833e81513d67ffffffffffffffff8160248401118184111715611d8a57505050505090565b8285019150815181811115611da25750505050505090565b843d8701016020828501011115611dbc5750505050505090565b611dcb602082860101876118b9565b509095945050505050565b634e487b7160e01b600052601260045260246000fd5b600082611dfb57611dfb611dd6565b500490565b600082821015611e1257611e12611ad1565b500390565b600082611e2657611e26611dd6565b50069056fea2646970667358221220b03eae39a07df02cf0d2d9d94a3da5806276115115c5ab50b593c818923589e964736f6c634300080a0033

Verified Source Code Partial Match

Compiler: v0.8.10+commit.fc410830 EVM: london Optimization: Yes (200 runs)
xApe721.sol 974 lines
// SPDX-License-Identifier: AGPL-3.0-only

pragma solidity >=0.8.0;

/// @notice Modern, minimalist, and gas efficient ERC-721 implementation.
/// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/tokens/ERC721.sol)
/// @dev Note that balanceOf does not revert if passed the zero address, in defiance of the ERC.
abstract contract ERC721 {
    /*///////////////////////////////////////////////////////////////
                                 EVENTS
    //////////////////////////////////////////////////////////////*/

    event Transfer(address indexed from, address indexed to, uint256 indexed id);

    event Approval(address indexed owner, address indexed spender, uint256 indexed id);

    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);

    /*///////////////////////////////////////////////////////////////
                          METADATA STORAGE/LOGIC
    //////////////////////////////////////////////////////////////*/

    string public name;

    string public symbol;

    function tokenURI(uint256 id) public view virtual returns (string memory);

    /*///////////////////////////////////////////////////////////////
                            ERC721 STORAGE                        
    //////////////////////////////////////////////////////////////*/

    mapping(address => uint256) public balanceOf;

    mapping(uint256 => address) public ownerOf;

    mapping(uint256 => address) public getApproved;

    mapping(address => mapping(address => bool)) public isApprovedForAll;

    /*///////////////////////////////////////////////////////////////
                              CONSTRUCTOR
    //////////////////////////////////////////////////////////////*/

    constructor(string memory _name, string memory _symbol) {
        name = _name;
        symbol = _symbol;
    }

    /*///////////////////////////////////////////////////////////////
                              ERC721 LOGIC
    //////////////////////////////////////////////////////////////*/

    function approve(address spender, uint256 id) public virtual {
        address owner = ownerOf[id];

        require(msg.sender == owner || isApprovedForAll[owner][msg.sender], "NOT_AUTHORIZED");

        getApproved[id] = spender;

        emit Approval(owner, spender, id);
    }

    function setApprovalForAll(address operator, bool approved) public virtual {
        isApprovedForAll[msg.sender][operator] = approved;

        emit ApprovalForAll(msg.sender, operator, approved);
    }

    function transferFrom(
        address from,
        address to,
        uint256 id
    ) public virtual {
        require(from == ownerOf[id], "WRONG_FROM");

        require(to != address(0), "INVALID_RECIPIENT");

        require(
            msg.sender == from || msg.sender == getApproved[id] || isApprovedForAll[from][msg.sender],
            "NOT_AUTHORIZED"
        );

        // Underflow of the sender's balance is impossible because we check for
        // ownership above and the recipient's balance can't realistically overflow.
        unchecked {
            balanceOf[from]--;

            balanceOf[to]++;
        }

        ownerOf[id] = to;

        delete getApproved[id];

        emit Transfer(from, to, id);
    }

    function safeTransferFrom(
        address from,
        address to,
        uint256 id
    ) public virtual {
        transferFrom(from, to, id);

        require(
            to.code.length == 0 ||
                ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, "") ==
                ERC721TokenReceiver.onERC721Received.selector,
            "UNSAFE_RECIPIENT"
        );
    }

    function safeTransferFrom(
        address from,
        address to,
        uint256 id,
        bytes memory data
    ) public virtual {
        transferFrom(from, to, id);

        require(
            to.code.length == 0 ||
                ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, data) ==
                ERC721TokenReceiver.onERC721Received.selector,
            "UNSAFE_RECIPIENT"
        );
    }

    /*///////////////////////////////////////////////////////////////
                              ERC165 LOGIC
    //////////////////////////////////////////////////////////////*/

    function supportsInterface(bytes4 interfaceId) public pure virtual returns (bool) {
        return
            interfaceId == 0x01ffc9a7 || // ERC165 Interface ID for ERC165
            interfaceId == 0x80ac58cd || // ERC165 Interface ID for ERC721
            interfaceId == 0x5b5e139f; // ERC165 Interface ID for ERC721Metadata
    }

    /*///////////////////////////////////////////////////////////////
                       INTERNAL MINT/BURN LOGIC
    //////////////////////////////////////////////////////////////*/

    function _mint(address to, uint256 id) internal virtual {
        require(to != address(0), "INVALID_RECIPIENT");

        require(ownerOf[id] == address(0), "ALREADY_MINTED");

        // Counter overflow is incredibly unrealistic.
        unchecked {
            balanceOf[to]++;
        }

        ownerOf[id] = to;

        emit Transfer(address(0), to, id);
    }

    function _burn(uint256 id) internal virtual {
        address owner = ownerOf[id];

        require(ownerOf[id] != address(0), "NOT_MINTED");

        // Ownership check above ensures no underflow.
        unchecked {
            balanceOf[owner]--;
        }

        delete ownerOf[id];

        delete getApproved[id];

        emit Transfer(owner, address(0), id);
    }

    /*///////////////////////////////////////////////////////////////
                       INTERNAL SAFE MINT LOGIC
    //////////////////////////////////////////////////////////////*/

    function _safeMint(address to, uint256 id) internal virtual {
        _mint(to, id);

        require(
            to.code.length == 0 ||
                ERC721TokenReceiver(to).onERC721Received(msg.sender, address(0), id, "") ==
                ERC721TokenReceiver.onERC721Received.selector,
            "UNSAFE_RECIPIENT"
        );
    }

    function _safeMint(
        address to,
        uint256 id,
        bytes memory data
    ) internal virtual {
        _mint(to, id);

        require(
            to.code.length == 0 ||
                ERC721TokenReceiver(to).onERC721Received(msg.sender, address(0), id, data) ==
                ERC721TokenReceiver.onERC721Received.selector,
            "UNSAFE_RECIPIENT"
        );
    }
}

/// @notice A generic interface for a contract which properly accepts ERC721 tokens.
/// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/tokens/ERC721.sol)
interface ERC721TokenReceiver {
    function onERC721Received(
        address operator,
        address from,
        uint256 id,
        bytes calldata data
    ) external returns (bytes4);
}


// File @rari-capital/solmate/src/tokens/[email protected]


pragma solidity >=0.8.0;

/// @notice Modern and gas efficient ERC20 + EIP-2612 implementation.
/// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/tokens/ERC20.sol)
/// @author Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol)
/// @dev Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it.
abstract contract ERC20 {
    /*///////////////////////////////////////////////////////////////
                                  EVENTS
    //////////////////////////////////////////////////////////////*/

    event Transfer(address indexed from, address indexed to, uint256 amount);

    event Approval(address indexed owner, address indexed spender, uint256 amount);

    /*///////////////////////////////////////////////////////////////
                             METADATA STORAGE
    //////////////////////////////////////////////////////////////*/

    string public name;

    string public symbol;

    uint8 public immutable decimals;

    /*///////////////////////////////////////////////////////////////
                              ERC20 STORAGE
    //////////////////////////////////////////////////////////////*/

    uint256 public totalSupply;

    mapping(address => uint256) public balanceOf;

    mapping(address => mapping(address => uint256)) public allowance;

    /*///////////////////////////////////////////////////////////////
                             EIP-2612 STORAGE
    //////////////////////////////////////////////////////////////*/

    bytes32 public constant PERMIT_TYPEHASH =
        keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");

    uint256 internal immutable INITIAL_CHAIN_ID;

    bytes32 internal immutable INITIAL_DOMAIN_SEPARATOR;

    mapping(address => uint256) public nonces;

    /*///////////////////////////////////////////////////////////////
                               CONSTRUCTOR
    //////////////////////////////////////////////////////////////*/

    constructor(
        string memory _name,
        string memory _symbol,
        uint8 _decimals
    ) {
        name = _name;
        symbol = _symbol;
        decimals = _decimals;

        INITIAL_CHAIN_ID = block.chainid;
        INITIAL_DOMAIN_SEPARATOR = computeDomainSeparator();
    }

    /*///////////////////////////////////////////////////////////////
                              ERC20 LOGIC
    //////////////////////////////////////////////////////////////*/

    function approve(address spender, uint256 amount) public virtual returns (bool) {
        allowance[msg.sender][spender] = amount;

        emit Approval(msg.sender, spender, amount);

        return true;
    }

    function transfer(address to, uint256 amount) public virtual returns (bool) {
        balanceOf[msg.sender] -= amount;

        // Cannot overflow because the sum of all user
        // balances can't exceed the max uint256 value.
        unchecked {
            balanceOf[to] += amount;
        }

        emit Transfer(msg.sender, to, amount);

        return true;
    }

    function transferFrom(
        address from,
        address to,
        uint256 amount
    ) public virtual returns (bool) {
        uint256 allowed = allowance[from][msg.sender]; // Saves gas for limited approvals.

        if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - amount;

        balanceOf[from] -= amount;

        // Cannot overflow because the sum of all user
        // balances can't exceed the max uint256 value.
        unchecked {
            balanceOf[to] += amount;
        }

        emit Transfer(from, to, amount);

        return true;
    }

    /*///////////////////////////////////////////////////////////////
                              EIP-2612 LOGIC
    //////////////////////////////////////////////////////////////*/

    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) public virtual {
        require(deadline >= block.timestamp, "PERMIT_DEADLINE_EXPIRED");

        // Unchecked because the only math done is incrementing
        // the owner's nonce which cannot realistically overflow.
        unchecked {
            bytes32 digest = keccak256(
                abi.encodePacked(
                    "\x19\x01",
                    DOMAIN_SEPARATOR(),
                    keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, value, nonces[owner]++, deadline))
                )
            );

            address recoveredAddress = ecrecover(digest, v, r, s);

            require(recoveredAddress != address(0) && recoveredAddress == owner, "INVALID_SIGNER");

            allowance[recoveredAddress][spender] = value;
        }

        emit Approval(owner, spender, value);
    }

    function DOMAIN_SEPARATOR() public view virtual returns (bytes32) {
        return block.chainid == INITIAL_CHAIN_ID ? INITIAL_DOMAIN_SEPARATOR : computeDomainSeparator();
    }

    function computeDomainSeparator() internal view virtual returns (bytes32) {
        return
            keccak256(
                abi.encode(
                    keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"),
                    keccak256(bytes(name)),
                    keccak256("1"),
                    block.chainid,
                    address(this)
                )
            );
    }

    /*///////////////////////////////////////////////////////////////
                       INTERNAL MINT/BURN LOGIC
    //////////////////////////////////////////////////////////////*/

    function _mint(address to, uint256 amount) internal virtual {
        totalSupply += amount;

        // Cannot overflow because the sum of all user
        // balances can't exceed the max uint256 value.
        unchecked {
            balanceOf[to] += amount;
        }

        emit Transfer(address(0), to, amount);
    }

    function _burn(address from, uint256 amount) internal virtual {
        balanceOf[from] -= amount;

        // Cannot underflow because a user's balance
        // will never be larger than the total supply.
        unchecked {
            totalSupply -= amount;
        }

        emit Transfer(from, address(0), amount);
    }
}


// File @rari-capital/solmate/src/utils/[email protected]


pragma solidity >=0.8.0;

/// @notice Safe ETH and ERC20 transfer library that gracefully handles missing return values.
/// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/utils/SafeTransferLib.sol)
/// @author Modified from Gnosis (https://github.com/gnosis/gp-v2-contracts/blob/main/src/contracts/libraries/GPv2SafeERC20.sol)
/// @dev Use with caution! Some functions in this library knowingly create dirty bits at the destination of the free memory pointer.
library SafeTransferLib {
    /*///////////////////////////////////////////////////////////////
                            ETH OPERATIONS
    //////////////////////////////////////////////////////////////*/

    function safeTransferETH(address to, uint256 amount) internal {
        bool callStatus;

        assembly {
            // Transfer the ETH and store if it succeeded or not.
            callStatus := call(gas(), to, amount, 0, 0, 0, 0)
        }

        require(callStatus, "ETH_TRANSFER_FAILED");
    }

    /*///////////////////////////////////////////////////////////////
                           ERC20 OPERATIONS
    //////////////////////////////////////////////////////////////*/

    function safeTransferFrom(
        ERC20 token,
        address from,
        address to,
        uint256 amount
    ) internal {
        bool callStatus;

        assembly {
            // Get a pointer to some free memory.
            let freeMemoryPointer := mload(0x40)

            // Write the abi-encoded calldata to memory piece by piece:
            mstore(freeMemoryPointer, 0x23b872dd00000000000000000000000000000000000000000000000000000000) // Begin with the function selector.
            mstore(add(freeMemoryPointer, 4), and(from, 0xffffffffffffffffffffffffffffffffffffffff)) // Mask and append the "from" argument.
            mstore(add(freeMemoryPointer, 36), and(to, 0xffffffffffffffffffffffffffffffffffffffff)) // Mask and append the "to" argument.
            mstore(add(freeMemoryPointer, 68), amount) // Finally append the "amount" argument. No mask as it's a full 32 byte value.

            // Call the token and store if it succeeded or not.
            // We use 100 because the calldata length is 4 + 32 * 3.
            callStatus := call(gas(), token, 0, freeMemoryPointer, 100, 0, 0)
        }

        require(didLastOptionalReturnCallSucceed(callStatus), "TRANSFER_FROM_FAILED");
    }

    function safeTransfer(
        ERC20 token,
        address to,
        uint256 amount
    ) internal {
        bool callStatus;

        assembly {
            // Get a pointer to some free memory.
            let freeMemoryPointer := mload(0x40)

            // Write the abi-encoded calldata to memory piece by piece:
            mstore(freeMemoryPointer, 0xa9059cbb00000000000000000000000000000000000000000000000000000000) // Begin with the function selector.
            mstore(add(freeMemoryPointer, 4), and(to, 0xffffffffffffffffffffffffffffffffffffffff)) // Mask and append the "to" argument.
            mstore(add(freeMemoryPointer, 36), amount) // Finally append the "amount" argument. No mask as it's a full 32 byte value.

            // Call the token and store if it succeeded or not.
            // We use 68 because the calldata length is 4 + 32 * 2.
            callStatus := call(gas(), token, 0, freeMemoryPointer, 68, 0, 0)
        }

        require(didLastOptionalReturnCallSucceed(callStatus), "TRANSFER_FAILED");
    }

    function safeApprove(
        ERC20 token,
        address to,
        uint256 amount
    ) internal {
        bool callStatus;

        assembly {
            // Get a pointer to some free memory.
            let freeMemoryPointer := mload(0x40)

            // Write the abi-encoded calldata to memory piece by piece:
            mstore(freeMemoryPointer, 0x095ea7b300000000000000000000000000000000000000000000000000000000) // Begin with the function selector.
            mstore(add(freeMemoryPointer, 4), and(to, 0xffffffffffffffffffffffffffffffffffffffff)) // Mask and append the "to" argument.
            mstore(add(freeMemoryPointer, 36), amount) // Finally append the "amount" argument. No mask as it's a full 32 byte value.

            // Call the token and store if it succeeded or not.
            // We use 68 because the calldata length is 4 + 32 * 2.
            callStatus := call(gas(), token, 0, freeMemoryPointer, 68, 0, 0)
        }

        require(didLastOptionalReturnCallSucceed(callStatus), "APPROVE_FAILED");
    }

    /*///////////////////////////////////////////////////////////////
                         INTERNAL HELPER LOGIC
    //////////////////////////////////////////////////////////////*/

    function didLastOptionalReturnCallSucceed(bool callStatus) private pure returns (bool success) {
        assembly {
            // Get how many bytes the call returned.
            let returnDataSize := returndatasize()

            // If the call reverted:
            if iszero(callStatus) {
                // Copy the revert message into memory.
                returndatacopy(0, 0, returnDataSize)

                // Revert with the same message.
                revert(0, returnDataSize)
            }

            switch returnDataSize
            case 32 {
                // Copy the return data into memory.
                returndatacopy(0, 0, returnDataSize)

                // Set success to whether it returned true.
                success := iszero(iszero(mload(0)))
            }
            case 0 {
                // There was no return data.
                success := 1
            }
            default {
                // It returned some malformed input.
                success := 0
            }
        }
    }
}


// File contracts/Ownable.sol


pragma solidity 0.8.10;

error NotOwner();

abstract contract Ownable {
  address internal _owner;

  event OwnershipTransferred(
    address indexed previousOwner,
    address indexed newOwner
  );

  constructor() {
    _owner = msg.sender;
  }

  function owner() external view returns (address) {
    return _owner;
  }

  function transferOwnership(address _newOwner) external {
    if (msg.sender != _owner) revert NotOwner();

    _owner = _newOwner;
  }

  function renounceOwnership() public {
    if (msg.sender != _owner) revert NotOwner();

    _owner = address(0);
  }
}


// File contracts/IERC721.sol



pragma solidity 0.8.10;

/**
 * @dev Required interface of an ERC721 compliant contract.
 */
interface IERC721 {
  /**
   * @dev Emitted when `tokenId` token is transferred from `from` to `to`.
   */
  event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);

  /**
   * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
   */
  event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);

  /**
   * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
   */
  event ApprovalForAll(address indexed owner, address indexed operator, bool approved);

  /**
   * @dev Returns the number of tokens in ``owner``'s account.
   */
  function balanceOf(address owner) external view returns (uint256 balance);

  /**
   * @dev Returns the owner of the `tokenId` token.
   *
   * Requirements:
   *
   * - `tokenId` must exist.
   */
  function ownerOf(uint256 tokenId) external view returns (address owner);

  /**
   * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
   * are aware of the ERC721 protocol to prevent tokens from being forever locked.
   *
   * Requirements:
   *
   * - `from` cannot be the zero address.
   * - `to` cannot be the zero address.
   * - `tokenId` token must exist and be owned by `from`.
   * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
   * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
   *
   * Emits a {Transfer} event.
   */
  function safeTransferFrom(
    address from,
    address to,
    uint256 tokenId
  ) external;

  /**
   * @dev Transfers `tokenId` token from `from` to `to`.
   *
   * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
   *
   * Requirements:
   *
   * - `from` cannot be the zero address.
   * - `to` cannot be the zero address.
   * - `tokenId` token must be owned by `from`.
   * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
   *
   * Emits a {Transfer} event.
   */
  function transferFrom(
    address from,
    address to,
    uint256 tokenId
  ) external;

  /**
   * @dev Gives permission to `to` to transfer `tokenId` token to another account.
   * The approval is cleared when the token is transferred.
   *
   * Only a single account can be approved at a time, so approving the zero address clears previous approvals.
   *
   * Requirements:
   *
   * - The caller must own the token or be an approved operator.
   * - `tokenId` must exist.
   *
   * Emits an {Approval} event.
   */
  function approve(address to, uint256 tokenId) external;

  /**
   * @dev Returns the account approved for `tokenId` token.
   *
   * Requirements:
   *
   * - `tokenId` must exist.
   */
  function getApproved(uint256 tokenId) external view returns (address operator);

  /**
   * @dev Approve or remove `operator` as an operator for the caller.
   * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
   *
   * Requirements:
   *
   * - The `operator` cannot be the caller.
   *
   * Emits an {ApprovalForAll} event.
   */
  function setApprovalForAll(address operator, bool _approved) external;

  /**
   * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
   *
   * See {setApprovalForAll}
   */
  function isApprovedForAll(address owner, address operator) external view returns (bool);

  /**
   * @dev Safely transfers `tokenId` token from `from` to `to`.
   *
   * Requirements:
   *
   * - `from` cannot be the zero address.
   * - `to` cannot be the zero address.
   * - `tokenId` token must exist and be owned by `from`.
   * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
   * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
   *
   * Emits a {Transfer} event.
   */
  function safeTransferFrom(
    address from,
    address to,
    uint256 tokenId,
    bytes calldata data
  ) external;

  // Original 0xApes contract specifc
  function getPhunksBelongingToOwner(address _owner) external view returns (uint256[] memory);
}


// File contracts/Strings.sol


pragma solidity 0.8.10;

library Strings {
    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        // Inspired by OraclizeAPI's implementation - MIT licence
        // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol

        if (value == 0) {
            return "0";
        }
        uint256 temp = value;
        uint256 digits;
        while (temp != 0) {
            digits++;
            temp /= 10;
        }
        bytes memory buffer = new bytes(digits);
        while (value != 0) {
            digits -= 1;
            buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
            value /= 10;
        }
        return string(buffer);
    }
}


// File contracts/Ape721.sol


pragma solidity 0.8.10;
error DoesNotExist();
error NoTokensLeft();
error NotEnoughETH();
error AssertionError();
error NotTokenOwner();
error MintNotActive();
error MintAlreadyActive();
error MintLimitPerTx();

contract xApe721 is Ownable, ERC721 {
  using Strings for uint256;

  uint256 public constant TOTAL_SUPPLY = 10_000;
  uint256 public constant PRICE_PER_MINT = 0.05 ether;
  uint256 public constant MAX_MINT_PER_TX = 20;

  bool public mintActive;

  uint256 public totalSupply;
  uint256 internal nextMintableId = 10038; // IDs start at 10038

  string public baseURI;

  IERC721 public oldContract = IERC721(0x090b1DE324fEA5f0A0B4226101Db645819102629);
  address private teamWallet = 0x26CDE90abDD4e41ECA2948d79fE383E8103678b5;

  constructor(
    string memory name,
    string memory symbol,
    string memory _baseURI,
    address _oldContract,
    address[] memory recipients,
    uint256[] memory tokens
  ) payable ERC721(name, symbol) {
    require(recipients.length == tokens.length, "Airdrop lengths");
    baseURI = _baseURI;

    if (_oldContract != address(0)) {
      oldContract = IERC721(_oldContract);
    }

    uint256 length = tokens.length;

    for (uint i; i < length; ++i) {
      _mint(recipients[i], tokens[i]);
      totalSupply++;
    }
  }

  modifier onlyTeamWallet() {
    require(msg.sender == teamWallet, "Not callable except by team wallet");
    _;
  }

  function mint(uint16 amount) external payable {
    if (!mintActive) revert MintNotActive();
    if (totalSupply + amount >= TOTAL_SUPPLY) revert NoTokensLeft();
    if (msg.value < amount * PRICE_PER_MINT) revert NotEnoughETH();
    if (amount > MAX_MINT_PER_TX) revert MintLimitPerTx();

    uint256 supply = totalSupply;

    unchecked {
      for (uint16 index = 0; index < amount; index++) {
        uint256 newId = _getNextUnusedID();
        _mint(msg.sender, newId);
        supply++;
      }
    }

    totalSupply = supply;
  }

  function claim(uint256 tokenId) external payable {
    if (_ownsOldToken(msg.sender, tokenId))  {
      // Transfering into this contract effectively burns the old
      // token as there is no way to get it out of here
      oldContract.safeTransferFrom(msg.sender, address(this), tokenId);
      _mint(msg.sender, tokenId);
      totalSupply++;
      return;
    }
    revert NotTokenOwner();
  }

  function claimAll() external payable {
    uint256[] memory ownedTokens = oldContract.getPhunksBelongingToOwner(msg.sender);
    uint256 length = ownedTokens.length; // gas saving

    uint256 supply = totalSupply;

    for (uint256 i; i < length; ++i) {
      if (ownerOf[ownedTokens[i]] == address(0)) {
        // Has not been claimed yet

        // Transfering into this contract effectively burns the
        // old token as there is no way to get it out of here
        oldContract.safeTransferFrom(msg.sender, address(this), ownedTokens[i]);
        _mint(msg.sender, ownedTokens[i]);
        supply++;
      }
    }

    totalSupply = supply;
  }

  function _ownsOldToken(address account, uint256 tokenId) internal view returns(bool) {
    try oldContract.ownerOf(tokenId) returns (address tokenOwner) {
      return account == tokenOwner;
    } catch Error(string memory /*reason*/) {
      return false;
    }
  }

  function _getNextUnusedID() internal returns (uint256) {
    uint256 newId = nextMintableId;

    // Using 10 iterations instead of while loop as it is known
    // that the maximum contiguous group of successive IDs in
    // the original contract is 7 (14960-14966). Cannot have unbounded gas usage
    for (uint256 i; i < 10; ++i) {
      if (ownerOf[newId] != address(0)) {
        // Token is owned in this contract
        newId++;
        continue;
      }

      try oldContract.ownerOf(newId) returns (address) {
        // Token is owned in the old contract
        // ownerOf always reverts if the token isn't owned
        // so no need for zero check here
        newId++;
        continue;
      } catch Error(string memory /*reason*/) {
        nextMintableId = newId + 1;
        return newId;
      }
    }
    revert AssertionError();
  }

  function tokenURI(uint256 id) public view override returns (string memory) {
    if (ownerOf[id] == address(0)) revert DoesNotExist();

    return string(abi.encodePacked(baseURI, id.toString()));
  }

  function withdraw() external onlyTeamWallet() {
    SafeTransferLib.safeTransferETH(teamWallet, address(this).balance);
  }

  function pauseMint() external {
    if (msg.sender != _owner) revert NotOwner();
    if (!mintActive) revert MintNotActive();

    mintActive = false;
  }

  function startMint() external {
    if (msg.sender != _owner) revert NotOwner();
    if (mintActive) revert MintAlreadyActive();

    mintActive = true;
  }

  function setBaseURI(string memory _baseURI) external {
    if (msg.sender != _owner) revert NotOwner();
      baseURI = _baseURI;
  }

  function supportsInterface(bytes4 interfaceId)
    public
    pure
    override
    returns (bool)
  {
    return
      interfaceId == 0x7f5828d0 || // ERC165 Interface ID for ERC173
      interfaceId == 0x80ac58cd || // ERC165 Interface ID for ERC721
      interfaceId == 0x5b5e139f || // ERC165 Interface ID for ERC165
      interfaceId == 0x01ffc9a7 || // ERC165 Interface ID for ERC721Metadata
      interfaceId == 0x150b7a02;   // ERC721 Receiver
  }

  function onERC721Received(
      address operator,
      address from,
      uint256 tokenId,
      bytes calldata data
  ) external returns (bytes4) {
      return 0x150b7a02;
  }
}

Read Contract

MAX_MINT_PER_TX 0x8ecad721 → uint256
PRICE_PER_MINT 0x86b8703b → uint256
TOTAL_SUPPLY 0x902d55a5 → uint256
balanceOf 0x70a08231 → uint256
baseURI 0x6c0360eb → string
getApproved 0x081812fc → address
isApprovedForAll 0xe985e9c5 → bool
mintActive 0x25fd90f3 → bool
name 0x06fdde03 → string
oldContract 0x30503c4e → address
owner 0x8da5cb5b → address
ownerOf 0x6352211e → address
supportsInterface 0x01ffc9a7 → bool
symbol 0x95d89b41 → string
tokenURI 0xc87b56dd → string
totalSupply 0x18160ddd → uint256

Write Contract 15 functions

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

approve 0x095ea7b3
address spender
uint256 id
claim 0x379607f5
uint256 tokenId
claimAll 0xd1058e59
No parameters
mint 0x23cf0a22
uint16 amount
onERC721Received 0x150b7a02
address operator
address from
uint256 tokenId
bytes data
returns: bytes4
pauseMint 0xcd85cdb5
No parameters
renounceOwnership 0x715018a6
No parameters
safeTransferFrom 0x42842e0e
address from
address to
uint256 id
safeTransferFrom 0xb88d4fde
address from
address to
uint256 id
bytes data
setApprovalForAll 0xa22cb465
address operator
bool approved
setBaseURI 0x55f804b3
string _baseURI
startMint 0x2be09561
No parameters
transferFrom 0x23b872dd
address from
address to
uint256 id
transferOwnership 0xf2fde38b
address _newOwner
withdraw 0x3ccfd60b
No parameters

Recent Transactions

No transactions found for this address