Cryo Explorer Ethereum Mainnet

Address Contract Verified

Address 0xB840DB57Afbed2E66F9c01d0c3a4B8fEabaC5b5A
Balance 0 ETH
Nonce 1
Code Size 7740 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

7740 bytes
0x608060405234801561000f575f5ffd5b50600436106100f3575f3560e01c806370a0823111610095578063ca6bffc811610064578063ca6bffc8146102ad578063d56d229d146102c9578063dd62ed3e146102e7578063de0e9a3e14610317576100f3565b806370a082311461021157806395d89b4114610241578063a9059cbb1461025f578063adee8ff21461028f576100f3565b806318160ddd116100d157806318160ddd1461017557806323b872dd14610193578063313ce567146101c357806360c21826146101e1576100f3565b806306fdde03146100f7578063095ea7b314610115578063150b7a0214610145575b5f5ffd5b6100ff610333565b60405161010c9190611348565b60405180910390f35b61012f600480360381019061012a9190611406565b6103c3565b60405161013c919061145e565b60405180910390f35b61015f600480360381019061015a91906114d8565b6103e5565b60405161016c9190611596565b60405180910390f35b61017d6105ab565b60405161018a91906115be565b60405180910390f35b6101ad60048036038101906101a891906115d7565b6105b4565b6040516101ba919061145e565b60405180910390f35b6101cb6105e2565b6040516101d89190611642565b60405180910390f35b6101fb60048036038101906101f6919061165b565b6105ea565b60405161020891906116a3565b60405180910390f35b61022b600480360381019061022691906116bc565b610620565b60405161023891906115be565b60405180910390f35b610249610665565b6040516102569190611348565b60405180910390f35b61027960048036038101906102749190611406565b6106f5565b604051610286919061145e565b60405180910390f35b610297610717565b6040516102a491906115be565b60405180910390f35b6102c760048036038101906102c29190611849565b610723565b005b6102d16108f9565b6040516102de91906118eb565b60405180910390f35b61030160048036038101906102fc9190611904565b61091d565b60405161030e91906115be565b60405180910390f35b610331600480360381019061032c919061165b565b61099f565b005b6060600380546103429061196f565b80601f016020809104026020016040519081016040528092919081815260200182805461036e9061196f565b80156103b95780601f10610390576101008083540402835291602001916103b9565b820191905f5260205f20905b81548152906001019060200180831161039c57829003601f168201915b5050505050905090565b5f5f6103cd610c56565b90506103da818585610c5d565b600191505092915050565b5f7f00000000000000000000000026d85a13212433fe6a8381969c2b0db390a0b0ae73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610474576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161046b906119e9565b60405180910390fd5b600584908060018154018082558091505060019003905f5260205f2090600a91828204019190066003029091909190916101000a81548162ffffff021916908362ffffff1602179055506104d085670de0b6b3a7640000610c6f565b5f600167ffffffffffffffff8111156104ec576104eb6116e7565b5b60405190808252806020026020018201604052801561051a5781602001602082028036833780820191505090505b50905084815f8151811061053157610530611a07565b5b602002602001019062ffffff16908162ffffff16815250508573ffffffffffffffffffffffffffffffffffffffff167fc7c317dcfc50254e4f42a03dd409a67212f3ba55726510e9be451a10619a68ab8260405161058f9190611aeb565b60405180910390a263150b7a0260e01b91505095945050505050565b5f600254905090565b5f5f6105be610c56565b90506105cb858285610cee565b6105d6858585610d81565b60019150509392505050565b5f6012905090565b600581815481106105f9575f80fd5b905f5260205f2090600a9182820401919006600302915054906101000a900462ffffff1681565b5f5f5f8373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20549050919050565b6060600480546106749061196f565b80601f01602080910402602001604051908101604052809291908181526020018280546106a09061196f565b80156106eb5780601f106106c2576101008083540402835291602001916106eb565b820191905f5260205f20905b8154815290600101906020018083116106ce57829003601f168201915b5050505050905090565b5f5f6106ff610c56565b905061070c818585610d81565b600191505092915050565b670de0b6b3a764000081565b5f815111610766576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161075d90611b55565b60405180910390fd5b5f5f90505b8151811015610889577f00000000000000000000000026d85a13212433fe6a8381969c2b0db390a0b0ae73ffffffffffffffffffffffffffffffffffffffff166323b872dd33308585815181106107c5576107c4611a07565b5b60200260200101516040518463ffffffff1660e01b81526004016107eb93929190611bb2565b5f604051808303815f87803b158015610802575f5ffd5b505af1158015610814573d5f5f3e3d5ffd5b50505050600582828151811061082d5761082c611a07565b5b6020026020010151908060018154018082558091505060019003905f5260205f2090600a91828204019190066003029091909190916101000a81548162ffffff021916908362ffffff160217905550808060010191505061076b565b503373ffffffffffffffffffffffffffffffffffffffff167fc7c317dcfc50254e4f42a03dd409a67212f3ba55726510e9be451a10619a68ab826040516108d09190611aeb565b60405180910390a26108f6338251670de0b6b3a76400006108f19190611c14565b610c6f565b50565b7f00000000000000000000000026d85a13212433fe6a8381969c2b0db390a0b0ae81565b5f60015f8473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2054905092915050565b5f81116109e1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109d890611c9f565b60405180910390fd5b670de0b6b3a7640000816109f59190611c14565b6109fe33610620565b1015610a3f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a3690611d07565b60405180910390fd5b610a5c33670de0b6b3a764000083610a579190611c14565b610e71565b5f8167ffffffffffffffff811115610a7757610a766116e7565b5b604051908082528060200260200182016040528015610aa55781602001602082028036833780820191505090505b5090505f5f90505b82811015610c03575f60056001600580549050610aca9190611d25565b81548110610adb57610ada611a07565b5b905f5260205f2090600a91828204019190066003029054906101000a900462ffffff1690506005805480610b1257610b11611d58565b5b600190038181905f5260205f2090600a91828204019190066003026101000a81549062ffffff021916905590557f00000000000000000000000026d85a13212433fe6a8381969c2b0db390a0b0ae73ffffffffffffffffffffffffffffffffffffffff166323b872dd3033846040518463ffffffff1660e01b8152600401610b9c93929190611bb2565b5f604051808303815f87803b158015610bb3575f5ffd5b505af1158015610bc5573d5f5f3e3d5ffd5b5050505080838381518110610bdd57610bdc611a07565b5b602002602001019062ffffff16908162ffffff1681525050508080600101915050610aad565b503373ffffffffffffffffffffffffffffffffffffffff167f51387f5c002c9ef370a71283ce9a7b1790b9e3222e459603a4318299e7a88df182604051610c4a9190611aeb565b60405180910390a25050565b5f33905090565b610c6a8383836001610ef0565b505050565b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610cdf575f6040517fec442f05000000000000000000000000000000000000000000000000000000008152600401610cd69190611d85565b60405180910390fd5b610cea5f83836110bf565b5050565b5f610cf9848461091d565b90507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff811015610d7b5781811015610d6c578281836040517ffb8f41b2000000000000000000000000000000000000000000000000000000008152600401610d6393929190611d9e565b60405180910390fd5b610d7a84848484035f610ef0565b5b50505050565b5f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603610df1575f6040517f96c6fd1e000000000000000000000000000000000000000000000000000000008152600401610de89190611d85565b60405180910390fd5b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610e61575f6040517fec442f05000000000000000000000000000000000000000000000000000000008152600401610e589190611d85565b60405180910390fd5b610e6c8383836110bf565b505050565b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610ee1575f6040517f96c6fd1e000000000000000000000000000000000000000000000000000000008152600401610ed89190611d85565b60405180910390fd5b610eec825f836110bf565b5050565b5f73ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1603610f60575f6040517fe602df05000000000000000000000000000000000000000000000000000000008152600401610f579190611d85565b60405180910390fd5b5f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603610fd0575f6040517f94280d62000000000000000000000000000000000000000000000000000000008152600401610fc79190611d85565b60405180910390fd5b8160015f8673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f208190555080156110b9578273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040516110b091906115be565b60405180910390a35b50505050565b5f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff160361110f578060025f8282546111039190611dd3565b925050819055506111dd565b5f5f5f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2054905081811015611198578381836040517fe450d38c00000000000000000000000000000000000000000000000000000000815260040161118f93929190611d9e565b60405180910390fd5b8181035f5f8673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2081905550505b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603611224578060025f828254039250508190555061126e565b805f5f8473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f82825401925050819055505b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040516112cb91906115be565b60405180910390a3505050565b5f81519050919050565b5f82825260208201905092915050565b8281835e5f83830152505050565b5f601f19601f8301169050919050565b5f61131a826112d8565b61132481856112e2565b93506113348185602086016112f2565b61133d81611300565b840191505092915050565b5f6020820190508181035f8301526113608184611310565b905092915050565b5f604051905090565b5f5ffd5b5f5ffd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6113a282611379565b9050919050565b6113b281611398565b81146113bc575f5ffd5b50565b5f813590506113cd816113a9565b92915050565b5f819050919050565b6113e5816113d3565b81146113ef575f5ffd5b50565b5f81359050611400816113dc565b92915050565b5f5f6040838503121561141c5761141b611371565b5b5f611429858286016113bf565b925050602061143a858286016113f2565b9150509250929050565b5f8115159050919050565b61145881611444565b82525050565b5f6020820190506114715f83018461144f565b92915050565b5f5ffd5b5f5ffd5b5f5ffd5b5f5f83601f84011261149857611497611477565b5b8235905067ffffffffffffffff8111156114b5576114b461147b565b5b6020830191508360018202830111156114d1576114d061147f565b5b9250929050565b5f5f5f5f5f608086880312156114f1576114f0611371565b5b5f6114fe888289016113bf565b955050602061150f888289016113bf565b9450506040611520888289016113f2565b935050606086013567ffffffffffffffff81111561154157611540611375565b5b61154d88828901611483565b92509250509295509295909350565b5f7fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b6115908161155c565b82525050565b5f6020820190506115a95f830184611587565b92915050565b6115b8816113d3565b82525050565b5f6020820190506115d15f8301846115af565b92915050565b5f5f5f606084860312156115ee576115ed611371565b5b5f6115fb868287016113bf565b935050602061160c868287016113bf565b925050604061161d868287016113f2565b9150509250925092565b5f60ff82169050919050565b61163c81611627565b82525050565b5f6020820190506116555f830184611633565b92915050565b5f602082840312156116705761166f611371565b5b5f61167d848285016113f2565b91505092915050565b5f62ffffff82169050919050565b61169d81611686565b82525050565b5f6020820190506116b65f830184611694565b92915050565b5f602082840312156116d1576116d0611371565b5b5f6116de848285016113bf565b91505092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b61171d82611300565b810181811067ffffffffffffffff8211171561173c5761173b6116e7565b5b80604052505050565b5f61174e611368565b905061175a8282611714565b919050565b5f67ffffffffffffffff821115611779576117786116e7565b5b602082029050602081019050919050565b61179381611686565b811461179d575f5ffd5b50565b5f813590506117ae8161178a565b92915050565b5f6117c66117c18461175f565b611745565b905080838252602082019050602084028301858111156117e9576117e861147f565b5b835b8181101561181257806117fe88826117a0565b8452602084019350506020810190506117eb565b5050509392505050565b5f82601f8301126118305761182f611477565b5b81356118408482602086016117b4565b91505092915050565b5f6020828403121561185e5761185d611371565b5b5f82013567ffffffffffffffff81111561187b5761187a611375565b5b6118878482850161181c565b91505092915050565b5f819050919050565b5f6118b36118ae6118a984611379565b611890565b611379565b9050919050565b5f6118c482611899565b9050919050565b5f6118d5826118ba565b9050919050565b6118e5816118cb565b82525050565b5f6020820190506118fe5f8301846118dc565b92915050565b5f5f6040838503121561191a57611919611371565b5b5f611927858286016113bf565b9250506020611938858286016113bf565b9150509250929050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b5f600282049050600182168061198657607f821691505b60208210810361199957611998611942565b5b50919050565b7f4f6e6c7920746172676574204e465400000000000000000000000000000000005f82015250565b5f6119d3600f836112e2565b91506119de8261199f565b602082019050919050565b5f6020820190508181035f830152611a00816119c7565b9050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b5f81519050919050565b5f82825260208201905092915050565b5f819050602082019050919050565b611a6681611686565b82525050565b5f611a778383611a5d565b60208301905092915050565b5f602082019050919050565b5f611a9982611a34565b611aa38185611a3e565b9350611aae83611a4e565b805f5b83811015611ade578151611ac58882611a6c565b9750611ad083611a83565b925050600181019050611ab1565b5085935050505092915050565b5f6020820190508181035f830152611b038184611a8f565b905092915050565b7f4e6f20746f6b656e4964732070726f76696465640000000000000000000000005f82015250565b5f611b3f6014836112e2565b9150611b4a82611b0b565b602082019050919050565b5f6020820190508181035f830152611b6c81611b33565b9050919050565b611b7c81611398565b82525050565b5f611b9c611b97611b9284611686565b611890565b6113d3565b9050919050565b611bac81611b82565b82525050565b5f606082019050611bc55f830186611b73565b611bd26020830185611b73565b611bdf6040830184611ba3565b949350505050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f611c1e826113d3565b9150611c29836113d3565b9250828202611c37816113d3565b91508282048414831517611c4e57611c4d611be7565b5b5092915050565b7f4e6f204e46547320746f20756e777261700000000000000000000000000000005f82015250565b5f611c896011836112e2565b9150611c9482611c55565b602082019050919050565b5f6020820190508181035f830152611cb681611c7d565b9050919050565b7f496e73756666696369656e742062616c616e63650000000000000000000000005f82015250565b5f611cf16014836112e2565b9150611cfc82611cbd565b602082019050919050565b5f6020820190508181035f830152611d1e81611ce5565b9050919050565b5f611d2f826113d3565b9150611d3a836113d3565b9250828203905081811115611d5257611d51611be7565b5b92915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603160045260245ffd5b5f602082019050611d985f830184611b73565b92915050565b5f606082019050611db15f830186611b73565b611dbe60208301856115af565b611dcb60408301846115af565b949350505050565b5f611ddd826113d3565b9150611de8836113d3565b9250828201905080821115611e0057611dff611be7565b5b9291505056fea2646970667358221220157c75518684083f0c1e3daa5862f6f829975f8f04f7fc0102f6d814381c67b264736f6c634300081e0033

