Cryo Explorer Ethereum Mainnet

Address Contract Verified

Address 0x4A116CA93Df31FBa5213BAd8bc198bB4387B029E
Balance 0 ETH
Nonce 1
Code Size 7760 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

7760 bytes
0x608060405234801561001057600080fd5b506004361061016c5760003560e01c806392f2ff80116100cd578063cd24b0a311610081578063f23a6e6111610066578063f23a6e61146103ba578063f2fde38b146103f2578063fe4693a31461040557600080fd5b8063cd24b0a3146103aa578063efff997c146103b257600080fd5b8063a8086755116100b2578063a8086755146102e0578063bc197c81146102f5578063c89109131461032d57600080fd5b806392f2ff80146102ab578063a591efde146102cb57600080fd5b8063502c9bd511610124578063715018a611610109578063715018a614610272578063859610c61461027a5780638da5cb5b1461028d57600080fd5b8063502c9bd51461024c5780635d36598f1461025f57600080fd5b806316b3d1711161015557806316b3d171146101dd57806331b6e245146102225780634e71d92d1461024257600080fd5b806301ffc9a714610171578063150b7a0214610199575b600080fd5b61018461017f366004611636565b61040d565b60405190151581526020015b60405180910390f35b6101ac6101a73660046117b4565b6104a6565b6040517fffffffff000000000000000000000000000000000000000000000000000000009091168152602001610190565b6004546101fd9073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610190565b6003546101fd9073ffffffffffffffffffffffffffffffffffffffff1681565b61024a6104d0565b005b6101fd61025a36600461181c565b610d63565b61024a61026d366004611835565b610d9a565b61024a610f68565b61024a610288366004611835565b610f7c565b60005473ffffffffffffffffffffffffffffffffffffffff166101fd565b6102be6102b93660046118aa565b611132565b60405161019091906118c5565b6102d36111ae565b6040516101909190611909565b6102e861121d565b6040516101909190611957565b6101ac610303366004611a44565b7fbc197c810000000000000000000000000000000000000000000000000000000095945050505050565b61037f61033b3660046118aa565b60026020526000908152604090205467ffffffffffffffff808216916801000000000000000081048216917001000000000000000000000000000000009091041683565b6040805167ffffffffffffffff94851681529284166020840152921691810191909152606001610190565b61024a6112ab565b6102e8611401565b6101ac6103c8366004611aee565b7ff23a6e610000000000000000000000000000000000000000000000000000000095945050505050565b61024a6104003660046118aa565b61140e565b6102e8611472565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f4e2312e00000000000000000000000000000000000000000000000000000000014806104a057507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b92915050565b7f150b7a02000000000000000000000000000000000000000000000000000000005b949350505050565b60035460045473ffffffffffffffffffffffffffffffffffffffff918216911660008262fdd58e336040517fffffffff0000000000000000000000000000000000000000000000000000000060e084901b16815273ffffffffffffffffffffffffffffffffffffffff909116600482015260016024820152604401602060405180830381865afa158015610568573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061058c9190611b53565b9050600073ffffffffffffffffffffffffffffffffffffffff841662fdd58e336040517fffffffff0000000000000000000000000000000000000000000000000000000060e084901b16815273ffffffffffffffffffffffffffffffffffffffff909116600482015260026024820152604401602060405180830381865afa15801561061c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106409190611b53565b9050600073ffffffffffffffffffffffffffffffffffffffff851662fdd58e336040517fffffffff0000000000000000000000000000000000000000000000000000000060e084901b16815273ffffffffffffffffffffffffffffffffffffffff909116600482015260036024820152604401602060405180830381865afa1580156106d0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106f49190611b53565b905067ffffffffffffffff8316158015610716575067ffffffffffffffff8216155b801561072a575067ffffffffffffffff8116155b15610796576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f596f7520646f206e6f74206861766520616e792047656e65736973204e46540060448201526064015b60405180910390fd5b6001805480820182557fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf60180547fffffffffffffffffffffffff00000000000000000000000000000000000000001633908117909155600090815260026020526040902090810167ffffffffffffffff8516156109ab576040517ff242432a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff88169063f242432a9061086690339030906001908b90600401611b6c565b600060405180830381600087803b15801561088057600080fd5b505af1158015610894573d6000803e3d6000fd5b505083548792508491506000906108b690849067ffffffffffffffff16611c1e565b92506101000a81548167ffffffffffffffff021916908367ffffffffffffffff16021790555060005b8567ffffffffffffffff168110156109a9576040517fc772745a000000000000000000000000000000000000000000000000000000008152829073ffffffffffffffffffffffffffffffffffffffff89169063c772745a9061094b903090600590600190600401611c99565b6020604051808303816000875af115801561096a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061098e9190611b53565b815460018181018455600093845260209093200155016108df565b505b67ffffffffffffffff841615610b65576040517ff242432a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff88169063f242432a90610a1490339030906002908a90600401611b6c565b600060405180830381600087803b158015610a2e57600080fd5b505af1158015610a42573d6000803e3d6000fd5b50508354869250849150600890610a7090849068010000000000000000900467ffffffffffffffff16611c1e565b92506101000a81548167ffffffffffffffff021916908367ffffffffffffffff16021790555060005b8467ffffffffffffffff16811015610b63576040517fc772745a000000000000000000000000000000000000000000000000000000008152829073ffffffffffffffffffffffffffffffffffffffff89169063c772745a90610b05903090600690600290600401611c99565b6020604051808303816000875af1158015610b24573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b489190611b53565b81546001818101845560009384526020909320015501610a99565b505b67ffffffffffffffff831615610d27576040517ff242432a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff88169063f242432a90610bce90339030906003908990600401611b6c565b600060405180830381600087803b158015610be857600080fd5b505af1158015610bfc573d6000803e3d6000fd5b50508354859250849150601090610c32908490700100000000000000000000000000000000900467ffffffffffffffff16611c1e565b92506101000a81548167ffffffffffffffff021916908367ffffffffffffffff16021790555060005b8367ffffffffffffffff16811015610d25576040517fc772745a000000000000000000000000000000000000000000000000000000008152829073ffffffffffffffffffffffffffffffffffffffff89169063c772745a90610cc7903090600790600390600401611c99565b6020604051808303816000875af1158015610ce6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d0a9190611b53565b81546001818101845560009384526020909320015501610c5b565b505b6040805133815290517f0c7ef932d3b91976772937f18d5ef9b39a9930bef486b576c374f047c4b512dc9181900360200190a150505050505050565b60018181548110610d7357600080fd5b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff16905081565b60045433600090815260026020526040812073ffffffffffffffffffffffffffffffffffffffff90921691600101905b83811015610f1657610df482868684818110610de857610de8611da9565b9050602002013561147f565b610e4657848482818110610e0a57610e0a611da9565b905060200201356040517f4b7185b000000000000000000000000000000000000000000000000000000000815260040161078d91815260200190565b73ffffffffffffffffffffffffffffffffffffffff83166323b872dd3033888886818110610e7657610e76611da9565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e088901b16815273ffffffffffffffffffffffffffffffffffffffff958616600482015294909316602485015250602090910201356044820152606401600060405180830381600087803b158015610ef257600080fd5b505af1158015610f06573d6000803e3d6000fd5b505060019092019150610dca9050565b507f0be774851955c26a1d6a32b13b020663a069006b4a3b643ff0b809d318260572335b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390a150505050565b610f7061153c565b610f7a600061158f565b565b6004546001805480820182557fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf60180547fffffffffffffffffffffffff00000000000000000000000000000000000000001633908117909155600090815260026020526040812073ffffffffffffffffffffffffffffffffffffffff90931692909101905b8381101561110a5773ffffffffffffffffffffffffffffffffffffffff83166323b872dd333088888681811061103957611039611da9565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e088901b16815273ffffffffffffffffffffffffffffffffffffffff958616600482015294909316602485015250602090910201356044820152606401600060405180830381600087803b1580156110b557600080fd5b505af11580156110c9573d6000803e3d6000fd5b50505050818585838181106110e0576110e0611da9565b83546001808201865560009586526020958690209290950293909301359201919091555001611001565b507fc1b5f12cea7c200ad495a43bf2d4c7ba1a753343c06c339093937849de84d91333610f3a565b73ffffffffffffffffffffffffffffffffffffffff81166000908152600260209081526040918290206001018054835181840281018401909452808452606093928301828280156111a257602002820191906000526020600020905b81548152602001906001019080831161118e575b50505050509050919050565b6060600180548060200260200160405190810160405280929190818152602001828054801561121357602002820191906000526020600020905b815473ffffffffffffffffffffffffffffffffffffffff1681526001909101906020018083116111e8575b5050505050905090565b6007805461122a90611c46565b80601f016020809104026020016040519081016040528092919081815260200182805461125690611c46565b80156112a35780601f10611278576101008083540402835291602001916112a3565b820191906000526020600020905b81548152906001019060200180831161128657829003601f168201915b505050505081565b60045433600090815260026020526040812073ffffffffffffffffffffffffffffffffffffffff909216919060018201905b81548110156113ba5773ffffffffffffffffffffffffffffffffffffffff84166323b872dd303385858154811061131657611316611da9565b6000918252602090912001546040517fffffffff0000000000000000000000000000000000000000000000000000000060e086901b16815273ffffffffffffffffffffffffffffffffffffffff93841660048201529290911660248301526044820152606401600060405180830381600087803b15801561139657600080fd5b505af11580156113aa573d6000803e3d6000fd5b5050600190920191506112dd9050565b506113c9600183016000611604565b6040805133815290517f249e0abcb070308b2b7f50ef13b8d729533680427eedeb4438f1e5fc09bcad8e9181900360200190a1505050565b6005805461122a90611c46565b61141661153c565b73ffffffffffffffffffffffffffffffffffffffff8116611466576040517f1e4fbdf70000000000000000000000000000000000000000000000000000000081526000600482015260240161078d565b61146f8161158f565b50565b6006805461122a90611c46565b8154600090815b8181101561153157838582815481106114a1576114a1611da9565b90600052602060002001540361152957846114bd600184611dd8565b815481106114cd576114cd611da9565b90600052602060002001548582815481106114ea576114ea611da9565b90600052602060002001819055508480548061150857611508611deb565b600190038181906000526020600020016000905590556001925050506104a0565b600101611486565b506000949350505050565b60005473ffffffffffffffffffffffffffffffffffffffff163314610f7a576040517f118cdaa700000000000000000000000000000000000000000000000000000000815233600482015260240161078d565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b508054600082559060005260206000209081019061146f91905b80821115611632576000815560010161161e565b5090565b60006020828403121561164857600080fd5b81357fffffffff000000000000000000000000000000000000000000000000000000008116811461167857600080fd5b9392505050565b803573ffffffffffffffffffffffffffffffffffffffff811681146116a357600080fd5b919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff8111828210171561171e5761171e6116a8565b604052919050565b600082601f83011261173757600080fd5b813567ffffffffffffffff811115611751576117516116a8565b61178260207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116016116d7565b81815284602083860101111561179757600080fd5b816020850160208301376000918101602001919091529392505050565b600080600080608085870312156117ca57600080fd5b6117d38561167f565b93506117e16020860161167f565b925060408501359150606085013567ffffffffffffffff81111561180457600080fd5b61181087828801611726565b91505092959194509250565b60006020828403121561182e57600080fd5b5035919050565b6000806020838503121561184857600080fd5b823567ffffffffffffffff8082111561186057600080fd5b818501915085601f83011261187457600080fd5b81358181111561188357600080fd5b8660208260051b850101111561189857600080fd5b60209290920196919550909350505050565b6000602082840312156118bc57600080fd5b6116788261167f565b6020808252825182820181905260009190848201906040850190845b818110156118fd578351835292840192918401916001016118e1565b50909695505050505050565b6020808252825182820181905260009190848201906040850190845b818110156118fd57835173ffffffffffffffffffffffffffffffffffffffff1683529284019291840191600101611925565b60006020808352835180602085015260005b8181101561198557858101830151858201604001528201611969565b5060006040828601015260407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8301168501019250505092915050565b600082601f8301126119d557600080fd5b8135602067ffffffffffffffff8211156119f1576119f16116a8565b8160051b611a008282016116d7565b9283528481018201928281019087851115611a1a57600080fd5b83870192505b84831015611a3957823582529183019190830190611a20565b979650505050505050565b600080600080600060a08688031215611a5c57600080fd5b611a658661167f565b9450611a736020870161167f565b9350604086013567ffffffffffffffff80821115611a9057600080fd5b611a9c89838a016119c4565b94506060880135915080821115611ab257600080fd5b611abe89838a016119c4565b93506080880135915080821115611ad457600080fd5b50611ae188828901611726565b9150509295509295909350565b600080600080600060a08688031215611b0657600080fd5b611b0f8661167f565b9450611b1d6020870161167f565b93506040860135925060608601359150608086013567ffffffffffffffff811115611b4757600080fd5b611ae188828901611726565b600060208284031215611b6557600080fd5b5051919050565b600073ffffffffffffffffffffffffffffffffffffffff808716835280861660208401525083604083015267ffffffffffffffff8316606083015260a06080830152611be560a08301600381527f3078300000000000000000000000000000000000000000000000000000000000602082015260400190565b9695505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b67ffffffffffffffff818116838216019080821115611c3f57611c3f611bef565b5092915050565b600181811c90821680611c5a57607f821691505b602082108103611c93577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b73ffffffffffffffffffffffffffffffffffffffff841681526000602060606020840152600085548160018260011c91506001831680611cda57607f831692505b602083108103611d11577f4e487b710000000000000000000000000000000000000000000000000000000085526022600452602485fd5b6060880183905260808801818015611d305760018114611d6457611d8f565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff008616825284151560051b82019650611d8f565b60008c81526020902060005b86811015611d8957815484820152908501908901611d70565b83019750505b50505061ffff88166040880152509193506104c892505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b818103818111156104a0576104a0611bef565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fdfea264697066735822122058cf2292b7450726e94640a15ff9b77ec355a4fbd0c7546fc4fd5e180ab245cc64736f6c63430008180033

