Contract 0xea5755ffba14683853f1e212f2aeca928be4815e

 
Txn Hash Method
Block
From
To
Value [Txn Fee]
0xbf5c238ceb0a0314e552e13f6891f3af0f3471ca15a9a597488a5d3896e940150x60806040102858412022-04-21 21:38:16225 days 2 hrs ago0xb013abd83f0bd173e9f14ce7d6e420ad711483b4 IN  Create: SmolFarm0 ETH0.023126873669 ETH
[ Download CSV Export 
Latest 25 internal transaction
Parent Txn Hash Block From To Value
0xa844d499bc4ad030ca14090ed12fa8cbd0daf4c43b7b6836321f920c75d20edb104123102022-04-23 17:14:34223 days 6 hrs ago 0xa31a661fa0247e04499291c98c57ca23dc2d26db 0xea5755ffba14683853f1e212f2aeca928be4815e0 ETH
0xf2d57acadda4e28a66438047f8b4a593dad17e0126246c41c1a38297035f4b8a104123072022-04-23 17:14:34223 days 6 hrs ago 0xa29cca54c47ce766a544236177c00015616b5676 0xea5755ffba14683853f1e212f2aeca928be4815e0 ETH
0x7c304614120108d675c730b3db76a02ecf308dff6cc9f077bee5ad04e55cb00d104122872022-04-23 17:13:30223 days 7 hrs ago 0xba3269e784c087c2c427c62499b5badca6775dcd 0xea5755ffba14683853f1e212f2aeca928be4815e0 ETH
0x77e394e4d9e5e8b092ccdc35b450f3cdbc64515322b432987ff5d40292a402e8104122812022-04-23 17:13:30223 days 7 hrs ago 0x9ed43f95ad8f2d59866331882f402b8c49056dc0 0xea5755ffba14683853f1e212f2aeca928be4815e0 ETH
0xbaeaebad31147659549bacff594835cf4882c5d878669dfd597bc8a8378e073e104122442022-04-23 17:13:29223 days 7 hrs ago 0xa29cca54c47ce766a544236177c00015616b5676 0xea5755ffba14683853f1e212f2aeca928be4815e0 ETH
0xe346f54a1605c0553c2ca343e13d2acf7f3d5225e55606a5e5e7ceb4f3b09738104122432022-04-23 17:13:29223 days 7 hrs ago 0x82251599e64ce75eb2f5dddbcda5690062c316f0 0xea5755ffba14683853f1e212f2aeca928be4815e0 ETH
0x33cdc059addb607e702a13924454e3e231e4a0fa4129869de9529f2addddadf1104121472022-04-23 17:09:40223 days 7 hrs ago 0x9ae20292e595073f9d1ecd7b05e5c042eb764557 0xea5755ffba14683853f1e212f2aeca928be4815e0 ETH
0xc44f490608482df5856823f36366b36ca5f36045430451b17800bdb247e92059104120612022-04-23 17:09:14223 days 7 hrs ago 0x9ed43f95ad8f2d59866331882f402b8c49056dc0 0xea5755ffba14683853f1e212f2aeca928be4815e0 ETH
0x9810ad06362b78c738357a85819409addd7d752984d3bb68f927097c0dc95dd3104120292022-04-23 17:08:36223 days 7 hrs ago 0xba3269e784c087c2c427c62499b5badca6775dcd 0xea5755ffba14683853f1e212f2aeca928be4815e0 ETH
0xba5d511e873b44b5bea60e8bdc22625ce59c0b80c17a649951738539c3ff4c3e104120252022-04-23 17:08:36223 days 7 hrs ago 0x41f0ae7750db8280439473a81ddb6f3aa4a15112 0xea5755ffba14683853f1e212f2aeca928be4815e0 ETH
0x659820ba43b66ba7aaef0c9991bf2251f6e9621cb0a4b070b2ef906922843f36104120132022-04-23 17:08:36223 days 7 hrs ago 0xa31a661fa0247e04499291c98c57ca23dc2d26db 0xea5755ffba14683853f1e212f2aeca928be4815e0 ETH
0x3630b35a46b6f5af043ade7f2bd3d014af090a57e1fc340c7dbe07cf2522fece104120032022-04-23 17:07:23223 days 7 hrs ago 0x41f0ae7750db8280439473a81ddb6f3aa4a15112 0xea5755ffba14683853f1e212f2aeca928be4815e0 ETH
0xa8cfd73b4299a32032e10f177f5ce1b858f5d7575bf4fd25b8e4c58c2cbd5aad104120022022-04-23 17:07:23223 days 7 hrs ago 0x050ee024a0ffd8b9bd383271835b27dd66c3fec3 0xea5755ffba14683853f1e212f2aeca928be4815e0 ETH
0x2c4c67e2523cafb817f7f53a89b0824dadb83823ccc988cdcfddbfdcb1f6db26104119872022-04-23 17:07:23223 days 7 hrs ago 0x9441e690788b01b660e8d00eb09f007fe8c84b71 0xea5755ffba14683853f1e212f2aeca928be4815e0 ETH
0x70c8ba7f7d9c292368ce8d9be16b8a913e9b615304519ef18847169519b74598104119552022-04-23 17:07:23223 days 7 hrs ago 0x050ee024a0ffd8b9bd383271835b27dd66c3fec3 0xea5755ffba14683853f1e212f2aeca928be4815e0 ETH
0xf3fc9daae8cab7946ce9c59bf8c209f3ebad3a1d5975b0912fb46673457e1bc4104119302022-04-23 17:06:05223 days 7 hrs ago 0x41f0ae7750db8280439473a81ddb6f3aa4a15112 0xea5755ffba14683853f1e212f2aeca928be4815e0 ETH
0xc48c5864374fe0c3f0734b21ca3b3392d317cbc451407dc71300b8af692e0f51104119252022-04-23 17:06:05223 days 7 hrs ago 0x32f9e0cebec2a3ef03f337acd0e6560da8ec07c0 0xea5755ffba14683853f1e212f2aeca928be4815e0 ETH
0xf11b04fe5a5f0ca1941ecb1b3cb537c20366350cd16d0b4ba155d57d52ae683a104118682022-04-23 17:06:05223 days 7 hrs ago 0xf3d9e75ac237d06ab034aebcf0046864ca57cafd 0xea5755ffba14683853f1e212f2aeca928be4815e0 ETH
0x0cc7a0c45821460d13e98517485ed7ced3f646d3e31bff8da0f30b94c26c4830104116822022-04-23 17:01:42223 days 7 hrs ago 0x40b6a6321c52ad83631259a651283e4eaf942023 0xea5755ffba14683853f1e212f2aeca928be4815e0 ETH
0x2044b6d0a8974a6577f6856afe2193859f91bf80280a454963a9777462e9bbcf104115012022-04-23 16:58:07223 days 7 hrs ago 0x98755fcf2203e2a4c93e138c30b24c2fa138cd71 0xea5755ffba14683853f1e212f2aeca928be4815e0 ETH
0xa237640793dfa36efac45320a3eac3d7569cf4e8b15c54616ab3d618a9289f1f104114472022-04-23 16:56:49223 days 7 hrs ago 0x98755fcf2203e2a4c93e138c30b24c2fa138cd71 0xea5755ffba14683853f1e212f2aeca928be4815e0 ETH
0x57266909276e8ee9bbd0dd3923911204aaddb1065581e0827802cc44e936a355104114252022-04-23 16:56:19223 days 7 hrs ago 0x879253b5cc2b13bb976e075f0571f85454a315f6 0xea5755ffba14683853f1e212f2aeca928be4815e0 ETH
0x26aedb878add017ca7f9a0b4f8e0edbdda45912a9abe18fcb8cd2421b797cc16104114092022-04-23 16:56:19223 days 7 hrs ago 0x879253b5cc2b13bb976e075f0571f85454a315f6 0xea5755ffba14683853f1e212f2aeca928be4815e0 ETH
0xc30e512321a4d93eac96f5f0e8db879e4c834996b96349cff7ef2be067b06596104113972022-04-23 16:56:19223 days 7 hrs ago 0xd4709d4a50cb35bcffab498f355cbdb3dbd1270e 0xea5755ffba14683853f1e212f2aeca928be4815e0 ETH
0x7e3168ff30bf13b31adbd67c73a27020a9194e3ea081f24c917f44c6eae19ca2104113662022-04-23 16:54:32223 days 7 hrs ago 0xd4709d4a50cb35bcffab498f355cbdb3dbd1270e 0xea5755ffba14683853f1e212f2aeca928be4815e0 ETH
[ Download CSV Export 
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
SmolFarm

Compiler Version
v0.8.9+commit.e5eed63a

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 25 : SmolFarm.sol
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC1155/extensions/ERC1155BurnableUpgradeable.sol";

import "./ISmolFarm.sol";
import "./SmolFarmContracts.sol";

contract SmolFarm is Initializable, ISmolFarm, SmolFarmContracts {

    using EnumerableSetUpgradeable for EnumerableSetUpgradeable.UintSet;

    function initialize() external initializer {
        SmolFarmContracts.__SmolFarmContracts_init();
    }

    function setRewards(
        uint256[] calldata _rewardIds,
        uint32[] calldata _rewardOdds)
    external
    onlyAdminOrOwner
    nonZeroLength(_rewardIds)
    {
        require(_rewardIds.length == _rewardOdds.length, "Bad lengths");

        delete rewardOptions;

        uint32 _totalOdds;
        for(uint256 i = 0; i < _rewardIds.length; i++) {
            _totalOdds += _rewardOdds[i];

            rewardOptions.push(_rewardIds[i]);
            rewardIdToOdds[_rewardIds[i]] = _rewardOdds[i];
        }

        require(_totalOdds == 100000, "Bad total odds");
    }

    function stakeSmol(
        uint256[] calldata _brainsTokens,
        uint256[] calldata _bodiesTokens)
    external
    onlyEOA
    contractsAreSet
    whenNotPaused
    {
        require(_brainsTokens.length > 0 || _bodiesTokens.length > 0, "no tokens given");
        for(uint256 i = 0; i < _brainsTokens.length; i++) {
            _stakeSmol(smolBrains, _brainsTokens[i]);
        }
        for(uint256 i = 0; i < _bodiesTokens.length; i++) {
            _stakeSmol(smolBodies, _bodiesTokens[i]);
        }
    }

    function _stakeSmol(IERC721 smol, uint256 _tokenId) private {
        userToTokensStaked[address(smol)][msg.sender].add(_tokenId);

        tokenIdToStakeStartTime[address(smol)][_tokenId] = block.timestamp;

        emit SmolStaked(msg.sender, address(smol), _tokenId, block.timestamp);

        // will revert if user does not own token
        smol.safeTransferFrom(msg.sender, address(this), _tokenId);
    }

    function unstakeSmol(
        uint256[] calldata _brainsTokens,
        uint256[] calldata _bodiesTokens)
    external
    onlyEOA
    contractsAreSet
    whenNotPaused
    {
        require(_brainsTokens.length > 0 || _bodiesTokens.length > 0, "no tokens given");
        for(uint256 i = 0; i < _brainsTokens.length; i++) {
            _unstakeSmol(smolBrains, _brainsTokens[i]);
        }
        for(uint256 i = 0; i < _bodiesTokens.length; i++) {
            _unstakeSmol(smolBodies, _bodiesTokens[i]);
        }
    }

    function _unstakeSmol(IERC721 smol, uint256 _tokenId) private {
        require(userToTokensStaked[address(smol)][msg.sender].contains(_tokenId), "Not owned by user");
        require(tokenIdToRequestId[address(smol)][_tokenId] == 0, "Claim in progress");
        require(numberOfRewardsToClaim(address(smol), _tokenId) == 0, "Rewards left unclaimed!");

        userToTokensStaked[address(smol)][msg.sender].remove(_tokenId);

        delete tokenIdToStakeStartTime[address(smol)][_tokenId];
        delete tokenIdToRewardsClaimed[address(smol)][_tokenId];

        emit SmolUnstaked(msg.sender, address(smol), _tokenId);

        smol.safeTransferFrom(address(this), msg.sender, _tokenId);
    }

    function startClaimingRewards(
        uint256[] calldata _brainsTokens,
        uint256[] calldata _bodiesTokens)
    external
    onlyEOA
    contractsAreSet
    whenNotPaused
    {
        require(_brainsTokens.length > 0 || _bodiesTokens.length > 0, "no tokens given");
        for(uint256 i = 0; i < _brainsTokens.length; i++) {
           _startClaimingReward(smolBrains, _brainsTokens[i]);
        }
        for(uint256 i = 0; i < _bodiesTokens.length; i++) {
           _startClaimingReward(smolBodies, _bodiesTokens[i]);
        }
    }

    function _startClaimingReward(IERC721 smol, uint256 _tokenId) private {
        require(userToTokensStaked[address(smol)][msg.sender].contains(_tokenId), "Not owned by user");
        require(tokenIdToRequestId[address(smol)][_tokenId] == 0, "Claim in progress");

        uint256 _numberToClaim = numberOfRewardsToClaim(address(smol), _tokenId);
        require(_numberToClaim > 0, "No rewards to claim");

        tokenIdToRewardsClaimed[address(smol)][_tokenId] += _numberToClaim;
        tokenIdToRewardsInProgress[address(smol)][_tokenId] = _numberToClaim;

        uint256 _requestId = randomizer.requestRandomNumber();
        tokenIdToRequestId[address(smol)][_tokenId] = _requestId;

        emit StartClaiming(msg.sender, address(smol), _tokenId, _requestId, _numberToClaim);
    }

    function finishClaimingRewards(
        uint256[] calldata _brainsTokens,
        uint256[] calldata _bodiesTokens)
    external
    onlyEOA
    contractsAreSet
    whenNotPaused
    {
        require(_brainsTokens.length > 0 || _bodiesTokens.length > 0, "no tokens given");
        for(uint256 i = 0; i < _brainsTokens.length; i++) {
           _finishClaimingReward(smolBrains, _brainsTokens[i]);
        }
        for(uint256 i = 0; i < _bodiesTokens.length; i++) {
           _finishClaimingReward(smolBodies, _bodiesTokens[i]);
        }
    }

    function _finishClaimingReward(IERC721 smol, uint256 _tokenId) private {
        require(userToTokensStaked[address(smol)][msg.sender].contains(_tokenId), "Not owned by user");
        require(rewardOptions.length > 0, "Rewards not setup");

        uint256 _requestId = tokenIdToRequestId[address(smol)][_tokenId];
        require(_requestId != 0, "No claim in progress");

        require(randomizer.isRandomReady(_requestId), "Random not ready");

        uint256 _randomNumber = randomizer.revealRandomNumber(_requestId);

        uint256 _numberToClaim = tokenIdToRewardsInProgress[address(smol)][_tokenId];

        for(uint256 i = 0; i < _numberToClaim; i++) {
            if(i != 0) {
                _randomNumber = uint256(keccak256(abi.encode(_randomNumber, i)));
            }

            _claimReward(smol, _tokenId, _randomNumber);
        }

        delete tokenIdToRewardsInProgress[address(smol)][_tokenId];
        delete tokenIdToRequestId[address(smol)][_tokenId];
    }

    function _claimReward(IERC721 smol, uint256 _tokenId, uint256 _randomNumber) private {
        uint256 _rewardResult = _randomNumber % 100000;

        uint256 _topRange = 0;
        uint256 _claimedRewardId = 0;
        for(uint256 i = 0; i < rewardOptions.length; i++) {
            uint256 _rewardId = rewardOptions[i];
            _topRange += rewardIdToOdds[_rewardId];
            if(_rewardResult < _topRange) {
                _claimedRewardId = _rewardId;

                treasures.mint(msg.sender, _claimedRewardId, 1);

                break;
            }
        }

        emit RewardClaimed(msg.sender, address(smol), _tokenId, _claimedRewardId, 1);
    }

    function numberOfRewardsToClaim(address smolAddress, uint256 _tokenId) public view returns(uint256) {
        if(tokenIdToStakeStartTime[smolAddress][_tokenId] == 0) {
            return 0;
        }

        uint256 _timeForCalculation = tokenIdToStakeStartTime[smolAddress][_tokenId] + (tokenIdToRewardsClaimed[smolAddress][_tokenId] * _timeForReward);
        uint256 rewardTime = block.timestamp;

        // End of farm emissions has passed, no longer provide emissions after that end time.
        if(_endEmissionTime > 0 && _endEmissionTime < block.timestamp) {
            rewardTime = _endEmissionTime;
        }

        return (rewardTime - _timeForCalculation) / _timeForReward;
    }

    function setTimeForReward(uint256 _rewardTime) external onlyAdminOrOwner {
        _timeForReward = _rewardTime;
    }

    function setEndTimeForEmissions(uint256 _endTime) external onlyAdminOrOwner {
        _endEmissionTime = _endTime;
    }

    function ownsToken(address _collection, address _owner, uint256 _tokenId) external view returns (bool) {
        return userToTokensStaked[_collection][_owner].contains(_tokenId);
    }

    function tokensOfOwner(address _collection, address _owner) external view returns (uint256[] memory) { 
        return userToTokensStaked[_collection][_owner].values();
    }

}

File 2 of 25 : Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/utils/Initializable.sol)

pragma solidity ^0.8.0;

import "../../utils/AddressUpgradeable.sol";

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
 *
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 *
 * [CAUTION]
 * ====
 * Avoid leaving a contract uninitialized.
 *
 * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
 * contract, which may impact the proxy. To initialize the implementation contract, you can either invoke the
 * initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * /// @custom:oz-upgrades-unsafe-allow constructor
 * constructor() initializer {}
 * ```
 * ====
 */
abstract contract Initializable {
    /**
     * @dev Indicates that the contract has been initialized.
     */
    bool private _initialized;

    /**
     * @dev Indicates that the contract is in the process of being initialized.
     */
    bool private _initializing;

    /**
     * @dev Modifier to protect an initializer function from being invoked twice.
     */
    modifier initializer() {
        // If the contract is initializing we ignore whether _initialized is set in order to support multiple
        // inheritance patterns, but we only do this in the context of a constructor, because in other contexts the
        // contract may have been reentered.
        require(_initializing ? _isConstructor() : !_initialized, "Initializable: contract is already initialized");

        bool isTopLevelCall = !_initializing;
        if (isTopLevelCall) {
            _initializing = true;
            _initialized = true;
        }

        _;

        if (isTopLevelCall) {
            _initializing = false;
        }
    }

    /**
     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
     * {initializer} modifier, directly or indirectly.
     */
    modifier onlyInitializing() {
        require(_initializing, "Initializable: contract is not initializing");
        _;
    }

    function _isConstructor() private view returns (bool) {
        return !AddressUpgradeable.isContract(address(this));
    }
}

File 3 of 25 : ERC1155BurnableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC1155/extensions/ERC1155Burnable.sol)

pragma solidity ^0.8.0;

import "../ERC1155Upgradeable.sol";
import "../../../proxy/utils/Initializable.sol";

/**
 * @dev Extension of {ERC1155} that allows token holders to destroy both their
 * own tokens and those that they have been approved to use.
 *
 * _Available since v3.1._
 */
abstract contract ERC1155BurnableUpgradeable is Initializable, ERC1155Upgradeable {
    function __ERC1155Burnable_init() internal onlyInitializing {
        __Context_init_unchained();
        __ERC165_init_unchained();
        __ERC1155Burnable_init_unchained();
    }

    function __ERC1155Burnable_init_unchained() internal onlyInitializing {
    }
    function burn(
        address account,
        uint256 id,
        uint256 value
    ) public virtual {
        require(
            account == _msgSender() || isApprovedForAll(account, _msgSender()),
            "ERC1155: caller is not owner nor approved"
        );

        _burn(account, id, value);
    }

    function burnBatch(
        address account,
        uint256[] memory ids,
        uint256[] memory values
    ) public virtual {
        require(
            account == _msgSender() || isApprovedForAll(account, _msgSender()),
            "ERC1155: caller is not owner nor approved"
        );

        _burnBatch(account, ids, values);
    }
    uint256[50] private __gap;
}

File 4 of 25 : ISmolFarm.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;


interface ISmolFarm {
}

File 5 of 25 : SmolFarmContracts.sol
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";

import "./SmolFarmState.sol";

abstract contract SmolFarmContracts is Initializable, SmolFarmState {

    function __SmolFarmContracts_init() internal initializer {
        SmolFarmState.__SmolFarmState_init();
    }

    function setContracts(
        address _treasures,
        address _smolBrains,
        address _smolBodies,
        address _smolLand,
        address _randomizer)
    external onlyAdminOrOwner
    {
        treasures = ISmolTreasures(_treasures);
        smolBrains = IERC721(_smolBrains);
        smolBodies = IERC721(_smolBodies);
        smolLand = IERC721(_smolLand);
        randomizer = IRandomizer(_randomizer);
    }

    modifier contractsAreSet() {
        require(address(treasures) != address(0)
            && address(randomizer) != address(0)
            && address(smolBrains) != address(0)
            && address(smolBodies) != address(0)
            && address(smolLand) != address(0), "Contracts aren't set");

        _;
    }
}

File 6 of 25 : AddressUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Address.sol)

pragma solidity ^0.8.0;

/**
 * @dev Collection of functions related to the address type
 */
library AddressUpgradeable {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

        uint256 size;
        assembly {
            size := extcodesize(account)
        }
        return size > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCall(target, data, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        require(isContract(target), "Address: call to non-contract");

        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        require(isContract(target), "Address: static call to non-contract");

        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

File 7 of 25 : ERC1155Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC1155/ERC1155.sol)

pragma solidity ^0.8.0;

import "./IERC1155Upgradeable.sol";
import "./IERC1155ReceiverUpgradeable.sol";
import "./extensions/IERC1155MetadataURIUpgradeable.sol";
import "../../utils/AddressUpgradeable.sol";
import "../../utils/ContextUpgradeable.sol";
import "../../utils/introspection/ERC165Upgradeable.sol";
import "../../proxy/utils/Initializable.sol";

/**
 * @dev Implementation of the basic standard multi-token.
 * See https://eips.ethereum.org/EIPS/eip-1155
 * Originally based on code by Enjin: https://github.com/enjin/erc-1155
 *
 * _Available since v3.1._
 */
contract ERC1155Upgradeable is Initializable, ContextUpgradeable, ERC165Upgradeable, IERC1155Upgradeable, IERC1155MetadataURIUpgradeable {
    using AddressUpgradeable for address;

    // Mapping from token ID to account balances
    mapping(uint256 => mapping(address => uint256)) private _balances;

    // Mapping from account to operator approvals
    mapping(address => mapping(address => bool)) private _operatorApprovals;

    // Used as the URI for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.json
    string private _uri;

    /**
     * @dev See {_setURI}.
     */
    function __ERC1155_init(string memory uri_) internal onlyInitializing {
        __Context_init_unchained();
        __ERC165_init_unchained();
        __ERC1155_init_unchained(uri_);
    }

    function __ERC1155_init_unchained(string memory uri_) internal onlyInitializing {
        _setURI(uri_);
    }

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165Upgradeable, IERC165Upgradeable) returns (bool) {
        return
            interfaceId == type(IERC1155Upgradeable).interfaceId ||
            interfaceId == type(IERC1155MetadataURIUpgradeable).interfaceId ||
            super.supportsInterface(interfaceId);
    }

    /**
     * @dev See {IERC1155MetadataURI-uri}.
     *
     * This implementation returns the same URI for *all* token types. It relies
     * on the token type ID substitution mechanism
     * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP].
     *
     * Clients calling this function must replace the `\{id\}` substring with the
     * actual token type ID.
     */
    function uri(uint256) public view virtual override returns (string memory) {
        return _uri;
    }

    /**
     * @dev See {IERC1155-balanceOf}.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     */
    function balanceOf(address account, uint256 id) public view virtual override returns (uint256) {
        require(account != address(0), "ERC1155: balance query for the zero address");
        return _balances[id][account];
    }

    /**
     * @dev See {IERC1155-balanceOfBatch}.
     *
     * Requirements:
     *
     * - `accounts` and `ids` must have the same length.
     */
    function balanceOfBatch(address[] memory accounts, uint256[] memory ids)
        public
        view
        virtual
        override
        returns (uint256[] memory)
    {
        require(accounts.length == ids.length, "ERC1155: accounts and ids length mismatch");

        uint256[] memory batchBalances = new uint256[](accounts.length);

        for (uint256 i = 0; i < accounts.length; ++i) {
            batchBalances[i] = balanceOf(accounts[i], ids[i]);
        }

        return batchBalances;
    }

    /**
     * @dev See {IERC1155-setApprovalForAll}.
     */
    function setApprovalForAll(address operator, bool approved) public virtual override {
        _setApprovalForAll(_msgSender(), operator, approved);
    }

    /**
     * @dev See {IERC1155-isApprovedForAll}.
     */
    function isApprovedForAll(address account, address operator) public view virtual override returns (bool) {
        return _operatorApprovals[account][operator];
    }

    /**
     * @dev See {IERC1155-safeTransferFrom}.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 id,
        uint256 amount,
        bytes memory data
    ) public virtual override {
        require(
            from == _msgSender() || isApprovedForAll(from, _msgSender()),
            "ERC1155: caller is not owner nor approved"
        );
        _safeTransferFrom(from, to, id, amount, data);
    }

    /**
     * @dev See {IERC1155-safeBatchTransferFrom}.
     */
    function safeBatchTransferFrom(
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) public virtual override {
        require(
            from == _msgSender() || isApprovedForAll(from, _msgSender()),
            "ERC1155: transfer caller is not owner nor approved"
        );
        _safeBatchTransferFrom(from, to, ids, amounts, data);
    }

    /**
     * @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - `from` must have a balance of tokens of type `id` of at least `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 amount,
        bytes memory data
    ) internal virtual {
        require(to != address(0), "ERC1155: transfer to the zero address");

        address operator = _msgSender();

        _beforeTokenTransfer(operator, from, to, _asSingletonArray(id), _asSingletonArray(amount), data);

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

        emit TransferSingle(operator, from, to, id, amount);

        _doSafeTransferAcceptanceCheck(operator, from, to, id, amount, data);
    }

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_safeTransferFrom}.
     *
     * Emits a {TransferBatch} event.
     *
     * Requirements:
     *
     * - 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[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) internal virtual {
        require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
        require(to != address(0), "ERC1155: transfer to the zero address");

        address operator = _msgSender();

        _beforeTokenTransfer(operator, from, to, ids, amounts, data);

        for (uint256 i = 0; i < ids.length; ++i) {
            uint256 id = ids[i];
            uint256 amount = amounts[i];

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

        emit TransferBatch(operator, from, to, ids, amounts);

        _doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, amounts, data);
    }

    /**
     * @dev Sets a new URI for all token types, by relying on the token type ID
     * substitution mechanism
     * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP].
     *
     * By this mechanism, any occurrence of the `\{id\}` substring in either the
     * URI or any of the amounts in the JSON file at said URI will be replaced by
     * clients with the token type ID.
     *
     * For example, the `https://token-cdn-domain/\{id\}.json` URI would be
     * interpreted by clients as
     * `https://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json`
     * for token type ID 0x4cce0.
     *
     * See {uri}.
     *
     * Because these URIs cannot be meaningfully represented by the {URI} event,
     * this function emits no events.
     */
    function _setURI(string memory newuri) internal virtual {
        _uri = newuri;
    }

    /**
     * @dev Creates `amount` tokens of token type `id`, and assigns them to `to`.
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
     * acceptance magic value.
     */
    function _mint(
        address to,
        uint256 id,
        uint256 amount,
        bytes memory data
    ) internal virtual {
        require(to != address(0), "ERC1155: mint to the zero address");

        address operator = _msgSender();

        _beforeTokenTransfer(operator, address(0), to, _asSingletonArray(id), _asSingletonArray(amount), data);

        _balances[id][to] += amount;
        emit TransferSingle(operator, address(0), to, id, amount);

        _doSafeTransferAcceptanceCheck(operator, address(0), to, id, amount, data);
    }

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_mint}.
     *
     * Requirements:
     *
     * - `ids` and `amounts` must have the same length.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
     * acceptance magic value.
     */
    function _mintBatch(
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) internal virtual {
        require(to != address(0), "ERC1155: mint to the zero address");
        require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");

        address operator = _msgSender();

        _beforeTokenTransfer(operator, address(0), to, ids, amounts, data);

        for (uint256 i = 0; i < ids.length; i++) {
            _balances[ids[i]][to] += amounts[i];
        }

        emit TransferBatch(operator, address(0), to, ids, amounts);

        _doSafeBatchTransferAcceptanceCheck(operator, address(0), to, ids, amounts, data);
    }

    /**
     * @dev Destroys `amount` tokens of token type `id` from `from`
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `from` must have at least `amount` tokens of token type `id`.
     */
    function _burn(
        address from,
        uint256 id,
        uint256 amount
    ) internal virtual {
        require(from != address(0), "ERC1155: burn from the zero address");

        address operator = _msgSender();

        _beforeTokenTransfer(operator, from, address(0), _asSingletonArray(id), _asSingletonArray(amount), "");

        uint256 fromBalance = _balances[id][from];
        require(fromBalance >= amount, "ERC1155: burn amount exceeds balance");
        unchecked {
            _balances[id][from] = fromBalance - amount;
        }

        emit TransferSingle(operator, from, address(0), id, amount);
    }

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}.
     *
     * Requirements:
     *
     * - `ids` and `amounts` must have the same length.
     */
    function _burnBatch(
        address from,
        uint256[] memory ids,
        uint256[] memory amounts
    ) internal virtual {
        require(from != address(0), "ERC1155: burn from the zero address");
        require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");

        address operator = _msgSender();

        _beforeTokenTransfer(operator, from, address(0), ids, amounts, "");

        for (uint256 i = 0; i < ids.length; i++) {
            uint256 id = ids[i];
            uint256 amount = amounts[i];

            uint256 fromBalance = _balances[id][from];
            require(fromBalance >= amount, "ERC1155: burn amount exceeds balance");
            unchecked {
                _balances[id][from] = fromBalance - amount;
            }
        }

        emit TransferBatch(operator, from, address(0), ids, amounts);
    }

    /**
     * @dev Approve `operator` to operate on all of `owner` tokens
     *
     * Emits a {ApprovalForAll} event.
     */
    function _setApprovalForAll(
        address owner,
        address operator,
        bool approved
    ) internal virtual {
        require(owner != operator, "ERC1155: setting approval status for self");
        _operatorApprovals[owner][operator] = approved;
        emit ApprovalForAll(owner, operator, approved);
    }

    /**
     * @dev Hook that is called before any token transfer. This includes minting
     * and burning, as well as batched variants.
     *
     * The same hook is called on both single and batched variants. For single
     * transfers, the length of the `id` and `amount` arrays will be 1.
     *
     * Calling conditions (for each `id` and `amount` pair):
     *
     * - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * of token type `id` will be  transferred to `to`.
     * - When `from` is zero, `amount` tokens of token type `id` will be minted
     * for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens of token type `id`
     * will be burned.
     * - `from` and `to` are never both zero.
     * - `ids` and `amounts` have the same, non-zero length.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(
        address operator,
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) internal virtual {}

    function _doSafeTransferAcceptanceCheck(
        address operator,
        address from,
        address to,
        uint256 id,
        uint256 amount,
        bytes memory data
    ) private {
        if (to.isContract()) {
            try IERC1155ReceiverUpgradeable(to).onERC1155Received(operator, from, id, amount, data) returns (bytes4 response) {
                if (response != IERC1155ReceiverUpgradeable.onERC1155Received.selector) {
                    revert("ERC1155: ERC1155Receiver rejected tokens");
                }
            } catch Error(string memory reason) {
                revert(reason);
            } catch {
                revert("ERC1155: transfer to non ERC1155Receiver implementer");
            }
        }
    }

    function _doSafeBatchTransferAcceptanceCheck(
        address operator,
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) private {
        if (to.isContract()) {
            try IERC1155ReceiverUpgradeable(to).onERC1155BatchReceived(operator, from, ids, amounts, data) returns (
                bytes4 response
            ) {
                if (response != IERC1155ReceiverUpgradeable.onERC1155BatchReceived.selector) {
                    revert("ERC1155: ERC1155Receiver rejected tokens");
                }
            } catch Error(string memory reason) {
                revert(reason);
            } catch {
                revert("ERC1155: transfer to non ERC1155Receiver implementer");
            }
        }
    }

    function _asSingletonArray(uint256 element) private pure returns (uint256[] memory) {
        uint256[] memory array = new uint256[](1);
        array[0] = element;

        return array;
    }
    uint256[47] private __gap;
}

File 8 of 25 : IERC1155Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC1155/IERC1155.sol)

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165Upgradeable.sol";

/**
 * @dev Required interface of an ERC1155 compliant contract, as defined in the
 * https://eips.ethereum.org/EIPS/eip-1155[EIP].
 *
 * _Available since v3.1._
 */