Verified Source Code Full Match

Compiler: v0.8.30+commit.73712a01 EVM: prague Optimization: No
draft-IERC6093.sol 161 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/draft-IERC6093.sol)
pragma solidity >=0.8.4;

/**
 * @dev Standard ERC-20 Errors
 * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-20 tokens.
 */
interface IERC20Errors {
    /**
     * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     * @param balance Current balance for the interacting account.
     * @param needed Minimum amount required to perform a transfer.
     */
    error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);

    /**
     * @dev Indicates a failure with the token `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     */
    error ERC20InvalidSender(address sender);

    /**
     * @dev Indicates a failure with the token `receiver`. Used in transfers.
     * @param receiver Address to which tokens are being transferred.
     */
    error ERC20InvalidReceiver(address receiver);

    /**
     * @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers.
     * @param spender Address that may be allowed to operate on tokens without being their owner.
     * @param allowance Amount of tokens a `spender` is allowed to operate with.
     * @param needed Minimum amount required to perform a transfer.
     */
    error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);

    /**
     * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
     * @param approver Address initiating an approval operation.
     */
    error ERC20InvalidApprover(address approver);

    /**
     * @dev Indicates a failure with the `spender` to be approved. Used in approvals.
     * @param spender Address that may be allowed to operate on tokens without being their owner.
     */
    error ERC20InvalidSpender(address spender);
}