Verified Source Code Full Match

Compiler: v0.8.24+commit.e11b9ed9 EVM: paris Optimization: Yes (1000000 runs)
GenesisNftTypes.sol 12 lines
// SPDX-License-Identifier: MIT

pragma solidity 0.8.24;

library GenesisNftTypes {

    uint16 public constant UNKNOWN = 0;
    uint16 public constant SILVER = 1;
    uint16 public constant GOLD = 2;
    uint16 public constant BLACK_GOLD = 3;

}
GenesisClaim.sol 161 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.24;

import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {IERC1155} from "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
import {ERC721Holder} from "@openzeppelin/contracts/token/ERC721/utils/ERC721Holder.sol";
import {ERC1155Holder} from "@openzeppelin/contracts/token/ERC1155/utils/ERC1155Holder.sol";
import {IGenesisERC721} from "./IGenesisERC721.sol";
import {GenesisNftTypes} from "../lib/GenesisNftTypes.sol";

contract GenesisClaim is Ownable, ERC721Holder, ERC1155Holder {

    struct UserData {
        uint64 silverNftAmount;
        uint64 goldNftAmount;
        uint64 blackGoldNftAmount;
        uint[] nftIds;
    }

    address[] public userAddresses;
    mapping(address => UserData) public userData;

    address public genesisERC1155Address;
    address public genesisERC721Address;

    string public silverNftUri;
    string public goldNftUri;
    string public blackGoldNftUri;

    constructor(address genesisERC1155Address_, address genesisERC721Address_, string memory silverNftUri_, string memory goldNftUri_, string memory blackGoldNftUri_) Ownable(_msgSender()) {
        genesisERC1155Address = genesisERC1155Address_;
        genesisERC721Address = genesisERC721Address_;

        silverNftUri = silverNftUri_;
        goldNftUri = goldNftUri_;
        blackGoldNftUri = blackGoldNftUri_;
    }

    function getUserAddresses()
    public view returns (address[] memory) {
        return userAddresses;
    }

    function getUserNftIds(address userAddress)
    public view returns (uint[] memory) {
        return userData[userAddress].nftIds;
    }

    function claim()
    public {
        IERC1155 genesisERC1155 = IERC1155(genesisERC1155Address);
        IGenesisERC721 genesisERC721 = IGenesisERC721(genesisERC721Address);

        uint64 silverNftAmount = uint64(genesisERC1155.balanceOf(_msgSender(), GenesisNftTypes.SILVER));
        uint64 goldNftAmount = uint64(genesisERC1155.balanceOf(_msgSender(), GenesisNftTypes.GOLD));
        uint64 blackGoldNftAmount = uint64(genesisERC1155.balanceOf(_msgSender(), GenesisNftTypes.BLACK_GOLD));

        if (silverNftAmount == 0 && goldNftAmount == 0 && blackGoldNftAmount == 0) {
            revert("You do not have any Genesis NFT");
        }

        userAddresses.push(_msgSender());

        UserData storage data = userData[_msgSender()];
        uint[] storage userNftIds = data.nftIds;

        if (silverNftAmount > 0) {
            genesisERC1155.safeTransferFrom(_msgSender(), address(this), 1, silverNftAmount, "0x0");
            data.silverNftAmount += silverNftAmount;

            for (uint i; i < silverNftAmount; i++) {
                userNftIds.push(genesisERC721.safeMint(address(this), silverNftUri, GenesisNftTypes.SILVER));
            }
        }
        if (goldNftAmount > 0) {
            genesisERC1155.safeTransferFrom(_msgSender(), address(this), 2, goldNftAmount, "0x0");
            data.goldNftAmount += goldNftAmount;

            for (uint i; i < goldNftAmount; i++) {
                userNftIds.push(genesisERC721.safeMint(address(this), goldNftUri, GenesisNftTypes.GOLD));
            }
        }
        if (blackGoldNftAmount > 0) {
            genesisERC1155.safeTransferFrom(_msgSender(), address(this), 3, blackGoldNftAmount, "0x0");
            data.blackGoldNftAmount += blackGoldNftAmount;

            for (uint i; i < blackGoldNftAmount; i++) {
                userNftIds.push(genesisERC721.safeMint(address(this), blackGoldNftUri, GenesisNftTypes.BLACK_GOLD));
            }
        }

        emit Claim(_msgSender());
    }

    function lock(uint[] calldata nftIds)
    public {
        IGenesisERC721 genesisERC721 = IGenesisERC721(genesisERC721Address);

        userAddresses.push(_msgSender());
        uint[] storage userNftIds = userData[_msgSender()].nftIds;
        for (uint i; i < nftIds.length; i++) {
            genesisERC721.transferFrom(_msgSender(), address(this), nftIds[i]);
            userNftIds.push(nftIds[i]);
        }

        emit Lock(_msgSender());
    }

    function unlock(uint[] calldata nftIds)
    public {
        IGenesisERC721 genesisERC721 = IGenesisERC721(genesisERC721Address);

        uint[] storage userNftIds = userData[_msgSender()].nftIds;
        for (uint i; i < nftIds.length; i++) {
            if (!_removeFromArray(userNftIds, nftIds[i])) {
                revert NftNotFound(nftIds[i]);
            }
            genesisERC721.transferFrom(address(this), _msgSender(), nftIds[i]);
        }

        emit Unlock(_msgSender());
    }

    function unlockAll()
    public {
        IGenesisERC721 genesisERC721 = IGenesisERC721(genesisERC721Address);

        UserData storage data = userData[_msgSender()];
        uint[] storage userNftIds = data.nftIds;
        for (uint i; i < userNftIds.length; i++) {
            genesisERC721.transferFrom(address(this), _msgSender(), userNftIds[i]);
        }
        delete data.nftIds;

        emit UnlockAll(_msgSender());
    }

    function _removeFromArray(uint[] storage arr, uint val)
    internal returns (bool) {
        uint arrLength = arr.length;
        for (uint i = 0; i < arrLength; i++) {
            if (arr[i] == val) {
                arr[i] = arr[arrLength - 1];
                arr.pop();
                return true;
            }
        }
        return false;
    }

    error NftNotFound(uint nftId);

    event Claim(address userAddress);

    event Lock(address userAddress);

    event Unlock(address userAddress);

    event UnlockAll(address userAddress);

}
IGenesisERC721.sol 11 lines
// SPDX-License-Identifier: MIT