interface IERC1155Upgradeable is IERC165Upgradeable {
    /**
     * @dev Emitted when `value` tokens of token 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 amount 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 `amount` tokens of token type `id` from `from` to `to`.
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - If the caller is not `from`, it must be have been approved to spend ``from``'s tokens via {setApprovalForAll}.
     * - `from` must have a balance of tokens of type `id` of at least `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 amount,
        bytes calldata data
    ) external;

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
     *
     * Emits a {TransferBatch} event.
     *
     * Requirements:
     *
     * - `ids` and `amounts` 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 amounts,
        bytes calldata data
    ) external;
}

File 9 of 25 : IERC1155ReceiverUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC1155/IERC1155Receiver.sol)

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165Upgradeable.sol";

/**
 * @dev _Available since v3.1._
 */
interface IERC1155ReceiverUpgradeable is IERC165Upgradeable {
    /**
        @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.
        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. 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);
}

File 10 of 25 : IERC1155MetadataURIUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC1155/extensions/IERC1155MetadataURI.sol)

pragma solidity ^0.8.0;

import "../IERC1155Upgradeable.sol";

/**
 * @dev Interface of the optional ERC1155MetadataExtension interface, as defined
 * in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[EIP].
 *
 * _Available since v3.1._
 */
interface IERC1155MetadataURIUpgradeable is IERC1155Upgradeable {
    /**
     * @dev Returns the URI for token type `id`.
     *
     * If the `\{id\}` substring is present in the URI, it must be replaced by
     * clients with the actual token type ID.
     */
    function uri(uint256 id) external view returns (string memory);
}

File 11 of 25 : ContextUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";

/**
 * @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 ContextUpgradeable is Initializable {
    function __Context_init() internal onlyInitializing {
        __Context_init_unchained();
    }

    function __Context_init_unchained() internal onlyInitializing {
    }
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
    uint256[50] private __gap;
}

File 12 of 25 : ERC165Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)

pragma solidity ^0.8.0;

import "./IERC165Upgradeable.sol";
import "../../proxy/utils/Initializable.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);
 * }
 * ```
 *
 * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
 */
abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable {
    function __ERC165_init() internal onlyInitializing {
        __ERC165_init_unchained();
    }

    function __ERC165_init_unchained() internal onlyInitializing {
    }
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IERC165Upgradeable).interfaceId;
    }
    uint256[50] private __gap;
}

