Cryo Explorer Ethereum Mainnet

Address Contract Verified

Address 0xb0dd2Cf11D0787146520ab39fbDC382F78dABb16
Balance 0 ETH
Nonce 1
Code Size 8639 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

8639 bytes
0x608060405234801561001057600080fd5b50600436106101f05760003560e01c80638748d4771161010f578063b16658bb116100a2578063dd62ed3e11610071578063dd62ed3e14610454578063e4cd874f1461049a578063ea38fab0146104a9578063f2fde38b146104df57600080fd5b8063b16658bb14610405578063b42348ac1461040e578063c12e6f161461042e578063d1d58b251461044157600080fd5b806395d89b41116100de57806395d89b41146103c55780639d2cc436146103cd578063a457c2d7146103df578063a9059cbb146103f257600080fd5b80638748d4771461034757806389967d51146103685780638da5cb5b1461037857806393994314146103bc57600080fd5b806339509351116101875780636ba4c138116101565780636ba4c138146102ee57806370a0823114610301578063715018a6146103375780638456cb591461033f57600080fd5b806339509351146102b55780633f4ba83a146102c8578063463b2eee146102d05780635c975abb146102e357600080fd5b806318160ddd116101c357806318160ddd1461027957806323b872dd14610281578063313ce5671461029457806332cb6b0c146102a357600080fd5b80630532bca1146101f557806306fdde031461020a578063095ea7b3146102285780631781bd481461024b575b600080fd5b610208610203366004611bf9565b6104f2565b005b610212610636565b60405161021f9190611c1b565b60405180910390f35b61023b610236366004611c8e565b6106c8565b604051901515815260200161021f565b61026b610259366004611cb8565b60076020526000908152604090205481565b60405190815260200161021f565b60025461026b565b61023b61028f366004611cd1565b6106e6565b6040516012815260200161021f565b61026b6acecb8f27f4200f3a00000081565b61023b6102c3366004611c8e565b61070a565b610208610756565b6102086102de366004611d88565b6107cd565b60055460ff1661023b565b6102086102fc366004611e8b565b610b8e565b61026b61030f366004611bf9565b73ffffffffffffffffffffffffffffffffffffffff1660009081526020819052604090205490565b610208610ced565b610208610d64565b61035a610355366004611bf9565b610dd9565b60405161021f929190611f08565b61026b6801158e460913d0000081565b600554610100900473ffffffffffffffffffffffffffffffffffffffff165b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200161021f565b61026b6108ad81565b610212610f3b565b61026b6a05909a817a215fedb0000081565b61023b6103ed366004611c8e565b610f4a565b61023b610400366004611c8e565b611001565b61026b6108ae81565b6006546103979073ffffffffffffffffffffffffffffffffffffffff1681565b61026b61043c366004611bf9565b61100f565b61026b61044f366004611cb8565b61107c565b61026b610462366004611f36565b73ffffffffffffffffffffffffffffffffffffffff918216600090815260016020908152604080832093909416825291909152205490565b61026b678ac7230489e8000081565b6103976104b7366004611cb8565b60086020526000908152604090205473ffffffffffffffffffffffffffffffffffffffff1681565b6102086104ed366004611bf9565b6110fd565b60055473ffffffffffffffffffffffffffffffffffffffff6101009091041633146105645760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff81166105c75760405162461bcd60e51b815260206004820152600c60248201527f496e76616c696420616464720000000000000000000000000000000000000000604482015260640161055b565b600680547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040517f9ee0f407fe781f489d612b2879aea89a7ce73492166d123f0b55ec4295626e4d90600090a250565b60606003805461064590611f69565b80601f016020809104026020016040519081016040528092919081815260200182805461067190611f69565b80156106be5780601f10610693576101008083540402835291602001916106be565b820191906000526020600020905b8154815290600101906020018083116106a157829003601f168201915b5050505050905090565b6000336106d6818585611312565b5060019392505050565b60025490565b6000336106f4858285611491565b6106ff85858561154e565b506001949350505050565b33600081815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff871684529091528120549091906106d69082908690610751908790611fe6565b611312565b60055473ffffffffffffffffffffffffffffffffffffffff6101009091041633146107c35760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161055b565b6107cb6117be565b565b6000848433856040516020016107e69493929190611ffe565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526006548151602083012091925073ffffffffffffffffffffffffffffffffffffffff16906108429084611885565b73ffffffffffffffffffffffffffffffffffffffff16146108a55760405162461bcd60e51b815260206004820152600b60248201527f496e76616c696420736967000000000000000000000000000000000000000000604482015260640161055b565b428311156108f55760405162461bcd60e51b815260206004820152600a60248201527f496e76616c696420747300000000000000000000000000000000000000000000604482015260640161055b565b60005b84811015610b8657336008600088888581811061091757610917612076565b602090810292909201358352508101919091526040016000205473ffffffffffffffffffffffffffffffffffffffff1614156109955760405162461bcd60e51b815260206004820152600660248201527f5374616b65640000000000000000000000000000000000000000000000000000604482015260640161055b565b6109a36108ae6108ad611fe6565b8686838181106109b5576109b5612076565b905060200201351115610a0a5760405162461bcd60e51b815260206004820152601060248201527f496e76616c696420746f6b656e20696400000000000000000000000000000000604482015260640161055b565b8360076000888885818110610a2157610a21612076565b9050602002013581526020019081526020016000205410610a845760405162461bcd60e51b815260206004820152600f60248201527f54696d6520697320612072697665720000000000000000000000000000000000604482015260640161055b565b600060076000888885818110610a9c57610a9c612076565b905060200201358152602001908152602001600020541115610ad957610ad9868683818110610acd57610acd612076565b90506020020135611922565b8360076000888885818110610af057610af0612076565b905060200201358152602001908152602001600020819055503360086000888885818110610b2057610b20612076565b90506020020135815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508080610b7e906120a5565b9150506108f8565b505050505050565b60005b81811015610ce8573360086000858585818110610bb057610bb0612076565b602090810292909201358352508101919091526040016000205473ffffffffffffffffffffffffffffffffffffffff1614610c2d5760405162461bcd60e51b815260206004820152600e60248201527f4163636573732064656e6965642e000000000000000000000000000000000000604482015260640161055b565b610c5733610c52858585818110610c4657610c46612076565b9050602002013561107c565b611954565b6201518060076000858585818110610c7157610c71612076565b9050602002013581526020019081526020016000205442610c9291906120de565b610c9c9190612124565b610ca690426120de565b60076000858585818110610cbc57610cbc612076565b905060200201358152602001908152602001600020819055508080610ce0906120a5565b915050610b91565b505050565b60055473ffffffffffffffffffffffffffffffffffffffff610100909104163314610d5a5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161055b565b6107cb60006119cc565b60055473ffffffffffffffffffffffffffffffffffffffff610100909104163314610dd15760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161055b565b6107cb611a4a565b6060806000610de78461100f565b905060008167ffffffffffffffff811115610e0457610e04611d59565b604051908082528060200260200182016040528015610e2d578160200160208202803683370190505b50905060008267ffffffffffffffff811115610e4b57610e4b611d59565b604051908082528060200260200182016040528015610e74578160200160208202803683370190505b5090506000805b610e896108ae6108ad611fe6565b8111610f2e5760008181526008602052604090205473ffffffffffffffffffffffffffffffffffffffff89811691161415610f1c5780848381518110610ed157610ed1612076565b6020026020010181815250506007600082815260200190815260200160002054838380610efd906120a5565b945081518110610f0f57610f0f612076565b6020026020010181815250505b80610f26816120a5565b915050610e7b565b5091969095509350505050565b60606004805461064590611f69565b33600081815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8716845290915281205490919083811015610ff45760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f000000000000000000000000000000000000000000000000000000606482015260840161055b565b6106ff8286868403611312565b6000336106d681858561154e565b6000805b6110216108ae6108ad611fe6565b81116110765760008181526008602052604090205473ffffffffffffffffffffffffffffffffffffffff848116911614156110645781611060816120a5565b9250505b8061106e816120a5565b915050611013565b50919050565b60008181526007602052604081205461109757506000919050565b60008281526007602052604081205462015180906110b590426120de565b6110bf9190612138565b905060006110cc84611af0565b6110df576801158e460913d000006110e9565b678ac7230489e800005b90506110f5818361214c565b949350505050565b60055473ffffffffffffffffffffffffffffffffffffffff61010090910416331461116a5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161055b565b73ffffffffffffffffffffffffffffffffffffffff81166111f35760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161055b565b6111fc816119cc565b50565b73ffffffffffffffffffffffffffffffffffffffff82166112625760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015260640161055b565b61126e60008383611b0b565b80600260008282546112809190611fe6565b909155505073ffffffffffffffffffffffffffffffffffffffff8216600090815260208190526040812080548392906112ba908490611fe6565b909155505060405181815273ffffffffffffffffffffffffffffffffffffffff8316906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a35b5050565b73ffffffffffffffffffffffffffffffffffffffff831661139a5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460448201527f7265737300000000000000000000000000000000000000000000000000000000606482015260840161055b565b73ffffffffffffffffffffffffffffffffffffffff82166114235760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f20616464726560448201527f7373000000000000000000000000000000000000000000000000000000000000606482015260840161055b565b73ffffffffffffffffffffffffffffffffffffffff83811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b73ffffffffffffffffffffffffffffffffffffffff8381166000908152600160209081526040808320938616835292905220547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8114611548578181101561153b5760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e6365000000604482015260640161055b565b6115488484848403611312565b50505050565b73ffffffffffffffffffffffffffffffffffffffff83166115d75760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f6472657373000000000000000000000000000000000000000000000000000000606482015260840161055b565b73ffffffffffffffffffffffffffffffffffffffff82166116605760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201527f6573730000000000000000000000000000000000000000000000000000000000606482015260840161055b565b61166b838383611b0b565b73ffffffffffffffffffffffffffffffffffffffff8316600090815260208190526040902054818110156117075760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206260448201527f616c616e63650000000000000000000000000000000000000000000000000000606482015260840161055b565b73ffffffffffffffffffffffffffffffffffffffff80851660009081526020819052604080822085850390559185168152908120805484929061174b908490611fe6565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516117b191815260200190565b60405180910390a3611548565b60055460ff166118105760405162461bcd60e51b815260206004820152601460248201527f5061757361626c653a206e6f7420706175736564000000000000000000000000604482015260640161055b565b600580547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390a1565b60008060008061189485611b5e565b6040805160008152602081018083528b905260ff8516918101919091526060810183905260808101829052929550909350915060019060a0016020604051602081039080840390855afa1580156118ef573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe00151979650505050505050565b6000818152600860205260409020546111fc9073ffffffffffffffffffffffffffffffffffffffff16610c528361107c565b6acecb8f27f4200f3a0000008161196a60025490565b6119749190611fe6565b11156119c25760405162461bcd60e51b815260206004820152600a60248201527f4d41585f535550504c5900000000000000000000000000000000000000000000604482015260640161055b565b61130e82826111ff565b6005805473ffffffffffffffffffffffffffffffffffffffff8381166101008181027fffffffffffffffffffffff0000000000000000000000000000000000000000ff85161790945560405193909204169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60055460ff1615611a9d5760405162461bcd60e51b815260206004820152601060248201527f5061757361626c653a2070617573656400000000000000000000000000000000604482015260640161055b565b600580547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25861185b3390565b60006108ae8211611b02576000611b05565b60015b92915050565b60055460ff1615610ce85760405162461bcd60e51b815260206004820152600c60248201527f546f6b656e207061757365640000000000000000000000000000000000000000604482015260640161055b565b60008060008351604114611bb45760405162461bcd60e51b815260206004820152600b60248201527f696e76616c696420736967000000000000000000000000000000000000000000604482015260640161055b565b5050506020810151604082015160609092015160001a92909190565b803573ffffffffffffffffffffffffffffffffffffffff81168114611bf457600080fd5b919050565b600060208284031215611c0b57600080fd5b611c1482611bd0565b9392505050565b600060208083528351808285015260005b81811015611c4857858101830151858201604001528201611c2c565b81811115611c5a576000604083870101525b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016929092016040019392505050565b60008060408385031215611ca157600080fd5b611caa83611bd0565b946020939093013593505050565b600060208284031215611cca57600080fd5b5035919050565b600080600060608486031215611ce657600080fd5b611cef84611bd0565b9250611cfd60208501611bd0565b9150604084013590509250925092565b60008083601f840112611d1f57600080fd5b50813567ffffffffffffffff811115611d3757600080fd5b6020830191508360208260051b8501011115611d5257600080fd5b9250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60008060008060608587031215611d9e57600080fd5b843567ffffffffffffffff80821115611db657600080fd5b611dc288838901611d0d565b9096509450602087013593506040870135915080821115611de257600080fd5b818701915087601f830112611df657600080fd5b813581811115611e0857611e08611d59565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f01168101908382118183101715611e4e57611e4e611d59565b816040528281528a6020848701011115611e6757600080fd5b82602086016020830137600060208483010152809550505050505092959194509250565b60008060208385031215611e9e57600080fd5b823567ffffffffffffffff811115611eb557600080fd5b611ec185828601611d0d565b90969095509350505050565b600081518084526020808501945080840160005b83811015611efd57815187529582019590820190600101611ee1565b509495945050505050565b604081526000611f1b6040830185611ecd565b8281036020840152611f2d8185611ecd565b95945050505050565b60008060408385031215611f4957600080fd5b611f5283611bd0565b9150611f6060208401611bd0565b90509250929050565b600181811c90821680611f7d57607f821691505b60208210811415611076577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60008219821115611ff957611ff9611fb7565b500190565b60007f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff85111561202d57600080fd5b8460051b8087843760609490941b7fffffffffffffffffffffffffffffffffffffffff000000000000000000000000169190930190815260148101919091526034019392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156120d7576120d7611fb7565b5060010190565b6000828210156120f0576120f0611fb7565b500390565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b600082612133576121336120f5565b500690565b600082612147576121476120f5565b500490565b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561218457612184611fb7565b50029056fea264697066735822122075a947008530cea2db5899ef6fb48cdeade585156ca26bc9d98c9632eca7b6c264736f6c63430008090033