pragma solidity 0.8.24;

import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol";

interface IGenesisERC721 is IERC721 {

    function safeMint(address to, string calldata uri, uint tokenType) external returns (uint);

}
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;
    }
}
Ownable.sol 100 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)

pragma solidity ^0.8.20;

import {Context} from "../utils/Context.sol";

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * The initial owner is set to the address provided by the deployer. This can
 * later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

    /**
     * @dev The caller account is not authorized to perform an operation.
     */
    error OwnableUnauthorizedAccount(address account);

    /**
     * @dev The owner is not a valid owner account. (eg. `address(0)`)
     */
    error OwnableInvalidOwner(address owner);

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

    /**
     * @dev Initializes the contract setting the address provided by the deployer as the initial owner.
     */
    constructor(address initialOwner) {
        if (initialOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(initialOwner);
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        if (owner() != _msgSender()) {
            revert OwnableUnauthorizedAccount(_msgSender());
        }
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby disabling any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        if (newOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}
IERC721.sol 135 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721.sol)

pragma solidity ^0.8.20;

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

/**
 * @dev Required interface of an ERC721 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 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 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 ERC721
     * 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);
}
IERC1155.sol 127 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (token/ERC1155/IERC1155.sol)

pragma solidity ^0.8.20;

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

/**
 * @dev Required interface of an ERC1155 compliant contract, as defined in the
 * https://eips.ethereum.org/EIPS/eip-1155[EIP].
 */
interface IERC1155 is IERC165 {
    /**
     * @dev Emitted when `value` amount of tokens of type `id` are transferred from `from` to `to` by `operator`.
     */
    event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);

    /**
     * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all
     * transfers.
     */
    event TransferBatch(
        address indexed operator,
        address indexed from,
        address indexed to,
        uint256[] ids,
        uint256[] values
    );

    /**
     * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to
     * `approved`.
     */
    event ApprovalForAll(address indexed account, address indexed operator, bool approved);

    /**
     * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.
     *
     * If an {URI} event was emitted for `id`, the standard
     * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value
     * returned by {IERC1155MetadataURI-uri}.
     */
    event URI(string value, uint256 indexed id);

    /**
     * @dev Returns the value of tokens of token type `id` owned by `account`.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     */
    function balanceOf(address account, uint256 id) external view returns (uint256);

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.
     *
     * Requirements:
     *
     * - `accounts` and `ids` must have the same length.
     */
    function balanceOfBatch(
        address[] calldata accounts,
        uint256[] calldata ids
    ) external view returns (uint256[] memory);

    /**
     * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,
     *
     * Emits an {ApprovalForAll} event.
     *
     * Requirements:
     *
     * - `operator` cannot be the caller.
     */
    function setApprovalForAll(address operator, bool approved) external;

    /**
     * @dev Returns true if `operator` is approved to transfer ``account``'s tokens.
     *
     * See {setApprovalForAll}.
     */
    function isApprovedForAll(address account, address operator) external view returns (bool);

    /**
     * @dev Transfers a `value` amount of tokens of type `id` from `from` to `to`.
     *
     * WARNING: This function can potentially allow a reentrancy attack when transferring tokens
     * to an untrusted contract, when invoking {onERC1155Received} on the receiver.
     * Ensure to follow the checks-effects-interactions pattern and consider employing
     * reentrancy guards when interacting with untrusted contracts.
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}.
     * - `from` must have a balance of tokens of type `id` of at least `value` amount.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
     * acceptance magic value.
     */
    function safeTransferFrom(address from, address to, uint256 id, uint256 value, bytes calldata data) external;

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
     *
     * WARNING: This function can potentially allow a reentrancy attack when transferring tokens
     * to an untrusted contract, when invoking {onERC1155BatchReceived} on the receiver.
     * Ensure to follow the checks-effects-interactions pattern and consider employing
     * reentrancy guards when interacting with untrusted contracts.
     *
     * Emits either a {TransferSingle} or a {TransferBatch} event, depending on the length of the array arguments.
     *
     * Requirements:
     *
     * - `ids` and `values` must have the same length.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
     * acceptance magic value.
     */
    function safeBatchTransferFrom(
        address from,
        address to,
        uint256[] calldata ids,
        uint256[] calldata values,
        bytes calldata data
    ) external;
}
ERC165.sol 27 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)