File 13 of 25 : IERC165Upgradeable.sol
// 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 IERC165Upgradeable {
    /**
     * @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);
}

File 14 of 25 : SmolFarmState.sol
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC721/utils/ERC721HolderUpgradeable.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";

import "../../shared/AdminableUpgradeable.sol";
import "../../shared/randomizer/IRandomizer.sol";
import "../treasures/ISmolTreasures.sol";

abstract contract SmolFarmState is
    Initializable,
    AdminableUpgradeable,
    ERC721HolderUpgradeable
{
    event SmolStaked(
        address indexed _owner,
        address indexed _smolAddress,
        uint256 indexed _tokenId,
        uint256 _stakeTime
    );
    event SmolUnstaked(address indexed _owner, address indexed _smolAddress, uint256 indexed _tokenId);

    event StartClaiming(
        address indexed _owner,
        address indexed _smolAddress,
        uint256 indexed _tokenId,
        uint256 _requestId,
        uint256 _numberRewards
    );
    event RewardClaimed(
        address indexed _owner,
        address indexed _smolAddress,
        uint256 indexed _tokenId,
        uint256 _claimedRewardId,
        uint256 _amount
    );

    ISmolTreasures public treasures;
    IRandomizer public randomizer;
    IERC721 public smolBrains;
    IERC721 public smolBodies;
    IERC721 public smolLand;

    // collection address -> user address -> tokens staked for collection
    mapping(address => mapping(address => EnumerableSetUpgradeable.UintSet)) internal userToTokensStaked;

    // collection address -> tokenId -> info
    mapping(address => mapping(uint256 => uint256)) public tokenIdToStakeStartTime;
    mapping(address => mapping(uint256 => uint256)) public tokenIdToRewardsClaimed;
    mapping(address => mapping(uint256 => uint256)) public tokenIdToRequestId;
    mapping(address => mapping(uint256 => uint256)) public tokenIdToRewardsInProgress;

    uint256[] public rewardOptions;
    // Odds out of 100,000
    mapping(uint256 => uint32) public rewardIdToOdds;

    uint256 public _timeForReward;

    uint256 public _endEmissionTime;

    function __SmolFarmState_init() internal initializer {
        AdminableUpgradeable.__Adminable_init();
        ERC721HolderUpgradeable.__ERC721Holder_init();

        _timeForReward = 1 days;
    }
}

File 15 of 25 : EnumerableSetUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/structs/EnumerableSet.sol)

pragma solidity ^0.8.0;

/**
 * @dev Library for managing
 * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
 * types.
 *
 * Sets have the following properties:
 *
 * - Elements are added, removed, and checked for existence in constant time
 * (O(1)).
 * - Elements are enumerated in O(n). No guarantees are made on the ordering.
 *
 * ```
 * contract Example {
 *     // Add the library methods
 *     using EnumerableSet for EnumerableSet.AddressSet;
 *
 *     // Declare a set state variable
 *     EnumerableSet.AddressSet private mySet;
 * }
 * ```
 *
 * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
 * and `uint256` (`UintSet`) are supported.
 */
