Contract 0xaa64ad10e1ff46a968be333ad5414d8ed3e4df21

 
Txn Hash Method
Block
From
To
Value [Txn Fee]
0xe30afe578fe4e73ec9f347f3b280d8f0d391b549c3f36cab286c2b237bee3fa60x6080604097560682022-04-13 18:59:02226 days 18 hrs ago0xb013abd83f0bd173e9f14ce7d6e420ad711483b4 IN  Create: SmolFarm0 ETH0.017267653409 ETH
[ Download CSV Export 
Latest 25 internal transaction
Parent Txn Hash Block From To Value
0x770b0ff39691867246a37e70f2b61098b9a74b29696aa52be00bbab761674250102855222022-04-21 21:31:50218 days 15 hrs ago 0x200a416be6ccd9ddfb324966145a545085cfd244 0xaa64ad10e1ff46a968be333ad5414d8ed3e4df210 ETH
0x9938185305a5657b86bfb52efc70679e5817ce23ff91762fe1aeef94980af4c4102855042022-04-21 21:31:05218 days 15 hrs ago 0x71d1988c74a2321a4e71b99490a4d61c72fe2c96 0xaa64ad10e1ff46a968be333ad5414d8ed3e4df210 ETH
0x2b2b35efe34f684c8349c33896135cb8da20d72490a173194bec27bb66efb620102854892022-04-21 21:31:05218 days 15 hrs ago 0xb0fecb1a263249d966807889198ca9fc8c7ea3d1 0xaa64ad10e1ff46a968be333ad5414d8ed3e4df210 ETH
0x99f5ee26996e9292718257e8ac8fa671544283421b584fcfa3ac3d7ce757b13e102854582022-04-21 21:29:56218 days 15 hrs ago 0x79c26b3468fea1ca206c918758d978ca9079bd39 0xaa64ad10e1ff46a968be333ad5414d8ed3e4df210 ETH
0xbaf4af5950a0fcba7d6c3910fa64e27f68258a59f1538aa7f5b0d9f6338e28b3102854512022-04-21 21:29:56218 days 15 hrs ago 0x7ece52a1c99b5422aad7a4fa6a070dbc8c4a25f9 0xaa64ad10e1ff46a968be333ad5414d8ed3e4df210 ETH
0xb9210dba76a5ef40bd1e64f852d242cf1ae657c359501e17ed5bd87fd43ffa20102854502022-04-21 21:29:56218 days 15 hrs ago 0x114de4711c4014691df3126b46631cb155f84395 0xaa64ad10e1ff46a968be333ad5414d8ed3e4df210 ETH
0x26a14ae5a90e254e75ceed150a1cb5bc72b3fed65458e134efcdfc91ceb5c2e8102854472022-04-21 21:29:56218 days 15 hrs ago 0xa93ee14e133ce344691ee7984162f5a191caf4bc 0xaa64ad10e1ff46a968be333ad5414d8ed3e4df210 ETH
0x1f952f5d4ffb5569757bd8d9094137ce955761f2cf155fc5f2f763a66834893d102854462022-04-21 21:29:56218 days 15 hrs ago 0x79c26b3468fea1ca206c918758d978ca9079bd39 0xaa64ad10e1ff46a968be333ad5414d8ed3e4df210 ETH
0xf61df4febdbb005ecf77f30580b7d4b500b692075c06be3604e34fe2b60e0c22102854132022-04-21 21:28:42218 days 15 hrs ago 0x0a3a0cf2b9f37e15d3d559b85b8a26a3099b0894 0xaa64ad10e1ff46a968be333ad5414d8ed3e4df210 ETH
0x9eb065b82600ec24abef804a7cdb22365c4c7b9da0e174b246735fbb295b1550102853812022-04-21 21:27:43218 days 16 hrs ago 0x23dd7afc61f7be0883d632b6520a90dad6197952 0xaa64ad10e1ff46a968be333ad5414d8ed3e4df210 ETH
0x914112c62a249ac3857ac10d12d2c335cd2e4934ea07a2c576f562425757c4b7102853642022-04-21 21:27:43218 days 16 hrs ago 0x23dd7afc61f7be0883d632b6520a90dad6197952 0xaa64ad10e1ff46a968be333ad5414d8ed3e4df210 ETH
0x09bdde02f21a5f203ef19ddd8b16e10947337a63b4274746f6c0e51b2c4c26cf102853622022-04-21 21:27:43218 days 16 hrs ago 0x399010918f2611f269b777a20725628b5a65ab73 0xaa64ad10e1ff46a968be333ad5414d8ed3e4df210 ETH
0xfce4b16ac1c0b06cc18430c0339188dba4b50b4381a60922d26c28fa388ce2d9102853522022-04-21 21:27:26218 days 16 hrs ago 0x399010918f2611f269b777a20725628b5a65ab73 0xaa64ad10e1ff46a968be333ad5414d8ed3e4df210 ETH
0xe8d5b0e3155fc496854f3db39158ec6595bd0b22483ef956347ef141623df79a102853332022-04-21 21:26:15218 days 16 hrs ago 0x399010918f2611f269b777a20725628b5a65ab73 0xaa64ad10e1ff46a968be333ad5414d8ed3e4df210 ETH
0xf20500882e7f4821c08e2d8c128bdba3002acf2a06097dcc9a09180f77f22778102853142022-04-21 21:26:15218 days 16 hrs ago 0x149cd9fbce29c608382a2e07f3fb1ccdc6f46fd3 0xaa64ad10e1ff46a968be333ad5414d8ed3e4df210 ETH
0x1725bf89181779e904b1ec6630693c0ec756aa21fa8b77af4217fc2773c48aaa102853112022-04-21 21:26:15218 days 16 hrs ago 0xccbdc6e710eecd5d4bb039965344ada24307840e 0xaa64ad10e1ff46a968be333ad5414d8ed3e4df210 ETH
0x11e0b83161ca2b62ff6d19b35239b18f8b9b7e253ce07f6fb8d6fd072d19282f102852972022-04-21 21:25:51218 days 16 hrs ago 0x5bf318820fb2ebb11075ebc81976c38a414472f5 0xaa64ad10e1ff46a968be333ad5414d8ed3e4df210 ETH
0xded243cad40d8e437ca570dfca4e8b3bbcdaed3ea49312261c46003892807569102852932022-04-21 21:25:51218 days 16 hrs ago 0x114de4711c4014691df3126b46631cb155f84395 0xaa64ad10e1ff46a968be333ad5414d8ed3e4df210 ETH
0x63c6cf09c0c6b10b4c7a9d3f7a381cfd6ddab17f9b26eb353ade732d92570a94102852662022-04-21 21:24:56218 days 16 hrs ago 0x149cd9fbce29c608382a2e07f3fb1ccdc6f46fd3 0xaa64ad10e1ff46a968be333ad5414d8ed3e4df210 ETH
0xf15b74cb459187c0b08b04f5883bd164c7ba8406140eb83484e24c74127c50e9102852632022-04-21 21:24:56218 days 16 hrs ago 0x48d26fbd89dda10c72cd8dc7b82b9eee0af6b48d 0xaa64ad10e1ff46a968be333ad5414d8ed3e4df210 ETH
0x4caaf374b12e3892287e5fe23b62191a0435a0a1c569c6250242ac9b2e1eb217102852362022-04-21 21:23:59218 days 16 hrs ago 0x48d26fbd89dda10c72cd8dc7b82b9eee0af6b48d 0xaa64ad10e1ff46a968be333ad5414d8ed3e4df210 ETH
0x88e1493f1121eb8e34885a83c189b2570de5836b82d0324c0b4b70c81930a272102852152022-04-21 21:23:59218 days 16 hrs ago 0x48d26fbd89dda10c72cd8dc7b82b9eee0af6b48d 0xaa64ad10e1ff46a968be333ad5414d8ed3e4df210 ETH
0x83ad3bebafa2c8976da3afda26441281c72eed9a34b2d76d83600b3c09967d46102851912022-04-21 21:22:36218 days 16 hrs ago 0xdc14966c1d4bd583bd0bb8e29c605e79cf2b2847 0xaa64ad10e1ff46a968be333ad5414d8ed3e4df210 ETH
0x960c716a9bb5a60afceebd4a4ead4442e9da2e718f6b59ddcbff8d6f2f67e40e102851602022-04-21 21:22:36218 days 16 hrs ago Smolverse: Smol Brains 0xaa64ad10e1ff46a968be333ad5414d8ed3e4df210 ETH
0x960c716a9bb5a60afceebd4a4ead4442e9da2e718f6b59ddcbff8d6f2f67e40e102851602022-04-21 21:22:36218 days 16 hrs ago 0x7d4157ea91695c66709b57c08083e141e7241160 0xaa64ad10e1ff46a968be333ad5414d8ed3e4df210 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);

        return (block.timestamp - _timeForCalculation) / _timeForReward;
    }

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

    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;

    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":"_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":"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"}]