pragma solidity ^0.8.20;

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

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
 * for the additional interface id that will be supported. For example:
 *
 * ```solidity
 * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
 *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
 * }
 * ```
 */
abstract contract ERC165 is IERC165 {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}
IERC165.sol 25 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * 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[EIP 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);
}
IERC721Receiver.sol 28 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721Receiver.sol)

pragma solidity ^0.8.20;

/**
 * @title ERC721 token receiver interface
 * @dev Interface for any contract that wants to support safeTransfers
 * from ERC721 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);
}
IERC1155Receiver.sol 59 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC1155/IERC1155Receiver.sol)

pragma solidity ^0.8.20;

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

/**
 * @dev Interface that must be implemented by smart contracts in order to receive
 * ERC-1155 token transfers.
 */
interface IERC1155Receiver is IERC165 {
    /**
     * @dev Handles the receipt of a single ERC1155 token type. This function is
     * called at the end of a `safeTransferFrom` after the balance has been updated.
     *
     * NOTE: To accept the transfer, this must return
     * `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))`
     * (i.e. 0xf23a6e61, or its own function selector).
     *
     * @param operator The address which initiated the transfer (i.e. msg.sender)
     * @param from The address which previously owned the token
     * @param id The ID of the token being transferred
     * @param value The amount of tokens being transferred
     * @param data Additional data with no specified format
     * @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed
     */
    function onERC1155Received(
        address operator,
        address from,
        uint256 id,
        uint256 value,
        bytes calldata data
    ) external returns (bytes4);

