Cryo Explorer Ethereum Mainnet

Address Contract Verified

Address 0x98727FB35AdDf1eE92d62B36CeabFF1b5d3E2503
Balance 0 ETH
Nonce 1
Code Size 7013 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

7013 bytes
0x608060405234801561001057600080fd5b50600436106100a95760003560e01c806370a082311161007157806370a0823114610164578063715018a6146101945780638da5cb5b1461019e57806394067045146101bc578063e449f341146101ec578063f2fde38b14610208576100a9565b80630fbf0a93146100ae578063150b7a02146100ca5780632b4fd779146100fa5780632f745c59146101165780636588103b14610146575b600080fd5b6100c860048036038101906100c391906112eb565b610224565b005b6100e460048036038101906100df9190611228565b6105df565b6040516100f1919061150b565b60405180910390f35b610114600480360381019061010f91906111ce565b6105f3565b005b610130600480360381019061012b91906112ab565b61075a565b60405161013d9190611641565b60405180910390f35b61014e6107ff565b60405161015b9190611526565b60405180910390f35b61017e600480360381019061017991906111ce565b610825565b60405161018b9190611641565b60405180910390f35b61019c61086e565b005b6101a66108f6565b6040516101b391906114b9565b60405180910390f35b6101d660048036038101906101d19190611338565b61091f565b6040516101e391906114b9565b60405180910390f35b610206600480360381019061020191906112eb565b610952565b005b610222600480360381019061021d91906111ce565b610d19565b005b6002600154141561026a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161026190611621565b60405180910390fd5b6002600181905550600082829050905060005b818110156105d25761028d610e11565b73ffffffffffffffffffffffffffffffffffffffff16600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16636352211e8686858181106102f4576102f36118ba565b5b905060200201356040518263ffffffff1660e01b81526004016103179190611641565b60206040518083038186803b15801561032f57600080fd5b505afa158015610343573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061036791906111fb565b73ffffffffffffffffffffffffffffffffffffffff16146103bd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103b490611581565b60405180910390fd5b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd610403610e11565b30878786818110610417576104166118ba565b5b905060200201356040518463ffffffff1660e01b815260040161043c939291906114d4565b600060405180830381600087803b15801561045657600080fd5b505af115801561046a573d6000803e3d6000fd5b50505050610476610e11565b6003600086868581811061048d5761048c6118ba565b5b90506020020135815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555061050a6104eb610e11565b8585848181106104fe576104fd6118ba565b5b90506020020135610e19565b600160026000610518610e11565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461056191906116ec565b925050819055507f6e47dcdd359b6cd69456f0f97d394bd4540a2e7c4adc1b9da076859df53756c784848381811061059c5761059b6118ba565b5b905060200201356105ab610e11565b6040516105b992919061165c565b60405180910390a1806105cb90611842565b905061027d565b5050600180819055505050565b600063150b7a0260e01b9050949350505050565b6105fb610e11565b73ffffffffffffffffffffffffffffffffffffffff166106196108f6565b73ffffffffffffffffffffffffffffffffffffffff161461066f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610666906115c1565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156106df576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106d690611601565b60405180910390fd5b80600660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507f5c7550a178940fd0fecb35dc85ad3975247522c3a1fd2b444cccea77f01c93258160405161074f91906114b9565b60405180910390a150565b600061076583610825565b82106107a6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161079d906115a1565b60405180910390fd5b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002054905092915050565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b610876610e11565b73ffffffffffffffffffffffffffffffffffffffff166108946108f6565b73ffffffffffffffffffffffffffffffffffffffff16146108ea576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108e1906115c1565b60405180910390fd5b6108f46000610e98565b565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60036020528060005260406000206000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60026001541415610998576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161098f90611621565b60405180910390fd5b60026001819055506000600260006109ae610e11565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205411610a29576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a2090611561565b60405180910390fd5b600082829050905060005b81811015610d0c57610a44610e11565b73ffffffffffffffffffffffffffffffffffffffff1660036000868685818110610a7157610a706118ba565b5b90506020020135815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610afd576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610af4906115e1565b60405180910390fd5b600060036000868685818110610b1657610b156118ba565b5b90506020020135815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd30610bb0610e11565b878786818110610bc357610bc26118ba565b5b905060200201356040518463ffffffff1660e01b8152600401610be8939291906114d4565b600060405180830381600087803b158015610c0257600080fd5b505af1158015610c16573d6000803e3d6000fd5b50505050610c44610c25610e11565b858584818110610c3857610c376118ba565b5b90506020020135610f5c565b600160026000610c52610e11565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610c9b9190611742565b925050819055507f81b0ac4b13aab1ab3b86d524dd62924e99a9d694e94e235f627bb41589717ff7848483818110610cd657610cd56118ba565b5b90506020020135610ce5610e11565b604051610cf392919061165c565b60405180910390a180610d0590611842565b9050610a34565b5050600180819055505050565b610d21610e11565b73ffffffffffffffffffffffffffffffffffffffff16610d3f6108f6565b73ffffffffffffffffffffffffffffffffffffffff1614610d95576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d8c906115c1565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610e05576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610dfc90611541565b60405180910390fd5b610e0e81610e98565b50565b600033905090565b6000610e2483610825565b905081600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002081905550806005600084815260200190815260200160002081905550505050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b60006001610f6984610825565b610f739190611742565b9050600060056000848152602001908152602001600020549050818114611058576000600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002054905080600460008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002081905550816005600083815260200190815260200160002081905550505b6005600084815260200190815260200160002060009055600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008381526020019081526020016000206000905550505050565b60006110dc6110d7846116aa565b611685565b9050828152602081018484840111156110f8576110f7611927565b5b611103848285611802565b509392505050565b60008135905061111a81611b01565b92915050565b60008151905061112f81611b01565b92915050565b60008083601f84011261114b5761114a61191d565b5b8235905067ffffffffffffffff81111561116857611167611918565b5b60208301915083602082028301111561118457611183611922565b5b9250929050565b600082601f8301126111a05761119f61191d565b5b81356111b08482602086016110c9565b91505092915050565b6000813590506111c881611b18565b92915050565b6000602082840312156111e4576111e3611931565b5b60006111f28482850161110b565b91505092915050565b60006020828403121561121157611210611931565b5b600061121f84828501611120565b91505092915050565b6000806000806080858703121561124257611241611931565b5b60006112508782880161110b565b94505060206112618782880161110b565b9350506040611272878288016111b9565b925050606085013567ffffffffffffffff8111156112935761129261192c565b5b61129f8782880161118b565b91505092959194509250565b600080604083850312156112c2576112c1611931565b5b60006112d08582860161110b565b92505060206112e1858286016111b9565b9150509250929050565b6000806020838503121561130257611301611931565b5b600083013567ffffffffffffffff8111156113205761131f61192c565b5b61132c85828601611135565b92509250509250929050565b60006020828403121561134e5761134d611931565b5b600061135c848285016111b9565b91505092915050565b61136e81611776565b82525050565b61137d81611788565b82525050565b61138c816117de565b82525050565b600061139f6026836116db565b91506113aa82611947565b604082019050919050565b60006113c26019836116db565b91506113cd82611996565b602082019050919050565b60006113e56021836116db565b91506113f0826119bf565b604082019050919050565b60006114086019836116db565b915061141382611a0e565b602082019050919050565b600061142b6020836116db565b915061143682611a37565b602082019050919050565b600061144e6026836116db565b915061145982611a60565b604082019050919050565b60006114716019836116db565b915061147c82611aaf565b602082019050919050565b6000611494601f836116db565b915061149f82611ad8565b602082019050919050565b6114b3816117d4565b82525050565b60006020820190506114ce6000830184611365565b92915050565b60006060820190506114e96000830186611365565b6114f66020830185611365565b61150360408301846114aa565b949350505050565b60006020820190506115206000830184611374565b92915050565b600060208201905061153b6000830184611383565b92915050565b6000602082019050818103600083015261155a81611392565b9050919050565b6000602082019050818103600083015261157a816113b5565b9050919050565b6000602082019050818103600083015261159a816113d8565b9050919050565b600060208201905081810360008301526115ba816113fb565b9050919050565b600060208201905081810360008301526115da8161141e565b9050919050565b600060208201905081810360008301526115fa81611441565b9050919050565b6000602082019050818103600083015261161a81611464565b9050919050565b6000602082019050818103600083015261163a81611487565b9050919050565b600060208201905061165660008301846114aa565b92915050565b600060408201905061167160008301856114aa565b61167e6020830184611365565b9392505050565b600061168f6116a0565b905061169b8282611811565b919050565b6000604051905090565b600067ffffffffffffffff8211156116c5576116c46118e9565b5b6116ce82611936565b9050602081019050919050565b600082825260208201905092915050565b60006116f7826117d4565b9150611702836117d4565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156117375761173661188b565b5b828201905092915050565b600061174d826117d4565b9150611758836117d4565b92508282101561176b5761176a61188b565b5b828203905092915050565b6000611781826117b4565b9050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b60006117e9826117f0565b9050919050565b60006117fb826117b4565b9050919050565b82818337600083830152505050565b61181a82611936565b810181811067ffffffffffffffff82111715611839576118386118e9565b5b80604052505050565b600061184d826117d4565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156118805761187f61188b565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f596f752068617665206e6f20746f6b656e73207374616b656400000000000000600082015250565b7f43616e2774207374616b6520746f6b656e7320796f7520646f6e2774206f776e60008201527f2100000000000000000000000000000000000000000000000000000000000000602082015250565b7f4f776e657220696e646578206f7574206f6620626f756e647300000000000000600082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f43616e277420756e7374616b6520746f6b656e7320796f75206469646e27742060008201527f7374616b65210000000000000000000000000000000000000000000000000000602082015250565b7f426164204e4654436f6c6c656374696f6e206164647265737300000000000000600082015250565b7f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00600082015250565b611b0a81611776565b8114611b1557600080fd5b50565b611b21816117d4565b8114611b2c57600080fd5b5056fea2646970667358221220a0a63e6fda17246b2de4dcb00f99cbf748f577393b65c51822f76a4ac15671e564736f6c63430008060033