library EnumerableSetUpgradeable {
    // To implement this library for multiple types with as little code
    // repetition as possible, we write it in terms of a generic Set type with
    // bytes32 values.
    // The Set implementation uses private functions, and user-facing
    // implementations (such as AddressSet) are just wrappers around the
    // underlying Set.
    // This means that we can only create new EnumerableSets for types that fit
    // in bytes32.

    struct Set {
        // Storage of set values
        bytes32[] _values;
        // Position of the value in the `values` array, plus 1 because index 0
        // means a value is not in the set.
        mapping(bytes32 => uint256) _indexes;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function _add(Set storage set, bytes32 value) private returns (bool) {
        if (!_contains(set, value)) {
            set._values.push(value);
            // The value is stored at length-1, but we add 1 to all indexes
            // and use 0 as a sentinel value
            set._indexes[value] = set._values.length;
            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function _remove(Set storage set, bytes32 value) private returns (bool) {
        // We read and store the value's index to prevent multiple reads from the same storage slot
        uint256 valueIndex = set._indexes[value];

        if (valueIndex != 0) {
            // Equivalent to contains(set, value)
            // To delete an element from the _values array in O(1), we swap the element to delete with the last one in
            // the array, and then remove the last element (sometimes called as 'swap and pop').
            // This modifies the order of the array, as noted in {at}.

            uint256 toDeleteIndex = valueIndex - 1;
            uint256 lastIndex = set._values.length - 1;

            if (lastIndex != toDeleteIndex) {
                bytes32 lastvalue = set._values[lastIndex];

                // Move the last value to the index where the value to delete is
                set._values[toDeleteIndex] = lastvalue;
                // Update the index for the moved value
                set._indexes[lastvalue] = valueIndex; // Replace lastvalue's index to valueIndex
            }

            // Delete the slot where the moved value was stored
            set._values.pop();

            // Delete the index for the deleted slot
            delete set._indexes[value];

            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function _contains(Set storage set, bytes32 value) private view returns (bool) {
        return set._indexes[value] != 0;
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function _length(Set storage set) private view returns (uint256) {
        return set._values.length;
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function _at(Set storage set, uint256 index) private view returns (bytes32) {
        return set._values[index];
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function _values(Set storage set) private view returns (bytes32[] memory) {
        return set._values;
    }

    // Bytes32Set

    struct Bytes32Set {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _add(set._inner, value);
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _remove(set._inner, value);
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
        return _contains(set._inner, value);
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(Bytes32Set storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
        return _at(set._inner, index);
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
        return _values(set._inner);
    }

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(AddressSet storage set, address value) internal returns (bool) {
        return _add(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(AddressSet storage set, address value) internal returns (bool) {
        return _remove(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(AddressSet storage set, address value) internal view returns (bool) {
        return _contains(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(AddressSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(AddressSet storage set, uint256 index) internal view returns (address) {
        return address(uint160(uint256(_at(set._inner, index))));
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(AddressSet storage set) internal view returns (address[] memory) {
        bytes32[] memory store = _values(set._inner);
        address[] memory result;

        assembly {
            result := store
        }

        return result;
    }

    // UintSet

    struct UintSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(UintSet storage set, uint256 value) internal returns (bool) {
        return _add(set._inner, bytes32(value));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(UintSet storage set, uint256 value) internal returns (bool) {
        return _remove(set._inner, bytes32(value));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(UintSet storage set, uint256 value) internal view returns (bool) {
        return _contains(set._inner, bytes32(value));
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function length(UintSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(UintSet storage set, uint256 index) internal view returns (uint256) {
        return uint256(_at(set._inner, index));
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(UintSet storage set) internal view returns (uint256[] memory) {
        bytes32[] memory store = _values(set._inner);
        uint256[] memory result;

        assembly {
            result := store
        }

        return result;
    }
}

File 16 of 25 : ERC721HolderUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/utils/ERC721Holder.sol)

pragma solidity ^0.8.0;

import "../IERC721ReceiverUpgradeable.sol";
import "../../../proxy/utils/Initializable.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 ERC721HolderUpgradeable is Initializable, IERC721ReceiverUpgradeable {
    function __ERC721Holder_init() internal onlyInitializing {
        __ERC721Holder_init_unchained();
    }

    function __ERC721Holder_init_unchained() internal onlyInitializing {
    }
    /**
     * @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;
    }
    uint256[50] private __gap;
}

File 17 of 25 : IERC721.sol
// 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;
}

File 18 of 25 : AdminableUpgradeable.sol
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";

import "./UtilitiesUpgradeable.sol";

// Do not add state to this contract.
//
contract AdminableUpgradeable is UtilitiesUpgradeable {

    mapping(address => bool) private admins;

    function __Adminable_init() internal initializer {
        UtilitiesUpgradeable.__Utilities__init();
    }

    function addAdmin(address _address) external onlyOwner {
        admins[_address] = true;
    }

    function addAdmins(address[] calldata _addresses) external onlyOwner {
        for(uint256 i = 0; i < _addresses.length; i++) {
            admins[_addresses[i]] = true;
        }
    }

    function removeAdmin(address _address) external onlyOwner {
        admins[_address] = false;
    }

    function removeAdmins(address[] calldata _addresses) external onlyOwner {
        for(uint256 i = 0; i < _addresses.length; i++) {
            admins[_addresses[i]] = false;
        }
    }

    function setPause(bool _shouldPause) external onlyAdminOrOwner {
        if(_shouldPause) {
            _pause();
        } else {
            _unpause();
        }
    }

    function isAdmin(address _address) public view returns(bool) {
        return admins[_address];
    }

    modifier onlyAdmin() {
        require(admins[msg.sender], "Not admin");
        _;
    }

    modifier onlyAdminOrOwner() {
        require(admins[msg.sender] || isOwner(), "Not admin or owner");
        _;
    }

    uint256[50] private __gap;
}

File 19 of 25 : IRandomizer.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface IRandomizer {

    // Sets the number of blocks that must pass between increment the commitId and seeding the random
    // Admin
    function setNumBlocksAfterIncrement(uint8 _numBlocksAfterIncrement) external;

    // Increments the commit id.
    // Admin
    function incrementCommitId() external;

    // Adding the random number needs to be done AFTER incrementing the commit id on a separate transaction. If
    // these are done together, there is a potential vulnerability to front load a commit when the bad actor
    // sees the value of the random number.
    function addRandomForCommit(uint256 _seed) external;

    // Returns a request ID for a random number. This is unique.
    function requestRandomNumber() external returns(uint256);

    // Returns the random number for the given request ID. Will revert
    // if the random is not ready.
    function revealRandomNumber(uint256 _requestId) external view returns(uint256);

    // Returns if the random number for the given request ID is ready or not. Call
    // before calling revealRandomNumber.
    function isRandomReady(uint256 _requestId) external view returns(bool);
}

File 20 of 25 : ISmolTreasures.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts-upgradeable/token/ERC1155/IERC1155Upgradeable.sol";

interface ISmolTreasures is IERC1155Upgradeable {

    function mint(address _to, uint256 _id, uint256 _amount) external;

    function burn(address account, uint256 id, uint256 value) external;

    function burnBatch(address account, uint256[] memory ids, uint256[] memory values) external;

    function adminSafeTransferFrom(address _from, address _to, uint256 _id, uint256 _amount) external;

    function adminSafeBatchTransferFrom(address _from, address _to, uint256[] calldata _ids, uint256[] calldata _amounts) external;
}

File 21 of 25 : IERC721ReceiverUpgradeable.sol
// 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 IERC721ReceiverUpgradeable {
    /**
     * @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);
}

File 22 of 25 : IERC165.sol
// 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);
}

File 23 of 25 : UtilitiesUpgradeable.sol
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";

contract UtilitiesUpgradeable is Initializable, OwnableUpgradeable, PausableUpgradeable {

    function __Utilities__init() internal initializer {
        OwnableUpgradeable.__Ownable_init();
        PausableUpgradeable.__Pausable_init();

        _pause();
    }

    modifier nonZeroAddress(address _address) {
        require(address(0) != _address, "0 address");
        _;
    }

    modifier nonZeroLength(uint[] memory _array) {
        require(_array.length > 0, "Empty array");
        _;
    }

    modifier lengthsAreEqual(uint[] memory _array1, uint[] memory _array2) {
        require(_array1.length == _array2.length, "Unequal lengths");
        _;
    }

    modifier onlyEOA() {
        /* solhint-disable avoid-tx-origin */
        require(msg.sender == tx.origin, "No contracts");
        _;
    }

    function isOwner() internal view returns(bool) {
        return owner() == msg.sender;
    }
}

File 24 of 25 : OwnableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)

pragma solidity ^0.8.0;

import "../utils/ContextUpgradeable.sol";
import "../proxy/utils/Initializable.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 OwnableUpgradeable is Initializable, ContextUpgradeable {
    address private _owner;

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

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    function __Ownable_init() internal onlyInitializing {
        __Context_init_unchained();
        __Ownable_init_unchained();
    }

    function __Ownable_init_unchained() internal onlyInitializing {
        _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);
    }
    uint256[49] private __gap;
}

File 25 of 25 : PausableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/Pausable.sol)

pragma solidity ^0.8.0;

import "../utils/ContextUpgradeable.sol";
import "../proxy/utils/Initializable.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 PausableUpgradeable is Initializable, ContextUpgradeable {
    /**
     * @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.
     */
    function __Pausable_init() internal onlyInitializing {
        __Context_init_unchained();
        __Pausable_init_unchained();
    }

    function __Pausable_init_unchained() internal onlyInitializing {
        _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());
    }
    uint256[49] private __gap;
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "libraries": {}
}

Contract ABI

[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_owner","type":"address"},{"indexed":true,"internalType":"address","name":"_smolAddress","type":"address"},{"indexed":true,"internalType":"uint256","name":"_tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_claimedRewardId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"RewardClaimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_owner","type":"address"},{"indexed":true,"internalType":"address","name":"_smolAddress","type":"address"},{"indexed":true,"internalType":"uint256","name":"_tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_stakeTime","type":"uint256"}],"name":"SmolStaked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_owner","type":"address"},{"indexed":true,"internalType":"address","name":"_smolAddress","type":"address"},{"indexed":true,"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"SmolUnstaked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_owner","type":"address"},{"indexed":true,"internalType":"address","name":"_smolAddress","type":"address"},{"indexed":true,"internalType":"uint256","name":"_tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_requestId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_numberRewards","type":"uint256"}],"name":"StartClaiming","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[],"name":"_endEmissionTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_timeForReward","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"}],"name":"addAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_addresses","type":"address[]"}],"name":"addAdmins","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_brainsTokens","type":"uint256[]"},{"internalType":"uint256[]","name":"_bodiesTokens","type":"uint256[]"}],"name":"finishClaimingRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"}],"name":"isAdmin","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"smolAddress","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"numberOfRewardsToClaim","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_collection","type":"address"},{"internalType":"address","name":"_owner","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"ownsToken","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"randomizer","outputs":[{"internalType":"contract IRandomizer","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"}],"name":"removeAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_addresses","type":"address[]"}],"name":"removeAdmins","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"rewardIdToOdds","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"rewardOptions","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_treasures","type":"address"},{"internalType":"address","name":"_smolBrains","type":"address"},{"internalType":"address","name":"_smolBodies","type":"address"},{"internalType":"address","name":"_smolLand","type":"address"},{"internalType":"address","name":"_randomizer","type":"address"}],"name":"setContracts","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_endTime","type":"uint256"}],"name":"setEndTimeForEmissions","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_shouldPause","type":"bool"}],"name":"setPause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_rewardIds","type":"uint256[]"},{"internalType":"uint32[]","name":"_rewardOdds","type":"uint32[]"}],"name":"setRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_rewardTime","type":"uint256"}],"name":"setTimeForReward","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"smolBodies","outputs":[{"internalType":"contract IERC721","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"smolBrains","outputs":[{"internalType":"contract IERC721","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"smolLand","outputs":[{"internalType":"contract IERC721","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_brainsTokens","type":"uint256[]"},{"internalType":"uint256[]","name":"_bodiesTokens","type":"uint256[]"}],"name":"stakeSmol","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_brainsTokens","type":"uint256[]"},{"internalType":"uint256[]","name":"_bodiesTokens","type":"uint256[]"}],"name":"startClaimingRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"tokenIdToRequestId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"tokenIdToRewardsClaimed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"tokenIdToRewardsInProgress","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"tokenIdToStakeStartTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_collection","type":"address"},{"internalType":"address","name":"_owner","type":"address"}],"name":"tokensOfOwner","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"treasures","outputs":[{"internalType":"contract ISmolTreasures","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_brainsTokens","type":"uint256[]"},{"internalType":"uint256[]","name":"_bodiesTokens","type":"uint256[]"}],"name":"unstakeSmol","outputs":[],"stateMutability":"nonpayable","type":"function"}]