/**
 * @dev Standard ERC-721 Errors
 * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-721 tokens.
 */
interface IERC721Errors {
    /**
     * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in ERC-20.
     * Used in balance queries.
     * @param owner Address of the current owner of a token.
     */
    error ERC721InvalidOwner(address owner);

    /**
     * @dev Indicates a `tokenId` whose `owner` is the zero address.
     * @param tokenId Identifier number of a token.
     */
    error ERC721NonexistentToken(uint256 tokenId);

    /**
     * @dev Indicates an error related to the ownership over a particular token. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     * @param tokenId Identifier number of a token.
     * @param owner Address of the current owner of a token.
     */
    error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);

    /**
     * @dev Indicates a failure with the token `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     */
    error ERC721InvalidSender(address sender);

    /**
     * @dev Indicates a failure with the token `receiver`. Used in transfers.
     * @param receiver Address to which tokens are being transferred.
     */
    error ERC721InvalidReceiver(address receiver);

    /**
     * @dev Indicates a failure with the `operator`’s approval. Used in transfers.
     * @param operator Address that may be allowed to operate on tokens without being their owner.
     * @param tokenId Identifier number of a token.
     */
    error ERC721InsufficientApproval(address operator, uint256 tokenId);

    /**
     * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
     * @param approver Address initiating an approval operation.
     */
    error ERC721InvalidApprover(address approver);

    /**
     * @dev Indicates a failure with the `operator` to be approved. Used in approvals.
     * @param operator Address that may be allowed to operate on tokens without being their owner.
     */
    error ERC721InvalidOperator(address operator);
}