Verified Source Code Full Match

Compiler: v0.8.6+commit.11564f7e EVM: berlin Optimization: No
TroversePlanetsStaking.sol 104 lines
// contracs/TroversePlanetsStaking.sol
// SPDX-License-Identifier: MIT

// ████████╗██████╗  ██████╗ ██╗   ██╗███████╗██████╗ ███████╗███████╗    
// ╚══██╔══╝██╔══██╗██╔═══██╗██║   ██║██╔════╝██╔══██╗██╔════╝██╔════╝    
//    ██║   ██████╔╝██║   ██║██║   ██║█████╗  ██████╔╝███████╗█████╗      
//    ██║   ██╔══██╗██║   ██║╚██╗ ██╔╝██╔══╝  ██╔══██╗╚════██║██╔══╝      
//    ██║   ██║  ██║╚██████╔╝ ╚████╔╝ ███████╗██║  ██║███████║███████╗    
//    ╚═╝   ╚═╝  ╚═╝ ╚═════╝   ╚═══╝  ╚══════╝╚═╝  ╚═╝╚══════╝╚══════╝    

pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC721/utils/ERC721Holder.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";

contract TroversePlanetsStaking is ERC721Holder, Ownable, ReentrancyGuard {
    mapping(address => uint256) private amountStaked;
    mapping(uint256 => address) public stakerAddress;

    mapping(address => mapping(uint256 => uint256)) private _ownedTokens;
    mapping(uint256 => uint256) private _ownedTokensIndex;

    IERC721 public nftCollection;

    event NFTCollectionChanged(address _nftCollection);

    event Staked(uint256 id, address account);
    event Unstaked(uint256 id, address account);


    constructor() { }


    function setNFTCollection(address _nftCollection) external onlyOwner {
        require(_nftCollection != address(0), "Bad NFTCollection address");
        nftCollection = IERC721(_nftCollection);

        emit NFTCollectionChanged(_nftCollection);
    }

    function balanceOf(address owner) public view returns (uint256) {
        return amountStaked[owner];
    }

    function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256) {
        require(index < balanceOf(owner), "Owner index out of bounds");
        return _ownedTokens[owner][index];
    }
    
    function stake(uint256[] calldata _tokenIds) external nonReentrant {
        uint256 tokensLen = _tokenIds.length;
        for (uint256 i; i < tokensLen; ++i) {
            require(nftCollection.ownerOf(_tokenIds[i]) == _msgSender(), "Can't stake tokens you don't own!");

            nftCollection.transferFrom(_msgSender(), address(this), _tokenIds[i]);
            stakerAddress[_tokenIds[i]] = _msgSender();

            _addTokenToOwnerEnumeration(_msgSender(), _tokenIds[i]);
            amountStaked[_msgSender()] += 1;

            emit Staked(_tokenIds[i], _msgSender());
        }
    }

    function unstake(uint256[] calldata _tokenIds) external nonReentrant {
        require(amountStaked[_msgSender()] > 0, "You have no tokens staked");

        uint256 tokensLen = _tokenIds.length;
        for (uint256 i; i < tokensLen; ++i) {
            require(stakerAddress[_tokenIds[i]] == _msgSender(), "Can't unstake tokens you didn't stake!");

            stakerAddress[_tokenIds[i]] = address(0);
            nftCollection.transferFrom(address(this), _msgSender(), _tokenIds[i]);

            _removeTokenFromOwnerEnumeration(_msgSender(), _tokenIds[i]);
            amountStaked[_msgSender()] -= 1;

            emit Unstaked(_tokenIds[i], _msgSender());
        }
    }

    function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {
        uint256 length = balanceOf(to);
        _ownedTokens[to][length] = tokenId;
        _ownedTokensIndex[tokenId] = length;
    }

    function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private {
        uint256 lastTokenIndex = balanceOf(from) - 1;
        uint256 tokenIndex = _ownedTokensIndex[tokenId];
        
        if (tokenIndex != lastTokenIndex) {
            uint256 lastTokenId = _ownedTokens[from][lastTokenIndex];

            _ownedTokens[from][tokenIndex] = lastTokenId;
            _ownedTokensIndex[lastTokenId] = tokenIndex;
        }
        
        delete _ownedTokensIndex[tokenId];
        delete _ownedTokens[from][lastTokenIndex];
    }
}
Context.sol 24 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;