    /**
     * @dev Handles the receipt of a multiple ERC1155 token types. This function
     * is called at the end of a `safeBatchTransferFrom` after the balances have
     * been updated.
     *
     * NOTE: To accept the transfer(s), this must return
     * `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))`
     * (i.e. 0xbc197c81, or its own function selector).
     *
     * @param operator The address which initiated the batch transfer (i.e. msg.sender)
     * @param from The address which previously owned the token
     * @param ids An array containing ids of each token being transferred (order and length must match values array)
     * @param values An array containing amounts of each token being transferred (order and length must match ids array)
     * @param data Additional data with no specified format
     * @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed
     */
    function onERC1155BatchReceived(
        address operator,
        address from,
        uint256[] calldata ids,
        uint256[] calldata values,
        bytes calldata data
    ) external returns (bytes4);
}
ERC721Holder.sol 24 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/utils/ERC721Holder.sol)

pragma solidity ^0.8.20;

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

/**
 * @dev Implementation of the {IERC721Receiver} interface.
 *
 * Accepts all token transfers.
 * Make sure the contract is able to use its token with {IERC721-safeTransferFrom}, {IERC721-approve} or
 * {IERC721-setApprovalForAll}.
 */
abstract contract ERC721Holder is IERC721Receiver {
    /**
     * @dev See {IERC721Receiver-onERC721Received}.
     *
     * Always returns `IERC721Receiver.onERC721Received.selector`.
     */
    function onERC721Received(address, address, uint256, bytes memory) public virtual returns (bytes4) {
        return this.onERC721Received.selector;
    }
}
ERC1155Holder.sol 42 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC1155/utils/ERC1155Holder.sol)