/**
 * @dev Standard ERC-1155 Errors
 * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-1155 tokens.
 */
interface IERC1155Errors {
    /**
     * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     * @param balance Current balance for the interacting account.
     * @param needed Minimum amount required to perform a transfer.
     * @param tokenId Identifier number of a token.
     */
    error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);

    /**
     * @dev Indicates a failure with the token `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     */
    error ERC1155InvalidSender(address sender);

    /**
     * @dev Indicates a failure with the token `receiver`. Used in transfers.
     * @param receiver Address to which tokens are being transferred.
     */
    error ERC1155InvalidReceiver(address receiver);

    /**
     * @dev Indicates a failure with the `operator`’s approval. Used in transfers.
     * @param operator Address that may be allowed to operate on tokens without being their owner.
     * @param owner Address of the current owner of a token.
     */
    error ERC1155MissingApprovalForAll(address operator, address owner);

    /**
     * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
     * @param approver Address initiating an approval operation.
     */
    error ERC1155InvalidApprover(address approver);

    /**
     * @dev Indicates a failure with the `operator` to be approved. Used in approvals.
     * @param operator Address that may be allowed to operate on tokens without being their owner.
     */
    error ERC1155InvalidOperator(address operator);

    /**
     * @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.
     * Used in batch transfers.
     * @param idsLength Length of the array of token identifiers
     * @param valuesLength Length of the array of token amounts
     */
    error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);
}
ERC20.sol 305 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC20/ERC20.sol)