608060405234801561001057600080fd5b50612a1a806100206000396000f3fe608060405234801561001057600080fd5b50600436106102065760003560e01c80638da5cb5b1161011a578063cfe8f487116100ad578063ead657c71161007c578063ead657c714610505578063eb54d5c714610518578063f10fb58414610544578063f2fde38b14610557578063f63bf8bd1461056a57600080fd5b8063cfe8f487146104ab578063d8447dad146104cb578063e0e3818e146104df578063eaafd1dd146104f257600080fd5b8063bbf65ab7116100e9578063bbf65ab714610468578063bedb86fb1461047b578063c03f36701461048e578063ccf63845146104a157600080fd5b80638da5cb5b1461041e5780639c54df641461042f578063a87e547014610442578063b64d309f1461045557600080fd5b806335b3c18a1161019d578063686dd20b1161016c578063686dd20b146103d557806370480275146103e8578063715018a6146103fb5780637bd6babb146104035780638129fc1c1461041657600080fd5b806335b3c18a14610391578063377e11e0146103a457806349a5572b146103b75780635c975abb146103ca57600080fd5b806319842fb5116101d957806319842fb5146102d25780631f823805146102fe57806324d7806c146103295780632b5f94bd1461036557600080fd5b8063030c42251461020b5780630a5ff95a1461024a578063150b7a02146102865780631785f53c146102bd575b600080fd5b61023761021936600461231e565b61010360209081526000928352604080842090915290825290205481565b6040519081526020015b60405180910390f35b610271610258366004612348565b6101076020526000908152604090205463ffffffff1681565b60405163ffffffff9091168152602001610241565b6102a4610294366004612377565b630a85bd0160e11b949350505050565b6040516001600160e01b03199091168152602001610241565b6102d06102cb366004612453565b61057d565b005b6102376102e036600461231e565b61010460209081526000928352604080842090915290825290205481565b60fc54610311906001600160a01b031681565b6040516001600160a01b039091168152602001610241565b610355610337366004612453565b6001600160a01b031660009081526097602052604090205460ff1690565b6040519015158152602001610241565b61023761037336600461231e565b61010260209081526000928352604080842090915290825290205481565b6102d061039f3660046124ba565b6105d1565b6102d06103b2366004612526565b610751565b60fe54610311906001600160a01b031681565b60655460ff16610355565b6102376103e3366004612348565b6107f2565b6102d06103f6366004612453565b610814565b6102d0610862565b60ff54610311906001600160a01b031681565b6102d0610898565b6033546001600160a01b0316610311565b6102d061043d366004612526565b610912565b61023761045036600461231e565b6109ae565b6102d06104633660046124ba565b610a67565b6102d06104763660046124ba565b610be0565b6102d0610489366004612576565b610d59565b6102d061049c3660046124ba565b610dac565b6102376101085481565b6104be6104b9366004612593565b610f25565b60405161024191906125c6565b61010054610311906001600160a01b031681565b6102d06104ed3660046124ba565b610f5e565b61035561050036600461260a565b6111a4565b6102d0610513366004612348565b6111de565b61023761052636600461231e565b61010560209081526000928352604080842090915290825290205481565b60fd54610311906001600160a01b031681565b6102d0610565366004612453565b611221565b6102d0610578366004612646565b6112b9565b6033546001600160a01b031633146105b05760405162461bcd60e51b81526004016105a7906126ab565b60405180910390fd5b6001600160a01b03166000908152609760205260409020805460ff19169055565b3332146105f05760405162461bcd60e51b81526004016105a7906126e0565b60fc546001600160a01b031615801590610614575060fd546001600160a01b031615155b801561062a575060fe546001600160a01b031615155b8015610640575060ff546001600160a01b031615155b80156106575750610100546001600160a01b031615155b6106735760405162461bcd60e51b81526004016105a790612706565b60655460ff16156106965760405162461bcd60e51b81526004016105a790612734565b821515806106a357508015155b6106bf5760405162461bcd60e51b81526004016105a79061275e565b60005b8381101561070a5760fe546106f8906001600160a01b03168686848181106106ec576106ec612787565b90506020020135611356565b80610702816127b3565b9150506106c2565b5060005b8181101561074a5760ff54610738906001600160a01b03168484848181106106ec576106ec612787565b80610742816127b3565b91505061070e565b5050505050565b6033546001600160a01b0316331461077b5760405162461bcd60e51b81526004016105a7906126ab565b60005b818110156107ed5760006097600085858581811061079e5761079e612787565b90506020020160208101906107b39190612453565b6001600160a01b031681526020810191909152604001600020805460ff1916911515919091179055806107e5816127b3565b91505061077e565b505050565b610106818154811061080357600080fd5b600091825260209091200154905081565b6033546001600160a01b0316331461083e5760405162461bcd60e51b81526004016105a7906126ab565b6001600160a01b03166000908152609760205260409020805460ff19166001179055565b6033546001600160a01b0316331461088c5760405162461bcd60e51b81526004016105a7906126ab565b6108966000611447565b565b600054610100900460ff166108b35760005460ff16156108b7565b303b155b6108d35760405162461bcd60e51b81526004016105a7906127ce565b600054610100900460ff161580156108f5576000805461ffff19166101011790555b6108fd611499565b801561090f576000805461ff00191690555b50565b6033546001600160a01b0316331461093c5760405162461bcd60e51b81526004016105a7906126ab565b60005b818110156107ed5760016097600085858581811061095f5761095f612787565b90506020020160208101906109749190612453565b6001600160a01b031681526020810191909152604001600020805460ff1916911515919091179055806109a6816127b3565b91505061093f565b6001600160a01b0382166000908152610102602090815260408083208484529091528120546109df57506000610a61565b610108546001600160a01b0384166000908152610103602090815260408083208684529091528120549091610a139161281c565b6001600160a01b038516600090815261010260209081526040808320878452909152902054610a42919061283b565b61010854909150610a538242612853565b610a5d9190612880565b9150505b92915050565b333214610a865760405162461bcd60e51b81526004016105a7906126e0565b60fc546001600160a01b031615801590610aaa575060fd546001600160a01b031615155b8015610ac0575060fe546001600160a01b031615155b8015610ad6575060ff546001600160a01b031615155b8015610aed5750610100546001600160a01b031615155b610b095760405162461bcd60e51b81526004016105a790612706565b60655460ff1615610b2c5760405162461bcd60e51b81526004016105a790612734565b82151580610b3957508015155b610b555760405162461bcd60e51b81526004016105a79061275e565b60005b83811015610ba05760fe54610b8e906001600160a01b0316868684818110610b8257610b82612787565b905060200201356114fe565b80610b98816127b3565b915050610b58565b5060005b8181101561074a5760ff54610bce906001600160a01b0316848484818110610b8257610b82612787565b80610bd8816127b3565b915050610ba4565b333214610bff5760405162461bcd60e51b81526004016105a7906126e0565b60fc546001600160a01b031615801590610c23575060fd546001600160a01b031615155b8015610c39575060fe546001600160a01b031615155b8015610c4f575060ff546001600160a01b031615155b8015610c665750610100546001600160a01b031615155b610c825760405162461bcd60e51b81526004016105a790612706565b60655460ff1615610ca55760405162461bcd60e51b81526004016105a790612734565b82151580610cb257508015155b610cce5760405162461bcd60e51b81526004016105a79061275e565b60005b83811015610d195760fe54610d07906001600160a01b0316868684818110610cfb57610cfb612787565b905060200201356117f4565b80610d11816127b3565b915050610cd1565b5060005b8181101561074a5760ff54610d47906001600160a01b0316848484818110610cfb57610cfb612787565b80610d51816127b3565b915050610d1d565b3360009081526097602052604090205460ff1680610d7a5750610d7a6119cb565b610d965760405162461bcd60e51b81526004016105a790612894565b8015610da45761090f6119ef565b61090f611a64565b333214610dcb5760405162461bcd60e51b81526004016105a7906126e0565b60fc546001600160a01b031615801590610def575060fd546001600160a01b031615155b8015610e05575060fe546001600160a01b031615155b8015610e1b575060ff546001600160a01b031615155b8015610e325750610100546001600160a01b031615155b610e4e5760405162461bcd60e51b81526004016105a790612706565b60655460ff1615610e715760405162461bcd60e51b81526004016105a790612734565b82151580610e7e57508015155b610e9a5760405162461bcd60e51b81526004016105a79061275e565b60005b83811015610ee55760fe54610ed3906001600160a01b0316868684818110610ec757610ec7612787565b90506020020135611ade565b80610edd816127b3565b915050610e9d565b5060005b8181101561074a5760ff54610f13906001600160a01b0316848484818110610ec757610ec7612787565b80610f1d816127b3565b915050610ee9565b6001600160a01b03808316600090815261010160209081526040808320938516835292905220606090610f5790611d1f565b9392505050565b3360009081526097602052604090205460ff1680610f7f5750610f7f6119cb565b610f9b5760405162461bcd60e51b81526004016105a790612894565b8383808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152505082511515915061100e90505760405162461bcd60e51b815260206004820152600b60248201526a456d70747920617272617960a81b60448201526064016105a7565b83821461104b5760405162461bcd60e51b815260206004820152600b60248201526a426164206c656e6774687360a81b60448201526064016105a7565b61105861010660006122d0565b6000805b858110156111525784848281811061107657611076612787565b905060200201602081019061108b91906128c0565b61109590836128e6565b91506101068787838181106110ac576110ac612787565b835460018101855560009485526020948590209190940292909201359190920155508484828181106110e0576110e0612787565b90506020020160208101906110f591906128c0565b610107600089898581811061110c5761110c612787565b90506020020135815260200190815260200160002060006101000a81548163ffffffff021916908363ffffffff160217905550808061114a906127b3565b91505061105c565b508063ffffffff16620186a01461119c5760405162461bcd60e51b815260206004820152600e60248201526d42616420746f74616c206f64647360901b60448201526064016105a7565b505050505050565b6001600160a01b0380841660009081526101016020908152604080832093861683529290529081206111d69083611d2c565b949350505050565b3360009081526097602052604090205460ff16806111ff57506111ff6119cb565b61121b5760405162461bcd60e51b81526004016105a790612894565b61010855565b6033546001600160a01b0316331461124b5760405162461bcd60e51b81526004016105a7906126ab565b6001600160a01b0381166112b05760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016105a7565b61090f81611447565b3360009081526097602052604090205460ff16806112da57506112da6119cb565b6112f65760405162461bcd60e51b81526004016105a790612894565b60fc80546001600160a01b03199081166001600160a01b039788161790915560fe805482169587169590951790945560ff80548516938616939093179092556101008054841691851691909117905560fd80549092169216919091179055565b6001600160a01b03821660009081526101016020908152604080832033845290915290206113849082611d44565b506001600160a01b0382166000818152610102602090815260408083208584528252918290204290819055915191825283929133917f133489e9ddda3b16ddd3b9b961284c406b0a5da8cce1dc3ba03f7838764c93e7910160405180910390a4604051632142170760e11b8152336004820152306024820152604481018290526001600160a01b038316906342842e0e906064015b600060405180830381600087803b15801561143357600080fd5b505af115801561119c573d6000803e3d6000fd5b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff166114b45760005460ff16156114b8565b303b155b6114d45760405162461bcd60e51b81526004016105a7906127ce565b600054610100900460ff161580156114f6576000805461ffff19166101011790555b6108fd611d50565b6001600160a01b038216600090815261010160209081526040808320338452909152902061152c9082611d2c565b6115485760405162461bcd60e51b81526004016105a79061290e565b6101065461158c5760405162461bcd60e51b8152602060048201526011602482015270052657761726473206e6f7420736574757607c1b60448201526064016105a7565b6001600160a01b038216600090815261010460209081526040808320848452909152902054806115f55760405162461bcd60e51b81526020600482015260146024820152734e6f20636c61696d20696e2070726f677265737360601b60448201526064016105a7565b60fd5460405163f030210760e01b8152600481018390526001600160a01b039091169063f03021079060240160206040518083038186803b15801561163957600080fd5b505afa15801561164d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116719190612939565b6116b05760405162461bcd60e51b815260206004820152601060248201526f52616e646f6d206e6f7420726561647960801b60448201526064016105a7565b60fd54604051634ad30a7560e01b8152600481018390526000916001600160a01b031690634ad30a759060240160206040518083038186803b1580156116f557600080fd5b505afa158015611709573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061172d9190612956565b6001600160a01b0385166000908152610105602090815260408083208784529091528120549192505b818110156117b15780156117945760408051602081018590529081018290526060016040516020818303038152906040528051906020012060001c92505b61179f868685611dd9565b806117a9816127b3565b915050611756565b5050506001600160a01b03909216600081815261010560209081526040808320858452825280832083905592825261010481528282209382529290925281205550565b6001600160a01b03821660009081526101016020908152604080832033845290915290206118229082611d2c565b61183e5760405162461bcd60e51b81526004016105a79061290e565b6001600160a01b038216600090815261010460209081526040808320848452909152902054156118a45760405162461bcd60e51b8152602060048201526011602482015270436c61696d20696e2070726f677265737360781b60448201526064016105a7565b6118ae82826109ae565b156118fb5760405162461bcd60e51b815260206004820152601760248201527f52657761726473206c65667420756e636c61696d65642100000000000000000060448201526064016105a7565b6001600160a01b03821660009081526101016020908152604080832033845290915290206119299082611f25565b506001600160a01b038216600081815261010260209081526040808320858452825280832083905583835261010382528083208584529091528082208290555183929133917f0e0892e64dffe15b2a80856d3fa02b3b3df09de56739118dc5b9a6050b8d553f9190a4604051632142170760e11b8152306004820152336024820152604481018290526001600160a01b038316906342842e0e90606401611419565b6000336119e06033546001600160a01b031690565b6001600160a01b031614905090565b60655460ff1615611a125760405162461bcd60e51b81526004016105a790612734565b6065805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258611a473390565b6040516001600160a01b03909116815260200160405180910390a1565b60655460ff16611aad5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b60448201526064016105a7565b6065805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa33611a47565b6001600160a01b0382166000908152610101602090815260408083203384529091529020611b0c9082611d2c565b611b285760405162461bcd60e51b81526004016105a79061290e565b6001600160a01b03821660009081526101046020908152604080832084845290915290205415611b8e5760405162461bcd60e51b8152602060048201526011602482015270436c61696d20696e2070726f677265737360781b60448201526064016105a7565b6000611b9a83836109ae565b905060008111611be25760405162461bcd60e51b81526020600482015260136024820152724e6f207265776172647320746f20636c61696d60681b60448201526064016105a7565b6001600160a01b03831660009081526101036020908152604080832085845290915281208054839290611c1690849061283b565b90915550506001600160a01b03808416600090815261010560209081526040808320868452825280832085905560fd54815163433c53d960e11b8152915193941692638678a7b29260048084019391929182900301818787803b158015611c7c57600080fd5b505af1158015611c90573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cb49190612956565b6001600160a01b0385166000818152610104602090815260408083208884528252918290208490558151848152908101869052929350859233917f961177686f8f4c3873b7414b6f60339b49b32781a671d26be8a490508d4122b2910160405180910390a450505050565b60606000610f5783611f31565b60008181526001830160205260408120541515610f57565b6000610f578383611f8d565b600054610100900460ff16611d6b5760005460ff1615611d6f565b303b155b611d8b5760405162461bcd60e51b81526004016105a7906127ce565b600054610100900460ff16158015611dad576000805461ffff19166101011790555b611db5611fdc565b611dbd612041565b6201518061010855801561090f576000805461ff001916905550565b6000611de8620186a08361296f565b905060008060005b61010654811015611ed45760006101068281548110611e1157611e11612787565b6000918252602080832090910154808352610107909152604090912054909150611e419063ffffffff168561283b565b935083851015611ec15760fc54604051630ab714fb60e11b8152336004820152602481018390526001604482015291935083916001600160a01b039091169063156e29f690606401600060405180830381600087803b158015611ea357600080fd5b505af1158015611eb7573d6000803e3d6000fd5b5050505050611ed4565b5080611ecc816127b3565b915050611df0565b50604080518281526001602082015286916001600160a01b0389169133917f17db246e2b79d27e01c800967d89cbee46000807213e933b6e4c4fddac899a78910160405180910390a4505050505050565b6000610f578383612070565b606081600001805480602002602001604051908101604052809291908181526020018280548015611f8157602002820191906000526020600020905b815481526020019060010190808311611f6d575b50505050509050919050565b6000818152600183016020526040812054611fd457508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610a61565b506000610a61565b600054610100900460ff16611ff75760005460ff1615611ffb565b303b155b6120175760405162461bcd60e51b81526004016105a7906127ce565b600054610100900460ff16158015612039576000805461ffff19166101011790555b6108fd612163565b600054610100900460ff166120685760405162461bcd60e51b81526004016105a790612983565b6108966121d8565b60008181526001830160205260408120548015612159576000612094600183612853565b85549091506000906120a890600190612853565b905081811461210d5760008660000182815481106120c8576120c8612787565b90600052602060002001549050808760000184815481106120eb576120eb612787565b6000918252602080832090910192909255918252600188019052604090208390555b855486908061211e5761211e6129ce565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610a61565b6000915050610a61565b600054610100900460ff1661217e5760005460ff1615612182565b303b155b61219e5760405162461bcd60e51b81526004016105a7906127ce565b600054610100900460ff161580156121c0576000805461ffff19166101011790555b6121c86121ff565b6121d0612236565b6108fd6119ef565b600054610100900460ff166108965760405162461bcd60e51b81526004016105a790612983565b600054610100900460ff166122265760405162461bcd60e51b81526004016105a790612983565b61222e6121d8565b61089661226d565b600054610100900460ff1661225d5760405162461bcd60e51b81526004016105a790612983565b6122656121d8565b61089661229d565b600054610100900460ff166122945760405162461bcd60e51b81526004016105a790612983565b61089633611447565b600054610100900460ff166122c45760405162461bcd60e51b81526004016105a790612983565b6065805460ff19169055565b508054600082559060005260206000209081019061090f91905b808211156122fe57600081556001016122ea565b5090565b80356001600160a01b038116811461231957600080fd5b919050565b6000806040838503121561233157600080fd5b61233a83612302565b946020939093013593505050565b60006020828403121561235a57600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b6000806000806080858703121561238d57600080fd5b61239685612302565b93506123a460208601612302565b925060408501359150606085013567ffffffffffffffff808211156123c857600080fd5b818701915087601f8301126123dc57600080fd5b8135818111156123ee576123ee612361565b604051601f8201601f19908116603f0116810190838211818310171561241657612416612361565b816040528281528a602084870101111561242f57600080fd5b82602086016020830137600060208483010152809550505050505092959194509250565b60006020828403121561246557600080fd5b610f5782612302565b60008083601f84011261248057600080fd5b50813567ffffffffffffffff81111561249857600080fd5b6020830191508360208260051b85010111156124b357600080fd5b9250929050565b600080600080604085870312156124d057600080fd5b843567ffffffffffffffff808211156124e857600080fd5b6124f48883890161246e565b9096509450602087013591508082111561250d57600080fd5b5061251a8782880161246e565b95989497509550505050565b6000806020838503121561253957600080fd5b823567ffffffffffffffff81111561255057600080fd5b61255c8582860161246e565b90969095509350505050565b801515811461090f57600080fd5b60006020828403121561258857600080fd5b8135610f5781612568565b600080604083850312156125a657600080fd5b6125af83612302565b91506125bd60208401612302565b90509250929050565b6020808252825182820181905260009190848201906040850190845b818110156125fe578351835292840192918401916001016125e2565b50909695505050505050565b60008060006060848603121561261f57600080fd5b61262884612302565b925061263660208501612302565b9150604084013590509250925092565b600080600080600060a0868803121561265e57600080fd5b61266786612302565b945061267560208701612302565b935061268360408701612302565b925061269160608701612302565b915061269f60808701612302565b90509295509295909350565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252600c908201526b4e6f20636f6e74726163747360a01b604082015260600190565b60208082526014908201527310dbdb9d1c9858dd1cc8185c995b89dd081cd95d60621b604082015260600190565b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b6020808252600f908201526e3737903a37b5b2b7399033b4bb32b760891b604082015260600190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b60006000198214156127c7576127c761279d565b5060010190565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b60008160001904831182151516156128365761283661279d565b500290565b6000821982111561284e5761284e61279d565b500190565b6000828210156128655761286561279d565b500390565b634e487b7160e01b600052601260045260246000fd5b60008261288f5761288f61286a565b500490565b6020808252601290820152712737ba1030b236b4b71037b91037bbb732b960711b604082015260600190565b6000602082840312156128d257600080fd5b813563ffffffff81168114610f5757600080fd5b600063ffffffff8083168185168083038211156129055761290561279d565b01949350505050565b6020808252601190820152702737ba1037bbb732b210313c903ab9b2b960791b604082015260600190565b60006020828403121561294b57600080fd5b8151610f5781612568565b60006020828403121561296857600080fd5b5051919050565b60008261297e5761297e61286a565b500690565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b634e487b7160e01b600052603160045260246000fdfea2646970667358221220b19ecdd6456af84f6f18966468662394a56ca9f4ba7b0303945ab709cd4dbe3c64736f6c63430008090033

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.