608060405234801561001057600080fd5b50612ab2806100206000396000f3fe608060405234801561001057600080fd5b506004361061021c5760003560e01c8063907cf4be11610125578063cfe8f487116100ad578063ead657c71161007c578063ead657c714610538578063eb54d5c71461054b578063f10fb58414610577578063f2fde38b1461058a578063f63bf8bd1461059d57600080fd5b8063cfe8f487146104de578063d8447dad146104fe578063e0e3818e14610512578063eaafd1dd1461052557600080fd5b8063b64d309f116100f4578063b64d309f14610488578063bbf65ab71461049b578063bedb86fb146104ae578063c03f3670146104c1578063ccf63845146104d457600080fd5b8063907cf4be146104455780639b9580af1461044f5780639c54df6414610462578063a87e54701461047557600080fd5b8063377e11e0116101a8578063704802751161017757806370480275146103fe578063715018a6146104115780637bd6babb146104195780638129fc1c1461042c5780638da5cb5b1461043457600080fd5b8063377e11e0146103ba57806349a5572b146103cd5780635c975abb146103e0578063686dd20b146103eb57600080fd5b806319842fb5116101ef57806319842fb5146102e85780631f8238051461031457806324d7806c1461033f5780632b5f94bd1461037b57806335b3c18a146103a757600080fd5b8063030c4225146102215780630a5ff95a14610260578063150b7a021461029c5780631785f53c146102d3575b600080fd5b61024d61022f3660046123b6565b61010360209081526000928352604080842090915290825290205481565b6040519081526020015b60405180910390f35b61028761026e3660046123e0565b6101076020526000908152604090205463ffffffff1681565b60405163ffffffff9091168152602001610257565b6102ba6102aa36600461240f565b630a85bd0160e11b949350505050565b6040516001600160e01b03199091168152602001610257565b6102e66102e13660046124eb565b6105b0565b005b61024d6102f63660046123b6565b61010460209081526000928352604080842090915290825290205481565b60fc54610327906001600160a01b031681565b6040516001600160a01b039091168152602001610257565b61036b61034d3660046124eb565b6001600160a01b031660009081526097602052604090205460ff1690565b6040519015158152602001610257565b61024d6103893660046123b6565b61010260209081526000928352604080842090915290825290205481565b6102e66103b5366004612552565b610604565b6102e66103c83660046125be565b610784565b60fe54610327906001600160a01b031681565b60655460ff1661036b565b61024d6103f93660046123e0565b610825565b6102e661040c3660046124eb565b610847565b6102e6610895565b60ff54610327906001600160a01b031681565b6102e66108cb565b6033546001600160a01b0316610327565b61024d6101095481565b6102e661045d3660046123e0565b610945565b6102e66104703660046125be565b610988565b61024d6104833660046123b6565b610a24565b6102e6610496366004612552565b610aff565b6102e66104a9366004612552565b610c78565b6102e66104bc36600461260e565b610df1565b6102e66104cf366004612552565b610e44565b61024d6101085481565b6104f16104ec36600461262b565b610fbd565b604051610257919061265e565b61010054610327906001600160a01b031681565b6102e6610520366004612552565b610ff6565b61036b6105333660046126a2565b61123c565b6102e66105463660046123e0565b611276565b61024d6105593660046123b6565b61010560209081526000928352604080842090915290825290205481565b60fd54610327906001600160a01b031681565b6102e66105983660046124eb565b6112b9565b6102e66105ab3660046126de565b611351565b6033546001600160a01b031633146105e35760405162461bcd60e51b81526004016105da90612743565b60405180910390fd5b6001600160a01b03166000908152609760205260409020805460ff19169055565b3332146106235760405162461bcd60e51b81526004016105da90612778565b60fc546001600160a01b031615801590610647575060fd546001600160a01b031615155b801561065d575060fe546001600160a01b031615155b8015610673575060ff546001600160a01b031615155b801561068a5750610100546001600160a01b031615155b6106a65760405162461bcd60e51b81526004016105da9061279e565b60655460ff16156106c95760405162461bcd60e51b81526004016105da906127cc565b821515806106d657508015155b6106f25760405162461bcd60e51b81526004016105da906127f6565b60005b8381101561073d5760fe5461072b906001600160a01b031686868481811061071f5761071f61281f565b905060200201356113ee565b806107358161284b565b9150506106f5565b5060005b8181101561077d5760ff5461076b906001600160a01b031684848481811061071f5761071f61281f565b806107758161284b565b915050610741565b5050505050565b6033546001600160a01b031633146107ae5760405162461bcd60e51b81526004016105da90612743565b60005b81811015610820576000609760008585858181106107d1576107d161281f565b90506020020160208101906107e691906124eb565b6001600160a01b031681526020810191909152604001600020805460ff1916911515919091179055806108188161284b565b9150506107b1565b505050565b610106818154811061083657600080fd5b600091825260209091200154905081565b6033546001600160a01b031633146108715760405162461bcd60e51b81526004016105da90612743565b6001600160a01b03166000908152609760205260409020805460ff19166001179055565b6033546001600160a01b031633146108bf5760405162461bcd60e51b81526004016105da90612743565b6108c960006114df565b565b600054610100900460ff166108e65760005460ff16156108ea565b303b155b6109065760405162461bcd60e51b81526004016105da90612866565b600054610100900460ff16158015610928576000805461ffff19166101011790555b610930611531565b8015610942576000805461ff00191690555b50565b3360009081526097602052604090205460ff16806109665750610966611596565b6109825760405162461bcd60e51b81526004016105da906128b4565b61010955565b6033546001600160a01b031633146109b25760405162461bcd60e51b81526004016105da90612743565b60005b81811015610820576001609760008585858181106109d5576109d561281f565b90506020020160208101906109ea91906124eb565b6001600160a01b031681526020810191909152604001600020805460ff191691151591909117905580610a1c8161284b565b9150506109b5565b6001600160a01b038216600090815261010260209081526040808320848452909152812054610a5557506000610af9565b610108546001600160a01b0384166000908152610103602090815260408083208684529091528120549091610a89916128e0565b6001600160a01b038516600090815261010260209081526040808320878452909152902054610ab891906128ff565b61010954909150429015801590610ad157504261010954105b15610adc5750610109545b61010854610aea8383612917565b610af49190612944565b925050505b92915050565b333214610b1e5760405162461bcd60e51b81526004016105da90612778565b60fc546001600160a01b031615801590610b42575060fd546001600160a01b031615155b8015610b58575060fe546001600160a01b031615155b8015610b6e575060ff546001600160a01b031615155b8015610b855750610100546001600160a01b031615155b610ba15760405162461bcd60e51b81526004016105da9061279e565b60655460ff1615610bc45760405162461bcd60e51b81526004016105da906127cc565b82151580610bd157508015155b610bed5760405162461bcd60e51b81526004016105da906127f6565b60005b83811015610c385760fe54610c26906001600160a01b0316868684818110610c1a57610c1a61281f565b905060200201356115ba565b80610c308161284b565b915050610bf0565b5060005b8181101561077d5760ff54610c66906001600160a01b0316848484818110610c1a57610c1a61281f565b80610c708161284b565b915050610c3c565b333214610c975760405162461bcd60e51b81526004016105da90612778565b60fc546001600160a01b031615801590610cbb575060fd546001600160a01b031615155b8015610cd1575060fe546001600160a01b031615155b8015610ce7575060ff546001600160a01b031615155b8015610cfe5750610100546001600160a01b031615155b610d1a5760405162461bcd60e51b81526004016105da9061279e565b60655460ff1615610d3d5760405162461bcd60e51b81526004016105da906127cc565b82151580610d4a57508015155b610d665760405162461bcd60e51b81526004016105da906127f6565b60005b83811015610db15760fe54610d9f906001600160a01b0316868684818110610d9357610d9361281f565b905060200201356118b0565b80610da98161284b565b915050610d69565b5060005b8181101561077d5760ff54610ddf906001600160a01b0316848484818110610d9357610d9361281f565b80610de98161284b565b915050610db5565b3360009081526097602052604090205460ff1680610e125750610e12611596565b610e2e5760405162461bcd60e51b81526004016105da906128b4565b8015610e3c57610942611a87565b610942611afc565b333214610e635760405162461bcd60e51b81526004016105da90612778565b60fc546001600160a01b031615801590610e87575060fd546001600160a01b031615155b8015610e9d575060fe546001600160a01b031615155b8015610eb3575060ff546001600160a01b031615155b8015610eca5750610100546001600160a01b031615155b610ee65760405162461bcd60e51b81526004016105da9061279e565b60655460ff1615610f095760405162461bcd60e51b81526004016105da906127cc565b82151580610f1657508015155b610f325760405162461bcd60e51b81526004016105da906127f6565b60005b83811015610f7d5760fe54610f6b906001600160a01b0316868684818110610f5f57610f5f61281f565b90506020020135611b76565b80610f758161284b565b915050610f35565b5060005b8181101561077d5760ff54610fab906001600160a01b0316848484818110610f5f57610f5f61281f565b80610fb58161284b565b915050610f81565b6001600160a01b03808316600090815261010160209081526040808320938516835292905220606090610fef90611db7565b9392505050565b3360009081526097602052604090205460ff16806110175750611017611596565b6110335760405162461bcd60e51b81526004016105da906128b4565b838380806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250508251151591506110a690505760405162461bcd60e51b815260206004820152600b60248201526a456d70747920617272617960a81b60448201526064016105da565b8382146110e35760405162461bcd60e51b815260206004820152600b60248201526a426164206c656e6774687360a81b60448201526064016105da565b6110f06101066000612368565b6000805b858110156111ea5784848281811061110e5761110e61281f565b90506020020160208101906111239190612958565b61112d908361297e565b91506101068787838181106111445761114461281f565b835460018101855560009485526020948590209190940292909201359190920155508484828181106111785761117861281f565b905060200201602081019061118d9190612958565b61010760008989858181106111a4576111a461281f565b90506020020135815260200190815260200160002060006101000a81548163ffffffff021916908363ffffffff16021790555080806111e29061284b565b9150506110f4565b508063ffffffff16620186a0146112345760405162461bcd60e51b815260206004820152600e60248201526d42616420746f74616c206f64647360901b60448201526064016105da565b505050505050565b6001600160a01b03808416600090815261010160209081526040808320938616835292905290812061126e9083611dc4565b949350505050565b3360009081526097602052604090205460ff16806112975750611297611596565b6112b35760405162461bcd60e51b81526004016105da906128b4565b61010855565b6033546001600160a01b031633146112e35760405162461bcd60e51b81526004016105da90612743565b6001600160a01b0381166113485760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016105da565b610942816114df565b3360009081526097602052604090205460ff16806113725750611372611596565b61138e5760405162461bcd60e51b81526004016105da906128b4565b60fc80546001600160a01b03199081166001600160a01b039788161790915560fe805482169587169590951790945560ff80548516938616939093179092556101008054841691851691909117905560fd80549092169216919091179055565b6001600160a01b038216600090815261010160209081526040808320338452909152902061141c9082611ddc565b506001600160a01b0382166000818152610102602090815260408083208584528252918290204290819055915191825283929133917f133489e9ddda3b16ddd3b9b961284c406b0a5da8cce1dc3ba03f7838764c93e7910160405180910390a4604051632142170760e11b8152336004820152306024820152604481018290526001600160a01b038316906342842e0e906064015b600060405180830381600087803b1580156114cb57600080fd5b505af1158015611234573d6000803e3d6000fd5b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff1661154c5760005460ff1615611550565b303b155b61156c5760405162461bcd60e51b81526004016105da90612866565b600054610100900460ff1615801561158e576000805461ffff19166101011790555b610930611de8565b6000336115ab6033546001600160a01b031690565b6001600160a01b031614905090565b6001600160a01b03821660009081526101016020908152604080832033845290915290206115e89082611dc4565b6116045760405162461bcd60e51b81526004016105da906129a6565b610106546116485760405162461bcd60e51b8152602060048201526011602482015270052657761726473206e6f7420736574757607c1b60448201526064016105da565b6001600160a01b038216600090815261010460209081526040808320848452909152902054806116b15760405162461bcd60e51b81526020600482015260146024820152734e6f20636c61696d20696e2070726f677265737360601b60448201526064016105da565b60fd5460405163f030210760e01b8152600481018390526001600160a01b039091169063f03021079060240160206040518083038186803b1580156116f557600080fd5b505afa158015611709573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061172d91906129d1565b61176c5760405162461bcd60e51b815260206004820152601060248201526f52616e646f6d206e6f7420726561647960801b60448201526064016105da565b60fd54604051634ad30a7560e01b8152600481018390526000916001600160a01b031690634ad30a759060240160206040518083038186803b1580156117b157600080fd5b505afa1580156117c5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117e991906129ee565b6001600160a01b0385166000908152610105602090815260408083208784529091528120549192505b8181101561186d5780156118505760408051602081018590529081018290526060016040516020818303038152906040528051906020012060001c92505b61185b868685611e71565b806118658161284b565b915050611812565b5050506001600160a01b03909216600081815261010560209081526040808320858452825280832083905592825261010481528282209382529290925281205550565b6001600160a01b03821660009081526101016020908152604080832033845290915290206118de9082611dc4565b6118fa5760405162461bcd60e51b81526004016105da906129a6565b6001600160a01b038216600090815261010460209081526040808320848452909152902054156119605760405162461bcd60e51b8152602060048201526011602482015270436c61696d20696e2070726f677265737360781b60448201526064016105da565b61196a8282610a24565b156119b75760405162461bcd60e51b815260206004820152601760248201527f52657761726473206c65667420756e636c61696d65642100000000000000000060448201526064016105da565b6001600160a01b03821660009081526101016020908152604080832033845290915290206119e59082611fbd565b506001600160a01b038216600081815261010260209081526040808320858452825280832083905583835261010382528083208584529091528082208290555183929133917f0e0892e64dffe15b2a80856d3fa02b3b3df09de56739118dc5b9a6050b8d553f9190a4604051632142170760e11b8152306004820152336024820152604481018290526001600160a01b038316906342842e0e906064016114b1565b60655460ff1615611aaa5760405162461bcd60e51b81526004016105da906127cc565b6065805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258611adf3390565b6040516001600160a01b03909116815260200160405180910390a1565b60655460ff16611b455760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b60448201526064016105da565b6065805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa33611adf565b6001600160a01b0382166000908152610101602090815260408083203384529091529020611ba49082611dc4565b611bc05760405162461bcd60e51b81526004016105da906129a6565b6001600160a01b03821660009081526101046020908152604080832084845290915290205415611c265760405162461bcd60e51b8152602060048201526011602482015270436c61696d20696e2070726f677265737360781b60448201526064016105da565b6000611c328383610a24565b905060008111611c7a5760405162461bcd60e51b81526020600482015260136024820152724e6f207265776172647320746f20636c61696d60681b60448201526064016105da565b6001600160a01b03831660009081526101036020908152604080832085845290915281208054839290611cae9084906128ff565b90915550506001600160a01b03808416600090815261010560209081526040808320868452825280832085905560fd54815163433c53d960e11b8152915193941692638678a7b29260048084019391929182900301818787803b158015611d1457600080fd5b505af1158015611d28573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d4c91906129ee565b6001600160a01b0385166000818152610104602090815260408083208884528252918290208490558151848152908101869052929350859233917f961177686f8f4c3873b7414b6f60339b49b32781a671d26be8a490508d4122b2910160405180910390a450505050565b60606000610fef83611fc9565b60008181526001830160205260408120541515610fef565b6000610fef8383612025565b600054610100900460ff16611e035760005460ff1615611e07565b303b155b611e235760405162461bcd60e51b81526004016105da90612866565b600054610100900460ff16158015611e45576000805461ffff19166101011790555b611e4d612074565b611e556120d9565b62015180610108558015610942576000805461ff001916905550565b6000611e80620186a083612a07565b905060008060005b61010654811015611f6c5760006101068281548110611ea957611ea961281f565b6000918252602080832090910154808352610107909152604090912054909150611ed99063ffffffff16856128ff565b935083851015611f595760fc54604051630ab714fb60e11b8152336004820152602481018390526001604482015291935083916001600160a01b039091169063156e29f690606401600060405180830381600087803b158015611f3b57600080fd5b505af1158015611f4f573d6000803e3d6000fd5b5050505050611f6c565b5080611f648161284b565b915050611e88565b50604080518281526001602082015286916001600160a01b0389169133917f17db246e2b79d27e01c800967d89cbee46000807213e933b6e4c4fddac899a78910160405180910390a4505050505050565b6000610fef8383612108565b60608160000180548060200260200160405190810160405280929190818152602001828054801561201957602002820191906000526020600020905b815481526020019060010190808311612005575b50505050509050919050565b600081815260018301602052604081205461206c57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610af9565b506000610af9565b600054610100900460ff1661208f5760005460ff1615612093565b303b155b6120af5760405162461bcd60e51b81526004016105da90612866565b600054610100900460ff161580156120d1576000805461ffff19166101011790555b6109306121fb565b600054610100900460ff166121005760405162461bcd60e51b81526004016105da90612a1b565b6108c9612270565b600081815260018301602052604081205480156121f157600061212c600183612917565b855490915060009061214090600190612917565b90508181146121a55760008660000182815481106121605761216061281f565b90600052602060002001549050808760000184815481106121835761218361281f565b6000918252602080832090910192909255918252600188019052604090208390555b85548690806121b6576121b6612a66565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610af9565b6000915050610af9565b600054610100900460ff166122165760005460ff161561221a565b303b155b6122365760405162461bcd60e51b81526004016105da90612866565b600054610100900460ff16158015612258576000805461ffff19166101011790555b612260612297565b6122686122ce565b610930611a87565b600054610100900460ff166108c95760405162461bcd60e51b81526004016105da90612a1b565b600054610100900460ff166122be5760405162461bcd60e51b81526004016105da90612a1b565b6122c6612270565b6108c9612305565b600054610100900460ff166122f55760405162461bcd60e51b81526004016105da90612a1b565b6122fd612270565b6108c9612335565b600054610100900460ff1661232c5760405162461bcd60e51b81526004016105da90612a1b565b6108c9336114df565b600054610100900460ff1661235c5760405162461bcd60e51b81526004016105da90612a1b565b6065805460ff19169055565b508054600082559060005260206000209081019061094291905b808211156123965760008155600101612382565b5090565b80356001600160a01b03811681146123b157600080fd5b919050565b600080604083850312156123c957600080fd5b6123d28361239a565b946020939093013593505050565b6000602082840312156123f257600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b6000806000806080858703121561242557600080fd5b61242e8561239a565b935061243c6020860161239a565b925060408501359150606085013567ffffffffffffffff8082111561246057600080fd5b818701915087601f83011261247457600080fd5b813581811115612486576124866123f9565b604051601f8201601f19908116603f011681019083821181831017156124ae576124ae6123f9565b816040528281528a60208487010111156124c757600080fd5b82602086016020830137600060208483010152809550505050505092959194509250565b6000602082840312156124fd57600080fd5b610fef8261239a565b60008083601f84011261251857600080fd5b50813567ffffffffffffffff81111561253057600080fd5b6020830191508360208260051b850101111561254b57600080fd5b9250929050565b6000806000806040858703121561256857600080fd5b843567ffffffffffffffff8082111561258057600080fd5b61258c88838901612506565b909650945060208701359150808211156125a557600080fd5b506125b287828801612506565b95989497509550505050565b600080602083850312156125d157600080fd5b823567ffffffffffffffff8111156125e857600080fd5b6125f485828601612506565b90969095509350505050565b801515811461094257600080fd5b60006020828403121561262057600080fd5b8135610fef81612600565b6000806040838503121561263e57600080fd5b6126478361239a565b91506126556020840161239a565b90509250929050565b6020808252825182820181905260009190848201906040850190845b818110156126965783518352928401929184019160010161267a565b50909695505050505050565b6000806000606084860312156126b757600080fd5b6126c08461239a565b92506126ce6020850161239a565b9150604084013590509250925092565b600080600080600060a086880312156126f657600080fd5b6126ff8661239a565b945061270d6020870161239a565b935061271b6040870161239a565b92506127296060870161239a565b91506127376080870161239a565b90509295509295909350565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252600c908201526b4e6f20636f6e74726163747360a01b604082015260600190565b60208082526014908201527310dbdb9d1c9858dd1cc8185c995b89dd081cd95d60621b604082015260600190565b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b6020808252600f908201526e3737903a37b5b2b7399033b4bb32b760891b604082015260600190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600060001982141561285f5761285f612835565b5060010190565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b6020808252601290820152712737ba1030b236b4b71037b91037bbb732b960711b604082015260600190565b60008160001904831182151516156128fa576128fa612835565b500290565b6000821982111561291257612912612835565b500190565b60008282101561292957612929612835565b500390565b634e487b7160e01b600052601260045260246000fd5b6000826129535761295361292e565b500490565b60006020828403121561296a57600080fd5b813563ffffffff81168114610fef57600080fd5b600063ffffffff80831681851680830382111561299d5761299d612835565b01949350505050565b6020808252601190820152702737ba1037bbb732b210313c903ab9b2b960791b604082015260600190565b6000602082840312156129e357600080fd5b8151610fef81612600565b600060208284031215612a0057600080fd5b5051919050565b600082612a1657612a1661292e565b500690565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b634e487b7160e01b600052603160045260246000fdfea2646970667358221220fa34fb5ba6581964e1ba9e915c1cba8ad86eed85d0aa59d3a37246d5906d1c7764736f6c63430008090033

Block Transaction Gas Used Reward
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
Block Uncle Number Difficulty Gas Used Reward
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.