pragma solidity ^0.8.20;

import {IERC20} from "./IERC20.sol";
import {IERC20Metadata} from "./extensions/IERC20Metadata.sol";
import {Context} from "../../utils/Context.sol";
import {IERC20Errors} from "../../interfaces/draft-IERC6093.sol";

/**
 * @dev Implementation of the {IERC20} interface.
 *
 * This implementation is agnostic to the way tokens are created. This means
 * that a supply mechanism has to be added in a derived contract using {_mint}.
 *
 * TIP: For a detailed writeup see our guide
 * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
 * to implement supply mechanisms].
 *
 * The default value of {decimals} is 18. To change this, you should override
 * this function so it returns a different value.
 *
 * We have followed general OpenZeppelin Contracts guidelines: functions revert
 * instead returning `false` on failure. This behavior is nonetheless
 * conventional and does not conflict with the expectations of ERC-20
 * applications.
 */
abstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors {
    mapping(address account => uint256) private _balances;

    mapping(address account => mapping(address spender => uint256)) private _allowances;

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;

    /**
     * @dev Sets the values for {name} and {symbol}.
     *
     * Both values are immutable: they can only be set once during construction.
     */
    constructor(string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
    }

    /**
     * @dev Returns the name of the token.
     */
    function name() public view virtual returns (string memory) {
        return _name;
    }

    /**
     * @dev Returns the symbol of the token, usually a shorter version of the
     * name.
     */
    function symbol() public view virtual returns (string memory) {
        return _symbol;
    }

    /**
     * @dev Returns the number of decimals used to get its user representation.
     * For example, if `decimals` equals `2`, a balance of `505` tokens should
     * be displayed to a user as `5.05` (`505 / 10 ** 2`).
     *
     * Tokens usually opt for a value of 18, imitating the relationship between
     * Ether and Wei. This is the default value returned by this function, unless
     * it's overridden.
     *
     * NOTE: This information is only used for _display_ purposes: it in
     * no way affects any of the arithmetic of the contract, including
     * {IERC20-balanceOf} and {IERC20-transfer}.
     */
    function decimals() public view virtual returns (uint8) {
        return 18;
    }

    /// @inheritdoc IERC20
    function totalSupply() public view virtual returns (uint256) {
        return _totalSupply;
    }

    /// @inheritdoc IERC20
    function balanceOf(address account) public view virtual returns (uint256) {
        return _balances[account];
    }

    /**
     * @dev See {IERC20-transfer}.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - the caller must have a balance of at least `value`.
     */
    function transfer(address to, uint256 value) public virtual returns (bool) {
        address owner = _msgSender();
        _transfer(owner, to, value);
        return true;
    }

    /// @inheritdoc IERC20
    function allowance(address owner, address spender) public view virtual returns (uint256) {
        return _allowances[owner][spender];
    }

    /**
     * @dev See {IERC20-approve}.
     *
     * NOTE: If `value` is the maximum `uint256`, the allowance is not updated on
     * `transferFrom`. This is semantically equivalent to an infinite approval.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 value) public virtual returns (bool) {
        address owner = _msgSender();
        _approve(owner, spender, value);
        return true;
    }

    /**
     * @dev See {IERC20-transferFrom}.
     *
     * Skips emitting an {Approval} event indicating an allowance update. This is not
     * required by the ERC. See {xref-ERC20-_approve-address-address-uint256-bool-}[_approve].
     *
     * NOTE: Does not update the allowance if the current allowance
     * is the maximum `uint256`.
     *
     * Requirements:
     *
     * - `from` and `to` cannot be the zero address.
     * - `from` must have a balance of at least `value`.
     * - the caller must have allowance for ``from``'s tokens of at least
     * `value`.
     */
    function transferFrom(address from, address to, uint256 value) public virtual returns (bool) {
        address spender = _msgSender();
        _spendAllowance(from, spender, value);
        _transfer(from, to, value);
        return true;
    }

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to`.
     *
     * This internal function is equivalent to {transfer}, and can be used to
     * e.g. implement automatic token fees, slashing mechanisms, etc.
     *
     * Emits a {Transfer} event.
     *
     * NOTE: This function is not virtual, {_update} should be overridden instead.
     */
    function _transfer(address from, address to, uint256 value) internal {
        if (from == address(0)) {
            revert ERC20InvalidSender(address(0));
        }
        if (to == address(0)) {
            revert ERC20InvalidReceiver(address(0));
        }
        _update(from, to, value);
    }

    /**
     * @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from`
     * (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding
     * this function.
     *
     * Emits a {Transfer} event.
     */
    function _update(address from, address to, uint256 value) internal virtual {
        if (from == address(0)) {
            // Overflow check required: The rest of the code assumes that totalSupply never overflows
            _totalSupply += value;
        } else {
            uint256 fromBalance = _balances[from];
            if (fromBalance < value) {
                revert ERC20InsufficientBalance(from, fromBalance, value);
            }
            unchecked {
                // Overflow not possible: value <= fromBalance <= totalSupply.
                _balances[from] = fromBalance - value;
            }
        }

        if (to == address(0)) {
            unchecked {
                // Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply.
                _totalSupply -= value;
            }
        } else {
            unchecked {
                // Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256.
                _balances[to] += value;
            }
        }

        emit Transfer(from, to, value);
    }

    /**
     * @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0).
     * Relies on the `_update` mechanism
     *
     * Emits a {Transfer} event with `from` set to the zero address.
     *
     * NOTE: This function is not virtual, {_update} should be overridden instead.
     */
    function _mint(address account, uint256 value) internal {
        if (account == address(0)) {
            revert ERC20InvalidReceiver(address(0));
        }
        _update(address(0), account, value);
    }

    /**
     * @dev Destroys a `value` amount of tokens from `account`, lowering the total supply.
     * Relies on the `_update` mechanism.
     *
     * Emits a {Transfer} event with `to` set to the zero address.
     *
     * NOTE: This function is not virtual, {_update} should be overridden instead
     */
    function _burn(address account, uint256 value) internal {
        if (account == address(0)) {
            revert ERC20InvalidSender(address(0));
        }
        _update(account, address(0), value);
    }

    /**
     * @dev Sets `value` as the allowance of `spender` over the `owner`'s tokens.
     *
     * This internal function is equivalent to `approve`, and can be used to
     * e.g. set automatic allowances for certain subsystems, etc.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `owner` cannot be the zero address.
     * - `spender` cannot be the zero address.
     *
     * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.
     */
    function _approve(address owner, address spender, uint256 value) internal {
        _approve(owner, spender, value, true);
    }

    /**
     * @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event.
     *
     * By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by
     * `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any
     * `Approval` event during `transferFrom` operations.
     *
     * Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to
     * true using the following override:
     *
     * ```solidity
     * function _approve(address owner, address spender, uint256 value, bool) internal virtual override {
     *     super._approve(owner, spender, value, true);
     * }
     * ```
     *
     * Requirements are the same as {_approve}.
     */
    function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual {
        if (owner == address(0)) {
            revert ERC20InvalidApprover(address(0));
        }
        if (spender == address(0)) {
            revert ERC20InvalidSpender(address(0));
        }
        _allowances[owner][spender] = value;
        if (emitEvent) {
            emit Approval(owner, spender, value);
        }
    }

    /**
     * @dev Updates `owner`'s allowance for `spender` based on spent `value`.
     *
     * Does not update the allowance value in case of infinite allowance.
     * Revert if not enough allowance is available.
     *
     * Does not emit an {Approval} event.
     */
    function _spendAllowance(address owner, address spender, uint256 value) internal virtual {
        uint256 currentAllowance = allowance(owner, spender);
        if (currentAllowance < type(uint256).max) {
            if (currentAllowance < value) {
                revert ERC20InsufficientAllowance(spender, currentAllowance, value);
            }
            unchecked {
                _approve(owner, spender, currentAllowance - value, false);
            }
        }
    }
}
IERC20.sol 79 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC-20 standard as defined in the ERC.
 */
interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);

    /**
     * @dev Returns the value of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the value of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves a `value` amount of tokens from the caller's account to `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, uint256 value) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the
     * caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the
     * allowance mechanism. `value` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address from, address to, uint256 value) external returns (bool);
}
IERC20Metadata.sol 26 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity >=0.6.2;

import {IERC20} from "../IERC20.sol";

/**
 * @dev Interface for the optional metadata functions from the ERC-20 standard.
 */