/**
 * @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;
    }
}
Ownable.sol 76 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)

pragma solidity ^0.8.0;

import "../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.
 *
 * By default, the owner account will be the one that deploys the contract. 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;

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

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        _transferOwnership(_msgSender());
    }

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

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
        _;
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing 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 {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _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 143 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuard {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant _NOT_ENTERED = 1;
    uint256 private constant _ENTERED = 2;

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        // On the first call to nonReentrant, _notEntered will be true
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

        // Any calls to nonReentrant after this point will fail
        _status = _ENTERED;

        _;

        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = _NOT_ENTERED;
    }
}
IERC165.sol 25 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)

pragma solidity ^0.8.0;

/**
 * @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 27 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol)

pragma solidity ^0.8.0;

/**
 * @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 `IERC721.onERC721Received.selector`.
     */
    function onERC721Received(
        address operator,
        address from,
        uint256 tokenId,
        bytes calldata data
    ) external returns (bytes4);
}
ERC721Holder.sol 28 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/utils/ERC721Holder.sol)

pragma solidity ^0.8.0;

import "../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}.
 */
contract ERC721Holder is IERC721Receiver {
    /**
     * @dev See {IERC721Receiver-onERC721Received}.
     *
     * Always returns `IERC721Receiver.onERC721Received.selector`.
     */
    function onERC721Received(
        address,
        address,
        uint256,
        bytes memory
    ) public virtual override returns (bytes4) {
        return this.onERC721Received.selector;
    }
}

Read Contract

balanceOf 0x70a08231 → uint256
nftCollection 0x6588103b → address
owner 0x8da5cb5b → address
stakerAddress 0x94067045 → address
tokenOfOwnerByIndex 0x2f745c59 → uint256

Write Contract 6 functions

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

onERC721Received 0x150b7a02
address
address
uint256
bytes
returns: bytes4
renounceOwnership 0x715018a6
No parameters
setNFTCollection 0x2b4fd779
address _nftCollection
stake 0x0fbf0a93
uint256[] _tokenIds
transferOwnership 0xf2fde38b
address newOwner
unstake 0xe449f341
uint256[] _tokenIds

Recent Transactions

No transactions found for this address