Verified Source Code Full Match

Compiler: v0.8.9+commit.e5eed63a EVM: london Optimization: Yes (10000 runs)
Peach.sol 198 lines
// contracts/Peach.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.9;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Capped.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

/*
                       j╫╫╫╫╫╫ ]╫╫╫╫╫H                                          
                        ```╫╫╫ ]╫╫````                                          
    ▄▄▄▄      ▄▄▄▄  ÑÑÑÑÑÑÑ╫╫╫ ]╫╫ÑÑÑÑÑÑÑH ▄▄▄▄                                 
   ▐████      ████⌐ `````````` ``````````  ████▌                                
   ▐█████▌  ▐█████⌐▐██████████ ╫█████████▌ ████▌▐████ ▐██████████ ████▌ ████▌   
   ▐██████████████⌐▐████Γ▐████ ╫███▌└████▌ ████▌ ████ ▐████│█████ ████▌ ████▌   
   ▐████▀████▀████⌐▐████ ▐████ ╫███▌ ████▌ █████████▄ ▐██████████ ████▌ ████▌   
   ▐████ ▐██▌ ████⌐▐████ ▐████ ╫███▌ ████▌ ████▌▐████ ▐████│││││└ ██████████▌   
   ▐████      ████⌐▐██████████ ╫███▌ ████▌ ████▌▐████ ▐██████████ ▀▀▀▀▀▀████▌   
    ''''      ''''  '''''''''' `'''  `'''  ''''  ''''  '''''''''` ██████████▌   
╓╓╓╓  ╓╓╓╓  ╓╓╓╓                              .╓╓╓╓               ▀▀▀▀▀▀▀▀▀▀Γ   ===
████▌ ████=▐████                              ▐████                             
████▌ ████= ▄▄▄▄ ▐█████████▌ ██████████▌▐██████████ ║█████████▌ ███████▌▄███████
█████▄███▀ ▐████ ▐████▀████▌ ████▌▀████▌▐████▀▀████ ║████▀████▌ ████▌▀████▀▀████
█████▀████⌐▐████ ▐████ ╫███▌ ████▌ ████▌▐████ ▐████ ║████ ████▌ ████▌ ████=▐████
████▌ ████=▐████ ▐████ ╫███▌ █████▄████▌▐████ ▐████ ║████ ████▌ ████▌ ████=▐████
████▌ ████=▐████ ▐████ ╫███▌ ▀▀▀▀▀▀████▌▐██████████ ║█████████▌ ████▌ ████=▐████
▀▀▀▀` ▀▀▀▀  └└└└ `▀▀▀▀ "▀▀▀╘ ▄▄▄▄▄▄████▌ ▀▀▀▀▀▀▀▀▀▀ `▀▀▀▀▀▀▀▀▀└ ▀▀▀▀` ▀▀▀▀  ▀▀▀▀
                             ▀▀▀▀▀▀▀▀▀▀U                                      
*/