interface IERC20Metadata is IERC20 {
    /**
     * @dev Returns the name of the token.
     */
    function name() external view returns (string memory);

    /**
     * @dev Returns the symbol of the token.
     */
    function symbol() external view returns (string memory);

    /**
     * @dev Returns the decimals places of the token.
     */
    function decimals() external view returns (uint8);
}
IERC721.sol 135 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC721/IERC721.sol)

pragma solidity >=0.6.2;

import {IERC165} from "../../utils/introspection/IERC165.sol";

/**
 * @dev Required interface of an ERC-721 compliant contract.
 */
interface IERC721 is IERC165 {
    /**
     * @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`.
     *
     * 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;

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the ERC-721 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 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: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC-721
     * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
     * understand this adds an external call which potentially creates a reentrancy vulnerability.
     *
     * 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 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 address zero.
     *
     * Emits an {ApprovalForAll} event.
     */
    function setApprovalForAll(address operator, bool approved) external;

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

    /**
     * @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);
}
IERC721Receiver.sol 28 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC721/IERC721Receiver.sol)

pragma solidity >=0.5.0;

/**
 * @title ERC-721 token receiver interface
 * @dev Interface for any contract that wants to support safeTransfers
 * from ERC-721 asset contracts.
 */
interface IERC721Receiver {
    /**
     * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
     * by `operator` from `from`, this function is called.
     *
     * It must return its Solidity selector to confirm the token transfer.
     * If any other value is returned or the interface is not implemented by the recipient, the transfer will be
     * reverted.
     *
     * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.
     */
    function onERC721Received(
        address operator,
        address from,
        uint256 tokenId,
        bytes calldata data
    ) external returns (bytes4);
}
Context.sol 28 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)