pragma solidity ^0.8.20;

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

/**
 * @dev Simple implementation of `IERC1155Receiver` that will allow a contract to hold ERC1155 tokens.
 *
 * IMPORTANT: When inheriting this contract, you must include a way to use the received tokens, otherwise they will be
 * stuck.
 */
abstract contract ERC1155Holder is ERC165, IERC1155Receiver {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
        return interfaceId == type(IERC1155Receiver).interfaceId || super.supportsInterface(interfaceId);
    }

    function onERC1155Received(
        address,
        address,
        uint256,
        uint256,
        bytes memory
    ) public virtual override returns (bytes4) {
        return this.onERC1155Received.selector;
    }

    function onERC1155BatchReceived(
        address,
        address,
        uint256[] memory,
        uint256[] memory,
        bytes memory
    ) public virtual override returns (bytes4) {
        return this.onERC1155BatchReceived.selector;
    }
}

Read Contract

blackGoldNftUri 0xa8086755 → string
genesisERC1155Address 0x31b6e245 → address
genesisERC721Address 0x16b3d171 → address
getUserAddresses 0xa591efde → address[]
getUserNftIds 0x92f2ff80 → uint256[]
goldNftUri 0xfe4693a3 → string
owner 0x8da5cb5b → address
silverNftUri 0xefff997c → string
supportsInterface 0x01ffc9a7 → bool
userAddresses 0x502c9bd5 → address
userData 0xc8910913 → uint64, uint64, uint64

Write Contract 9 functions

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

claim 0x4e71d92d
No parameters
lock 0x859610c6
uint256[] nftIds
onERC1155BatchReceived 0xbc197c81
address
address
uint256[]
uint256[]
bytes
returns: bytes4
onERC1155Received 0xf23a6e61
address
address
uint256
uint256
bytes
returns: bytes4
onERC721Received 0x150b7a02
address
address
uint256
bytes
returns: bytes4
renounceOwnership 0x715018a6
No parameters
transferOwnership 0xf2fde38b
address newOwner
unlock 0x5d36598f
uint256[] nftIds
unlockAll 0xcd24b0a3
No parameters

Recent Transactions

No transactions found for this address