contract Peach is ERC20, Pausable, Ownable {
    uint256 public constant RESERVE = 6727500 ether;
    uint256 public constant MAX_SUPPLY = 250000000 ether;
    uint256 public constant WUKONG_DAILY_REWARD = 20 ether;
    uint256 public constant BAEPE_DAILY_REWARD = 10 ether;

    uint256 public constant NUM_WUKONGS = 2222;
    uint256 public constant NUM_BAEPES = 2221;

    address public authSigner;

    mapping(uint256 => uint256) public stakedTime;
    mapping(uint256 => address) public staker;

    event AuthSignerSet(address indexed newSigner);

    constructor(address _authSigner) ERC20("PEACH", "PEACH") {
        require(_authSigner != address(0), "Invalid addr");
        authSigner = _authSigner;
        _mint(msg.sender, RESERVE);
        // Set stakedTime of token ID 0 to max uint256 value to effectively disable staking of this tokenID 
        stakedTime[
            0
        ] = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff;
    }

    function pause() external onlyOwner {
        _pause();
    }

    function unpause() external onlyOwner {
        _unpause();
    }

    function setAuthSigner(address _authSigner) external onlyOwner {
        require(_authSigner != address(0), "Invalid addr");
        authSigner = _authSigner;
        emit AuthSignerSet(_authSigner);
    }

    function _beforeTokenTransfer(
        address from,
        address to,
        uint256 amount
    ) internal virtual override {
        super._beforeTokenTransfer(from, to, amount);
        require(!paused(), "Token paused");
    }

    function _mint(address account, uint256 amount) internal virtual override {
        require(ERC20.totalSupply() + amount <= MAX_SUPPLY, "MAX_SUPPLY");
        super._mint(account, amount);
    }

    function splitSignature(bytes memory sig)
        internal
        pure
        returns (
            uint8,
            bytes32,
            bytes32
        )
    {
        require(sig.length == 65, "invalid sig");

        bytes32 r;
        bytes32 s;
        uint8 v;

        assembly {
            r := mload(add(sig, 32))
            s := mload(add(sig, 64))
            v := byte(0, mload(add(sig, 96)))
        }

        return (v, r, s);
    }

    function recoverSigner(bytes32 message, bytes memory sig)
        internal
        pure
        returns (address)
    {
        uint8 v;
        bytes32 r;
        bytes32 s;

        (v, r, s) = splitSignature(sig);
        return ecrecover(message, v, r, s);
    }

    function sendPrevEarnings(uint256 tokenId) private {
        _mint(staker[tokenId], claimable(tokenId));
    }

    function claim(uint256[] calldata tokenIds) external {
        for (uint256 i = 0; i < tokenIds.length; i++) {
            require(staker[tokenIds[i]] == msg.sender, "Access denied.");
            _mint(msg.sender, claimable(tokenIds[i]));
            stakedTime[tokenIds[i]] = block.timestamp - (block.timestamp - stakedTime[tokenIds[i]]) % 1 days;
        }
    }

    function claimable(uint256 tokenId) public view returns (uint256 sum) {
        if (stakedTime[tokenId] == 0) return 0;
        uint256 daysStaked = (block.timestamp - stakedTime[tokenId]) / 1 days;
        uint256 dailyReward = isBaepe(tokenId)
            ? BAEPE_DAILY_REWARD
            : WUKONG_DAILY_REWARD;
        sum = daysStaked * dailyReward;
    }

    function isBaepe(uint256 tokenId) internal pure returns (bool) {
        return tokenId > NUM_WUKONGS ? true : false;
    }

    function stake(
        uint256[] calldata tokenIds,
        uint256 ts,
        bytes memory sig
    ) external {
        bytes memory b = abi.encodePacked(tokenIds, msg.sender, ts);
        require(recoverSigner(keccak256(b), sig) == authSigner, "Invalid sig");
        require(ts <= block.timestamp, "Invalid ts");

        for (uint256 i = 0; i < tokenIds.length; i++) {
            require(staker[tokenIds[i]] != msg.sender, "Staked");
            require(
                tokenIds[i] <= NUM_BAEPES + NUM_WUKONGS,
                "Invalid token id"
            );
            require(stakedTime[tokenIds[i]] < ts, "Time is a river");
            if (stakedTime[tokenIds[i]] > 0) sendPrevEarnings(tokenIds[i]);
            stakedTime[tokenIds[i]] = ts;
            staker[tokenIds[i]] = msg.sender;
        }
    }

    function listStakedTokens(address wallet)
        external
        view
        returns (uint256[] memory, uint256[] memory)
    {
        uint256 count = countStakedTokens(wallet);
        uint256[] memory staked = new uint256[](count);
        uint256[] memory stakeTimes = new uint256[](count);
        uint256 j;
        for (uint256 i = 0; i <= NUM_BAEPES + NUM_WUKONGS; i++) {
            if (staker[i] == wallet) {
                staked[j] = i;
                stakeTimes[j++] = stakedTime[i];
            }
        }
        return (staked, stakeTimes);
    }

    function countStakedTokens(address wallet)
        public
        view
        returns (uint256 count)
    {
        count = 0;
        for (uint256 i = 0; i <= NUM_BAEPES + NUM_WUKONGS; i++) {
            if (staker[i] == wallet) count++;
        }
    }
}
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);
    }
}
Pausable.sol 91 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/Pausable.sol)