pragma solidity ^0.8.20;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }

    function _contextSuffixLength() internal view virtual returns (uint256) {
        return 0;
    }
}
IERC165.sol 25 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (utils/introspection/IERC165.sol)

pragma solidity >=0.4.16;

/**
 * @dev Interface of the ERC-165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[ERC].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
PathSwap.sol 64 lines
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0 <0.9.0;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";

contract WrappedTenYearsOfEthereum is ERC20, IERC721Receiver {
    IERC721 public immutable nftContract = IERC721(0x26D85A13212433Fe6A8381969c2B0dB390a0B0ae);
    uint256 public constant TOKENS_PER_NFT = 1e18;

    uint24[] public wrappedTokenIds;

    event NFTWrapped(address indexed user, uint24[] tokenIds);
    event NFTUnwrapped(address indexed user, uint24[] tokenIds);

    constructor() ERC20("Wrapped Ten Years of Ethereum", "W10YETH") {}

    function wrap(uint24[] memory tokenIds) external {
        require(tokenIds.length > 0, "No tokenIds provided");

        for (uint256 i = 0; i < tokenIds.length; i++) {
            nftContract.transferFrom(msg.sender, address(this), tokenIds[i]);
            wrappedTokenIds.push(tokenIds[i]);
        }

        emit NFTWrapped(msg.sender, tokenIds);
        _mint(msg.sender, TOKENS_PER_NFT * tokenIds.length);
    }

    function unwrap(uint256 nftCount) external {
        require(nftCount > 0, "No NFTs to unwrap");
        require(balanceOf(msg.sender) >= nftCount * TOKENS_PER_NFT, "Insufficient balance");

        _burn(msg.sender, nftCount * TOKENS_PER_NFT);
        uint24[] memory tokenIds = new uint24[](nftCount);

        for (uint256 i = 0; i < nftCount; i++) {
            uint24 tokenId = wrappedTokenIds[wrappedTokenIds.length - 1];
            wrappedTokenIds.pop();
            nftContract.transferFrom(address(this), msg.sender, tokenId);
            tokenIds[i] = tokenId;
        }

        emit NFTUnwrapped(msg.sender, tokenIds);
    }

    function onERC721Received(
        address /*  operator  */,
        address from,
        uint256 tokenId,
        bytes calldata /* data */
    ) external override returns (bytes4) {
        require(msg.sender == address(nftContract), "Only target NFT");

        wrappedTokenIds.push(uint24(tokenId));
        _mint(from, TOKENS_PER_NFT);
        uint24[] memory tokenIds = new uint24[](1);
        tokenIds[0] = uint24(tokenId);

        emit NFTWrapped(from, tokenIds);
        return IERC721Receiver.onERC721Received.selector;
    }
}

Read Contract

TOKENS_PER_NFT 0xadee8ff2 → uint256
allowance 0xdd62ed3e → uint256
balanceOf 0x70a08231 → uint256
decimals 0x313ce567 → uint8
name 0x06fdde03 → string
nftContract 0xd56d229d → address
symbol 0x95d89b41 → string
totalSupply 0x18160ddd → uint256
wrappedTokenIds 0x60c21826 → uint24

Write Contract 6 functions

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

approve 0x095ea7b3
address spender
uint256 value
returns: bool
onERC721Received 0x150b7a02
address
address from
uint256 tokenId
bytes
returns: bytes4
transfer 0xa9059cbb
address to
uint256 value
returns: bool
transferFrom 0x23b872dd
address from
address to
uint256 value
returns: bool
unwrap 0xde0e9a3e
uint256 nftCount
wrap 0xca6bffc8
uint24[] tokenIds

Recent Transactions

No transactions found for this address