pragma solidity ^0.8.0;

import "../utils/Context.sol";

/**
 * @dev Contract module which allows children to implement an emergency stop
 * mechanism that can be triggered by an authorized account.
 *
 * This module is used through inheritance. It will make available the
 * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
 * the functions of your contract. Note that they will not be pausable by
 * simply including this module, only once the modifiers are put in place.
 */
abstract contract Pausable is Context {
    /**
     * @dev Emitted when the pause is triggered by `account`.
     */
    event Paused(address account);

    /**
     * @dev Emitted when the pause is lifted by `account`.
     */
    event Unpaused(address account);

    bool private _paused;

    /**
     * @dev Initializes the contract in unpaused state.
     */
    constructor() {
        _paused = false;
    }

    /**
     * @dev Returns true if the contract is paused, and false otherwise.
     */
    function paused() public view virtual returns (bool) {
        return _paused;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is not paused.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    modifier whenNotPaused() {
        require(!paused(), "Pausable: paused");
        _;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is paused.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    modifier whenPaused() {
        require(paused(), "Pausable: not paused");
        _;
    }

    /**
     * @dev Triggers stopped state.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    function _pause() internal virtual whenNotPaused {
        _paused = true;
        emit Paused(_msgSender());
    }

    /**
     * @dev Returns to normal state.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    function _unpause() internal virtual whenPaused {
        _paused = false;
        emit Unpaused(_msgSender());
    }
}
ERC20.sol 383 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/ERC20.sol)

pragma solidity ^0.8.0;

import "./IERC20.sol";
import "./extensions/IERC20Metadata.sol";
import "../../utils/Context.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}.
 * For a generic mechanism see {ERC20PresetMinterPauser}.
 *
 * TIP: For a detailed writeup see our guide
 * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
 * to implement supply mechanisms].
 *
 * 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 ERC20
 * applications.
 *
 * Additionally, an {Approval} event is emitted on calls to {transferFrom}.
 * This allows applications to reconstruct the allowance for all accounts just
 * by listening to said events. Other implementations of the EIP may not emit
 * these events, as it isn't required by the specification.
 *
 * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
 * functions have been added to mitigate the well-known issues around setting
 * allowances. See {IERC20-approve}.
 */
contract ERC20 is Context, IERC20, IERC20Metadata {
    mapping(address => uint256) private _balances;

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

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;

    /**
     * @dev Sets the values for {name} and {symbol}.
     *
     * The default value of {decimals} is 18. To select a different value for
     * {decimals} you should overload it.
     *
     * All two of these 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 override returns (string memory) {
        return _name;
    }

    /**
     * @dev Returns the symbol of the token, usually a shorter version of the
     * name.
     */
    function symbol() public view virtual override 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 value {ERC20} uses, unless this function is
     * 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 override returns (uint8) {
        return 18;
    }

    /**
     * @dev See {IERC20-totalSupply}.
     */
    function totalSupply() public view virtual override returns (uint256) {
        return _totalSupply;
    }

    /**
     * @dev See {IERC20-balanceOf}.
     */
    function balanceOf(address account) public view virtual override 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 `amount`.
     */
    function transfer(address to, uint256 amount) public virtual override returns (bool) {
        address owner = _msgSender();
        _transfer(owner, to, amount);
        return true;
    }

    /**
     * @dev See {IERC20-allowance}.
     */
    function allowance(address owner, address spender) public view virtual override returns (uint256) {
        return _allowances[owner][spender];
    }

    /**
     * @dev See {IERC20-approve}.
     *
     * NOTE: If `amount` 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 amount) public virtual override returns (bool) {
        address owner = _msgSender();
        _approve(owner, spender, amount);
        return true;
    }

    /**
     * @dev See {IERC20-transferFrom}.
     *
     * Emits an {Approval} event indicating the updated allowance. This is not
     * required by the EIP. See the note at the beginning of {ERC20}.
     *
     * 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 `amount`.
     * - the caller must have allowance for ``from``'s tokens of at least
     * `amount`.
     */
    function transferFrom(
        address from,
        address to,
        uint256 amount
    ) public virtual override returns (bool) {
        address spender = _msgSender();
        _spendAllowance(from, spender, amount);
        _transfer(from, to, amount);
        return true;
    }

    /**
     * @dev Atomically increases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
        address owner = _msgSender();
        _approve(owner, spender, _allowances[owner][spender] + addedValue);
        return true;
    }

    /**
     * @dev Atomically decreases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `spender` must have allowance for the caller of at least
     * `subtractedValue`.
     */
    function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
        address owner = _msgSender();
        uint256 currentAllowance = _allowances[owner][spender];
        require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
        unchecked {
            _approve(owner, spender, currentAllowance - subtractedValue);
        }

        return true;
    }

    /**
     * @dev Moves `amount` of tokens from `sender` to `recipient`.
     *
     * 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.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `from` must have a balance of at least `amount`.
     */
    function _transfer(
        address from,
        address to,
        uint256 amount
    ) internal virtual {
        require(from != address(0), "ERC20: transfer from the zero address");
        require(to != address(0), "ERC20: transfer to the zero address");

        _beforeTokenTransfer(from, to, amount);

        uint256 fromBalance = _balances[from];
        require(fromBalance >= amount, "ERC20: transfer amount exceeds balance");
        unchecked {
            _balances[from] = fromBalance - amount;
        }
        _balances[to] += amount;

        emit Transfer(from, to, amount);

        _afterTokenTransfer(from, to, amount);
    }

    /** @dev Creates `amount` tokens and assigns them to `account`, increasing
     * the total supply.
     *
     * Emits a {Transfer} event with `from` set to the zero address.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     */
    function _mint(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: mint to the zero address");

        _beforeTokenTransfer(address(0), account, amount);

        _totalSupply += amount;
        _balances[account] += amount;
        emit Transfer(address(0), account, amount);

        _afterTokenTransfer(address(0), account, amount);
    }

    /**
     * @dev Destroys `amount` tokens from `account`, reducing the
     * total supply.
     *
     * Emits a {Transfer} event with `to` set to the zero address.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     * - `account` must have at least `amount` tokens.
     */
    function _burn(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: burn from the zero address");

        _beforeTokenTransfer(account, address(0), amount);

        uint256 accountBalance = _balances[account];
        require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
        unchecked {
            _balances[account] = accountBalance - amount;
        }
        _totalSupply -= amount;

        emit Transfer(account, address(0), amount);

        _afterTokenTransfer(account, address(0), amount);
    }

    /**
     * @dev Sets `amount` 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.
     */
    function _approve(
        address owner,
        address spender,
        uint256 amount
    ) internal virtual {
        require(owner != address(0), "ERC20: approve from the zero address");
        require(spender != address(0), "ERC20: approve to the zero address");

        _allowances[owner][spender] = amount;
        emit Approval(owner, spender, amount);
    }

    /**
     * @dev Spend `amount` form the allowance of `owner` toward `spender`.
     *
     * Does not update the allowance amount in case of infinite allowance.
     * Revert if not enough allowance is available.
     *
     * Might emit an {Approval} event.
     */
    function _spendAllowance(
        address owner,
        address spender,
        uint256 amount
    ) internal virtual {
        uint256 currentAllowance = allowance(owner, spender);
        if (currentAllowance != type(uint256).max) {
            require(currentAllowance >= amount, "ERC20: insufficient allowance");
            unchecked {
                _approve(owner, spender, currentAllowance - amount);
            }
        }
    }

    /**
     * @dev Hook that is called before any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * will be transferred to `to`.
     * - when `from` is zero, `amount` tokens will be minted for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens will be burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(
        address from,
        address to,
        uint256 amount
    ) internal virtual {}

    /**
     * @dev Hook that is called after any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * has been transferred to `to`.
     * - when `from` is zero, `amount` tokens have been minted for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens have been burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _afterTokenTransfer(
        address from,
        address to,
        uint256 amount
    ) internal virtual {}
}
IERC20.sol 82 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

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

    /**
     * @dev Moves `amount` 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 amount) 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 `amount` 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 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `from` to `to` using the
     * allowance mechanism. `amount` 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 amount
    ) external returns (bool);

    /**
     * @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);
}
ERC20Capped.sol 37 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/ERC20Capped.sol)

pragma solidity ^0.8.0;

import "../ERC20.sol";

/**
 * @dev Extension of {ERC20} that adds a cap to the supply of tokens.
 */
abstract contract ERC20Capped is ERC20 {
    uint256 private immutable _cap;

    /**
     * @dev Sets the value of the `cap`. This value is immutable, it can only be
     * set once during construction.
     */
    constructor(uint256 cap_) {
        require(cap_ > 0, "ERC20Capped: cap is 0");
        _cap = cap_;
    }

    /**
     * @dev Returns the cap on the token's total supply.
     */
    function cap() public view virtual returns (uint256) {
        return _cap;
    }

    /**
     * @dev See {ERC20-_mint}.
     */
    function _mint(address account, uint256 amount) internal virtual override {
        require(ERC20.totalSupply() + amount <= cap(), "ERC20Capped: cap exceeded");
        super._mint(account, amount);
    }
}
IERC20Metadata.sol 28 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";

/**
 * @dev Interface for the optional metadata functions from the ERC20 standard.
 *
 * _Available since v4.1._
 */
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);
}

Read Contract

BAEPE_DAILY_REWARD 0xe4cd874f → uint256
MAX_SUPPLY 0x32cb6b0c → uint256
NUM_BAEPES 0x93994314 → uint256
NUM_WUKONGS 0xb16658bb → uint256
RESERVE 0x9d2cc436 → uint256
WUKONG_DAILY_REWARD 0x89967d51 → uint256
allowance 0xdd62ed3e → uint256
authSigner 0xb42348ac → address
balanceOf 0x70a08231 → uint256
claimable 0xd1d58b25 → uint256
countStakedTokens 0xc12e6f16 → uint256
decimals 0x313ce567 → uint8
listStakedTokens 0x8748d477 → uint256[], uint256[]
name 0x06fdde03 → string
owner 0x8da5cb5b → address
paused 0x5c975abb → bool
stakedTime 0x1781bd48 → uint256
staker 0xea38fab0 → address
symbol 0x95d89b41 → string
totalSupply 0x18160ddd → uint256

Write Contract 12 functions

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

approve 0x095ea7b3
address spender
uint256 amount
returns: bool
claim 0x6ba4c138
uint256[] tokenIds
decreaseAllowance 0xa457c2d7
address spender
uint256 subtractedValue
returns: bool
increaseAllowance 0x39509351
address spender
uint256 addedValue
returns: bool
pause 0x8456cb59
No parameters
renounceOwnership 0x715018a6
No parameters
setAuthSigner 0x0532bca1
address _authSigner
stake 0x463b2eee
uint256[] tokenIds
uint256 ts
bytes sig
transfer 0xa9059cbb
address to
uint256 amount
returns: bool
transferFrom 0x23b872dd
address from
address to
uint256 amount
returns: bool
transferOwnership 0xf2fde38b
address newOwner
unpause 0x3f4ba83a
No parameters

Recent Transactions

No transactions found for this address