Contract 0xe2670b1b199d1ac0b5ec8cb59f36fa7aeba27c39

 
Txn Hash Method
Block
From
To
Value [Txn Fee]
0x01763429c8147f4fc9629720930b1406a10d5af655b3d117a91342535867cb3f0x6080604063992412022-02-19 17:40:15288 days 17 hrs ago0xb013abd83f0bd173e9f14ce7d6e420ad711483b4 IN  Create: SmolFarm0 ETH0.023332081504 ETH
[ Download CSV Export 
Latest 25 internal transaction
Parent Txn Hash Block From To Value
0x347f66c93a31ff0896351a54c9c4d827f1111159f718ba770511a3dbd8dd4b6477051192022-03-10 18:30:12269 days 17 hrs ago Smolverse: Smol Brains 0xe2670b1b199d1ac0b5ec8cb59f36fa7aeba27c390 ETH
0x347f66c93a31ff0896351a54c9c4d827f1111159f718ba770511a3dbd8dd4b6477051192022-03-10 18:30:12269 days 17 hrs ago 0x87968002e2ab5cec1617e4c1d397dc7f0bd14fc2 0xe2670b1b199d1ac0b5ec8cb59f36fa7aeba27c390 ETH
0xc42d13b11ac25269b1deb0d515096f64dea56d76df0868d86463a5970595978d77051182022-03-10 18:30:12269 days 17 hrs ago 0xbdc81e0688858f44141c6ab23faf1319c5aa2dd3 0xe2670b1b199d1ac0b5ec8cb59f36fa7aeba27c390 ETH
0xcbbbee82a0f5484df649abd9dec85297d4eb4bd67a53ff0c8cd39ad6aca01b5b77051012022-03-10 18:29:32269 days 17 hrs ago 0xbdc81e0688858f44141c6ab23faf1319c5aa2dd3 0xe2670b1b199d1ac0b5ec8cb59f36fa7aeba27c390 ETH
0xbaedfc375ee9cd14accfef73f6de353e492f95de793f2bc4970a3ad13f70550277050852022-03-10 18:28:16269 days 17 hrs ago 0xe747cc3c1552d066cfa9c4b8808c4edb07e423e5 0xe2670b1b199d1ac0b5ec8cb59f36fa7aeba27c390 ETH
0xbfbbc67b79370626f772acff2f9a4937de00ad5100079247cf6065069087033277050472022-03-10 18:25:32269 days 17 hrs ago 0x87968002e2ab5cec1617e4c1d397dc7f0bd14fc2 0xe2670b1b199d1ac0b5ec8cb59f36fa7aeba27c390 ETH
0x43aabcc336c9fbadaf15fa6272ada667e5f1f66ea6bb27e62d18af92eeeb5fd777049732022-03-10 18:23:03269 days 17 hrs ago 0x507fc313f9d50ce32ff94e67df48f7b0935d016a 0xe2670b1b199d1ac0b5ec8cb59f36fa7aeba27c390 ETH
0x5d1bdedfe54340c43ce8661e33ae0b35623d6396bd0387fbcd25d89a4d21acaf77049722022-03-10 18:23:03269 days 17 hrs ago 0x87968002e2ab5cec1617e4c1d397dc7f0bd14fc2 0xe2670b1b199d1ac0b5ec8cb59f36fa7aeba27c390 ETH
0x7424287b2a2a3a9607252711902b38bdad2cb06e142886cc3849fa3190af9b6a77049262022-03-10 18:21:18269 days 17 hrs ago 0x55907cf476998d2f58591c6d0a10ecbbe249a8eb 0xe2670b1b199d1ac0b5ec8cb59f36fa7aeba27c390 ETH
0x3d1273f1ad975383352a6853cafdcee05edfe8543181595166fbfd3529537e1677049212022-03-10 18:21:18269 days 17 hrs ago 0xd9822f8e71303903fea0bdaa78688f7bcf175b18 0xe2670b1b199d1ac0b5ec8cb59f36fa7aeba27c390 ETH
0x2aa36a8f88af8666128af42339b1cab142b809c3f59ad521de9072387ee6140477048922022-03-10 18:20:20269 days 17 hrs ago 0x4b038be6a97c5d7f516f3595197a22a0248d4c73 0xe2670b1b199d1ac0b5ec8cb59f36fa7aeba27c390 ETH
0x3fe16efd4a75bb7021789f4cdb98ed9ddce5cef07b4759b2f949314ff3d3829877048672022-03-10 18:19:48269 days 17 hrs ago 0x7f04eb7ba1a3a05f6cb1100dd0173d68af94a728 0xe2670b1b199d1ac0b5ec8cb59f36fa7aeba27c390 ETH
0x21d4dd1639f2c75b775c75a2fa51e1de39fb1c48dd8d44ebc2f4d6a7eeb60c0a77048092022-03-10 18:17:54269 days 17 hrs ago 0xea1fd6438baac6d004dc850358742d9b5b0a0e2b 0xe2670b1b199d1ac0b5ec8cb59f36fa7aeba27c390 ETH
0xdb55b8c6789c1ba04ff90084e64adde129fb3d8a36e75717c15ca93a06a255a777047842022-03-10 18:17:41269 days 17 hrs ago 0x7f04eb7ba1a3a05f6cb1100dd0173d68af94a728 0xe2670b1b199d1ac0b5ec8cb59f36fa7aeba27c390 ETH
0x570e847c8c65e0bab42d9e6cdec99b806d238d23439d5ca8a3ee26bd1e1c825777047662022-03-10 18:17:07269 days 17 hrs ago 0xf7407d36c2741c9c5ef58d61924c1965c4f4256a 0xe2670b1b199d1ac0b5ec8cb59f36fa7aeba27c390 ETH
0x6f3706b17daea42d6ecbf4400de415c0aec745c4a4d4f411a7a1bc5f42f40b3277047402022-03-10 18:16:10269 days 17 hrs ago 0xbab64597e8d0eb511a356b56b8dc46c7b01097c5 0xe2670b1b199d1ac0b5ec8cb59f36fa7aeba27c390 ETH
0x40cce6ae6d1a4658da573a813ba386602579683837b39fa6f986d145e180a52a77047382022-03-10 18:16:10269 days 17 hrs ago 0x73831da9005709439ee08f6d580cba7de32acb85 0xe2670b1b199d1ac0b5ec8cb59f36fa7aeba27c390 ETH
0x5dde1f37fc83540c5122aebd694bc1951268c4563526de59077c105f3501d51377046942022-03-10 18:14:25269 days 17 hrs ago 0x507fc313f9d50ce32ff94e67df48f7b0935d016a 0xe2670b1b199d1ac0b5ec8cb59f36fa7aeba27c390 ETH
0xfb22bc2908b84168ddbaf5f8c01993897d2bf8ca18af91c44d7315225bcdbd3877046892022-03-10 18:14:23269 days 17 hrs ago 0x1a2d50b8aa52d1f600d126f66c625c4c6e14d9c7 0xe2670b1b199d1ac0b5ec8cb59f36fa7aeba27c390 ETH
0x806970c24ae4cfaa5b10de96a39437ccbc53e503e6a7cc24ba6717908c006dfc77046562022-03-10 18:12:44269 days 17 hrs ago 0xf7407d36c2741c9c5ef58d61924c1965c4f4256a 0xe2670b1b199d1ac0b5ec8cb59f36fa7aeba27c390 ETH
0xb4885c41ba07fff3f72a7e073279d38e40a81842e6b4cbff20e0cbb52d98e78677046342022-03-10 18:11:04269 days 17 hrs ago 0x6f3753040d4648fec4c48eae287e00edb4080efb 0xe2670b1b199d1ac0b5ec8cb59f36fa7aeba27c390 ETH
0x8032772676c7451ffa393c7f71762c940db3268f1fd590c20922e614cf85faac77046032022-03-10 18:10:28269 days 17 hrs ago 0x630b7ddf68675b1c66191cebc8237d1ac1815dce 0xe2670b1b199d1ac0b5ec8cb59f36fa7aeba27c390 ETH
0x07f6a9a93400a1de7a1e62a945628f7a0e66c65d91c33d86e0101242f03b220677045952022-03-10 18:10:28269 days 17 hrs ago 0x05ba7b83b2e033634ea89bc499ce085a68f6e9df 0xe2670b1b199d1ac0b5ec8cb59f36fa7aeba27c390 ETH
0x74e46b8af65cea3ffd20aed74ddfeea2ee05067f3fe0a29b4544d9bc3be858dc77045932022-03-10 18:10:28269 days 17 hrs ago 0x73831da9005709439ee08f6d580cba7de32acb85 0xe2670b1b199d1ac0b5ec8cb59f36fa7aeba27c390 ETH
0x8e79b627a85e32bd4f9caceb91a7c0bcb898e141e52d53811e7d5fce663d33b877045662022-03-10 18:09:04269 days 17 hrs ago 0x630b7ddf68675b1c66191cebc8237d1ac1815dce 0xe2670b1b199d1ac0b5ec8cb59f36fa7aeba27c390 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;
    }

}

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

608060405234801561001057600080fd5b50612849806100206000396000f3fe608060405234801561001057600080fd5b50600436106101f05760003560e01c80638129fc1c1161010f578063ccf63845116100a2578063eb54d5c711610071578063eb54d5c7146104cf578063f10fb584146104fb578063f2fde38b1461050e578063f63bf8bd1461052157600080fd5b8063ccf638451461048b578063d8447dad14610495578063e0e3818e146104a9578063ead657c7146104bc57600080fd5b8063b64d309f116100de578063b64d309f1461043f578063bbf65ab714610452578063bedb86fb14610465578063c03f36701461047857600080fd5b80638129fc1c146104005780638da5cb5b146104085780639c54df6414610419578063a87e54701461042c57600080fd5b806335b3c18a11610187578063686dd20b11610156578063686dd20b146103bf57806370480275146103d2578063715018a6146103e55780637bd6babb146103ed57600080fd5b806335b3c18a1461037b578063377e11e01461038e57806349a5572b146103a15780635c975abb146103b457600080fd5b806319842fb5116101c357806319842fb5146102bc5780631f823805146102e857806324d7806c146103135780632b5f94bd1461034f57600080fd5b8063030c4225146101f55780630a5ff95a14610234578063150b7a02146102705780631785f53c146102a7575b600080fd5b610221610203366004612200565b61010360209081526000928352604080842090915290825290205481565b6040519081526020015b60405180910390f35b61025b61024236600461222a565b6101076020526000908152604090205463ffffffff1681565b60405163ffffffff909116815260200161022b565b61028e61027e366004612259565b630a85bd0160e11b949350505050565b6040516001600160e01b0319909116815260200161022b565b6102ba6102b5366004612335565b610534565b005b6102216102ca366004612200565b61010460209081526000928352604080842090915290825290205481565b60fc546102fb906001600160a01b031681565b6040516001600160a01b03909116815260200161022b565b61033f610321366004612335565b6001600160a01b031660009081526097602052604090205460ff1690565b604051901515815260200161022b565b61022161035d366004612200565b61010260209081526000928352604080842090915290825290205481565b6102ba61038936600461239c565b610588565b6102ba61039c366004612408565b610708565b60fe546102fb906001600160a01b031681565b60655460ff1661033f565b6102216103cd36600461222a565b6107a9565b6102ba6103e0366004612335565b6107cb565b6102ba610819565b60ff546102fb906001600160a01b031681565b6102ba61084f565b6033546001600160a01b03166102fb565b6102ba610427366004612408565b6108c9565b61022161043a366004612200565b610965565b6102ba61044d36600461239c565b610a1e565b6102ba61046036600461239c565b610b97565b6102ba610473366004612458565b610d10565b6102ba61048636600461239c565b610d63565b6102216101085481565b610100546102fb906001600160a01b031681565b6102ba6104b736600461239c565b610edc565b6102ba6104ca36600461222a565b611122565b6102216104dd366004612200565b61010560209081526000928352604080842090915290825290205481565b60fd546102fb906001600160a01b031681565b6102ba61051c366004612335565b611165565b6102ba61052f366004612475565b6111fd565b6033546001600160a01b031633146105675760405162461bcd60e51b815260040161055e906124da565b60405180910390fd5b6001600160a01b03166000908152609760205260409020805460ff19169055565b3332146105a75760405162461bcd60e51b815260040161055e9061250f565b60fc546001600160a01b0316158015906105cb575060fd546001600160a01b031615155b80156105e1575060fe546001600160a01b031615155b80156105f7575060ff546001600160a01b031615155b801561060e5750610100546001600160a01b031615155b61062a5760405162461bcd60e51b815260040161055e90612535565b60655460ff161561064d5760405162461bcd60e51b815260040161055e90612563565b8215158061065a57508015155b6106765760405162461bcd60e51b815260040161055e9061258d565b60005b838110156106c15760fe546106af906001600160a01b03168686848181106106a3576106a36125b6565b9050602002013561129a565b806106b9816125e2565b915050610679565b5060005b818110156107015760ff546106ef906001600160a01b03168484848181106106a3576106a36125b6565b806106f9816125e2565b9150506106c5565b5050505050565b6033546001600160a01b031633146107325760405162461bcd60e51b815260040161055e906124da565b60005b818110156107a457600060976000858585818110610755576107556125b6565b905060200201602081019061076a9190612335565b6001600160a01b031681526020810191909152604001600020805460ff19169115159190911790558061079c816125e2565b915050610735565b505050565b61010681815481106107ba57600080fd5b600091825260209091200154905081565b6033546001600160a01b031633146107f55760405162461bcd60e51b815260040161055e906124da565b6001600160a01b03166000908152609760205260409020805460ff19166001179055565b6033546001600160a01b031633146108435760405162461bcd60e51b815260040161055e906124da565b61084d600061138b565b565b600054610100900460ff1661086a5760005460ff161561086e565b303b155b61088a5760405162461bcd60e51b815260040161055e906125fd565b600054610100900460ff161580156108ac576000805461ffff19166101011790555b6108b46113dd565b80156108c6576000805461ff00191690555b50565b6033546001600160a01b031633146108f35760405162461bcd60e51b815260040161055e906124da565b60005b818110156107a457600160976000858585818110610916576109166125b6565b905060200201602081019061092b9190612335565b6001600160a01b031681526020810191909152604001600020805460ff19169115159190911790558061095d816125e2565b9150506108f6565b6001600160a01b03821660009081526101026020908152604080832084845290915281205461099657506000610a18565b610108546001600160a01b03841660009081526101036020908152604080832086845290915281205490916109ca9161264b565b6001600160a01b0385166000908152610102602090815260408083208784529091529020546109f9919061266a565b61010854909150610a0a8242612682565b610a1491906126af565b9150505b92915050565b333214610a3d5760405162461bcd60e51b815260040161055e9061250f565b60fc546001600160a01b031615801590610a61575060fd546001600160a01b031615155b8015610a77575060fe546001600160a01b031615155b8015610a8d575060ff546001600160a01b031615155b8015610aa45750610100546001600160a01b031615155b610ac05760405162461bcd60e51b815260040161055e90612535565b60655460ff1615610ae35760405162461bcd60e51b815260040161055e90612563565b82151580610af057508015155b610b0c5760405162461bcd60e51b815260040161055e9061258d565b60005b83811015610b575760fe54610b45906001600160a01b0316868684818110610b3957610b396125b6565b90506020020135611442565b80610b4f816125e2565b915050610b0f565b5060005b818110156107015760ff54610b85906001600160a01b0316848484818110610b3957610b396125b6565b80610b8f816125e2565b915050610b5b565b333214610bb65760405162461bcd60e51b815260040161055e9061250f565b60fc546001600160a01b031615801590610bda575060fd546001600160a01b031615155b8015610bf0575060fe546001600160a01b031615155b8015610c06575060ff546001600160a01b031615155b8015610c1d5750610100546001600160a01b031615155b610c395760405162461bcd60e51b815260040161055e90612535565b60655460ff1615610c5c5760405162461bcd60e51b815260040161055e90612563565b82151580610c6957508015155b610c855760405162461bcd60e51b815260040161055e9061258d565b60005b83811015610cd05760fe54610cbe906001600160a01b0316868684818110610cb257610cb26125b6565b90506020020135611738565b80610cc8816125e2565b915050610c88565b5060005b818110156107015760ff54610cfe906001600160a01b0316848484818110610cb257610cb26125b6565b80610d08816125e2565b915050610cd4565b3360009081526097602052604090205460ff1680610d315750610d3161190f565b610d4d5760405162461bcd60e51b815260040161055e906126c3565b8015610d5b576108c6611933565b6108c66119a8565b333214610d825760405162461bcd60e51b815260040161055e9061250f565b60fc546001600160a01b031615801590610da6575060fd546001600160a01b031615155b8015610dbc575060fe546001600160a01b031615155b8015610dd2575060ff546001600160a01b031615155b8015610de95750610100546001600160a01b031615155b610e055760405162461bcd60e51b815260040161055e90612535565b60655460ff1615610e285760405162461bcd60e51b815260040161055e90612563565b82151580610e3557508015155b610e515760405162461bcd60e51b815260040161055e9061258d565b60005b83811015610e9c5760fe54610e8a906001600160a01b0316868684818110610e7e57610e7e6125b6565b90506020020135611a22565b80610e94816125e2565b915050610e54565b5060005b818110156107015760ff54610eca906001600160a01b0316848484818110610e7e57610e7e6125b6565b80610ed4816125e2565b915050610ea0565b3360009081526097602052604090205460ff1680610efd5750610efd61190f565b610f195760405162461bcd60e51b815260040161055e906126c3565b83838080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525050825115159150610f8c90505760405162461bcd60e51b815260206004820152600b60248201526a456d70747920617272617960a81b604482015260640161055e565b838214610fc95760405162461bcd60e51b815260206004820152600b60248201526a426164206c656e6774687360a81b604482015260640161055e565b610fd661010660006121b2565b6000805b858110156110d057848482818110610ff457610ff46125b6565b905060200201602081019061100991906126ef565b6110139083612715565b915061010687878381811061102a5761102a6125b6565b8354600181018555600094855260209485902091909402929092013591909201555084848281811061105e5761105e6125b6565b905060200201602081019061107391906126ef565b610107600089898581811061108a5761108a6125b6565b90506020020135815260200190815260200160002060006101000a81548163ffffffff021916908363ffffffff16021790555080806110c8906125e2565b915050610fda565b508063ffffffff16620186a01461111a5760405162461bcd60e51b815260206004820152600e60248201526d42616420746f74616c206f64647360901b604482015260640161055e565b505050505050565b3360009081526097602052604090205460ff1680611143575061114361190f565b61115f5760405162461bcd60e51b815260040161055e906126c3565b61010855565b6033546001600160a01b0316331461118f5760405162461bcd60e51b815260040161055e906124da565b6001600160a01b0381166111f45760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161055e565b6108c68161138b565b3360009081526097602052604090205460ff168061121e575061121e61190f565b61123a5760405162461bcd60e51b815260040161055e906126c3565b60fc80546001600160a01b03199081166001600160a01b039788161790915560fe805482169587169590951790945560ff80548516938616939093179092556101008054841691851691909117905560fd80549092169216919091179055565b6001600160a01b03821660009081526101016020908152604080832033845290915290206112c89082611c63565b506001600160a01b0382166000818152610102602090815260408083208584528252918290204290819055915191825283929133917f133489e9ddda3b16ddd3b9b961284c406b0a5da8cce1dc3ba03f7838764c93e7910160405180910390a4604051632142170760e11b8152336004820152306024820152604481018290526001600160a01b038316906342842e0e906064015b600060405180830381600087803b15801561137757600080fd5b505af115801561111a573d6000803e3d6000fd5b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff166113f85760005460ff16156113fc565b303b155b6114185760405162461bcd60e51b815260040161055e906125fd565b600054610100900460ff1615801561143a576000805461ffff19166101011790555b6108b4611c76565b6001600160a01b03821660009081526101016020908152604080832033845290915290206114709082611cff565b61148c5760405162461bcd60e51b815260040161055e9061273d565b610106546114d05760405162461bcd60e51b8152602060048201526011602482015270052657761726473206e6f7420736574757607c1b604482015260640161055e565b6001600160a01b038216600090815261010460209081526040808320848452909152902054806115395760405162461bcd60e51b81526020600482015260146024820152734e6f20636c61696d20696e2070726f677265737360601b604482015260640161055e565b60fd5460405163f030210760e01b8152600481018390526001600160a01b039091169063f03021079060240160206040518083038186803b15801561157d57600080fd5b505afa158015611591573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115b59190612768565b6115f45760405162461bcd60e51b815260206004820152601060248201526f52616e646f6d206e6f7420726561647960801b604482015260640161055e565b60fd54604051634ad30a7560e01b8152600481018390526000916001600160a01b031690634ad30a759060240160206040518083038186803b15801561163957600080fd5b505afa15801561164d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116719190612785565b6001600160a01b0385166000908152610105602090815260408083208784529091528120549192505b818110156116f55780156116d85760408051602081018590529081018290526060016040516020818303038152906040528051906020012060001c92505b6116e3868685611d17565b806116ed816125e2565b91505061169a565b5050506001600160a01b03909216600081815261010560209081526040808320858452825280832083905592825261010481528282209382529290925281205550565b6001600160a01b03821660009081526101016020908152604080832033845290915290206117669082611cff565b6117825760405162461bcd60e51b815260040161055e9061273d565b6001600160a01b038216600090815261010460209081526040808320848452909152902054156117e85760405162461bcd60e51b8152602060048201526011602482015270436c61696d20696e2070726f677265737360781b604482015260640161055e565b6117f28282610965565b1561183f5760405162461bcd60e51b815260206004820152601760248201527f52657761726473206c65667420756e636c61696d656421000000000000000000604482015260640161055e565b6001600160a01b038216600090815261010160209081526040808320338452909152902061186d9082611e63565b506001600160a01b038216600081815261010260209081526040808320858452825280832083905583835261010382528083208584529091528082208290555183929133917f0e0892e64dffe15b2a80856d3fa02b3b3df09de56739118dc5b9a6050b8d553f9190a4604051632142170760e11b8152306004820152336024820152604481018290526001600160a01b038316906342842e0e9060640161135d565b6000336119246033546001600160a01b031690565b6001600160a01b031614905090565b60655460ff16156119565760405162461bcd60e51b815260040161055e90612563565b6065805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25861198b3390565b6040516001600160a01b03909116815260200160405180910390a1565b60655460ff166119f15760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015260640161055e565b6065805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa3361198b565b6001600160a01b0382166000908152610101602090815260408083203384529091529020611a509082611cff565b611a6c5760405162461bcd60e51b815260040161055e9061273d565b6001600160a01b03821660009081526101046020908152604080832084845290915290205415611ad25760405162461bcd60e51b8152602060048201526011602482015270436c61696d20696e2070726f677265737360781b604482015260640161055e565b6000611ade8383610965565b905060008111611b265760405162461bcd60e51b81526020600482015260136024820152724e6f207265776172647320746f20636c61696d60681b604482015260640161055e565b6001600160a01b03831660009081526101036020908152604080832085845290915281208054839290611b5a90849061266a565b90915550506001600160a01b03808416600090815261010560209081526040808320868452825280832085905560fd54815163433c53d960e11b8152915193941692638678a7b29260048084019391929182900301818787803b158015611bc057600080fd5b505af1158015611bd4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bf89190612785565b6001600160a01b0385166000818152610104602090815260408083208884528252918290208490558151848152908101869052929350859233917f961177686f8f4c3873b7414b6f60339b49b32781a671d26be8a490508d4122b2910160405180910390a450505050565b6000611c6f8383611e6f565b9392505050565b600054610100900460ff16611c915760005460ff1615611c95565b303b155b611cb15760405162461bcd60e51b815260040161055e906125fd565b600054610100900460ff16158015611cd3576000805461ffff19166101011790555b611cdb611ebe565b611ce3611f23565b620151806101085580156108c6576000805461ff001916905550565b60008181526001830160205260408120541515611c6f565b6000611d26620186a08361279e565b905060008060005b61010654811015611e125760006101068281548110611d4f57611d4f6125b6565b6000918252602080832090910154808352610107909152604090912054909150611d7f9063ffffffff168561266a565b935083851015611dff5760fc54604051630ab714fb60e11b8152336004820152602481018390526001604482015291935083916001600160a01b039091169063156e29f690606401600060405180830381600087803b158015611de157600080fd5b505af1158015611df5573d6000803e3d6000fd5b5050505050611e12565b5080611e0a816125e2565b915050611d2e565b50604080518281526001602082015286916001600160a01b0389169133917f17db246e2b79d27e01c800967d89cbee46000807213e933b6e4c4fddac899a78910160405180910390a4505050505050565b6000611c6f8383611f52565b6000818152600183016020526040812054611eb657508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610a18565b506000610a18565b600054610100900460ff16611ed95760005460ff1615611edd565b303b155b611ef95760405162461bcd60e51b815260040161055e906125fd565b600054610100900460ff16158015611f1b576000805461ffff19166101011790555b6108b4612045565b600054610100900460ff16611f4a5760405162461bcd60e51b815260040161055e906127b2565b61084d6120ba565b6000818152600183016020526040812054801561203b576000611f76600183612682565b8554909150600090611f8a90600190612682565b9050818114611fef576000866000018281548110611faa57611faa6125b6565b9060005260206000200154905080876000018481548110611fcd57611fcd6125b6565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080612000576120006127fd565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610a18565b6000915050610a18565b600054610100900460ff166120605760005460ff1615612064565b303b155b6120805760405162461bcd60e51b815260040161055e906125fd565b600054610100900460ff161580156120a2576000805461ffff19166101011790555b6120aa6120e1565b6120b2612118565b6108b4611933565b600054610100900460ff1661084d5760405162461bcd60e51b815260040161055e906127b2565b600054610100900460ff166121085760405162461bcd60e51b815260040161055e906127b2565b6121106120ba565b61084d61214f565b600054610100900460ff1661213f5760405162461bcd60e51b815260040161055e906127b2565b6121476120ba565b61084d61217f565b600054610100900460ff166121765760405162461bcd60e51b815260040161055e906127b2565b61084d3361138b565b600054610100900460ff166121a65760405162461bcd60e51b815260040161055e906127b2565b6065805460ff19169055565b50805460008255906000526020600020908101906108c691905b808211156121e057600081556001016121cc565b5090565b80356001600160a01b03811681146121fb57600080fd5b919050565b6000806040838503121561221357600080fd5b61221c836121e4565b946020939093013593505050565b60006020828403121561223c57600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b6000806000806080858703121561226f57600080fd5b612278856121e4565b9350612286602086016121e4565b925060408501359150606085013567ffffffffffffffff808211156122aa57600080fd5b818701915087601f8301126122be57600080fd5b8135818111156122d0576122d0612243565b604051601f8201601f19908116603f011681019083821181831017156122f8576122f8612243565b816040528281528a602084870101111561231157600080fd5b82602086016020830137600060208483010152809550505050505092959194509250565b60006020828403121561234757600080fd5b611c6f826121e4565b60008083601f84011261236257600080fd5b50813567ffffffffffffffff81111561237a57600080fd5b6020830191508360208260051b850101111561239557600080fd5b9250929050565b600080600080604085870312156123b257600080fd5b843567ffffffffffffffff808211156123ca57600080fd5b6123d688838901612350565b909650945060208701359150808211156123ef57600080fd5b506123fc87828801612350565b95989497509550505050565b6000806020838503121561241b57600080fd5b823567ffffffffffffffff81111561243257600080fd5b61243e85828601612350565b90969095509350505050565b80151581146108c657600080fd5b60006020828403121561246a57600080fd5b8135611c6f8161244a565b600080600080600060a0868803121561248d57600080fd5b612496866121e4565b94506124a4602087016121e4565b93506124b2604087016121e4565b92506124c0606087016121e4565b91506124ce608087016121e4565b90509295509295909350565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252600c908201526b4e6f20636f6e74726163747360a01b604082015260600190565b60208082526014908201527310dbdb9d1c9858dd1cc8185c995b89dd081cd95d60621b604082015260600190565b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b6020808252600f908201526e3737903a37b5b2b7399033b4bb32b760891b604082015260600190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b60006000198214156125f6576125f66125cc565b5060010190565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b6000816000190483118215151615612665576126656125cc565b500290565b6000821982111561267d5761267d6125cc565b500190565b600082821015612694576126946125cc565b500390565b634e487b7160e01b600052601260045260246000fd5b6000826126be576126be612699565b500490565b6020808252601290820152712737ba1030b236b4b71037b91037bbb732b960711b604082015260600190565b60006020828403121561270157600080fd5b813563ffffffff81168114611c6f57600080fd5b600063ffffffff808316818516808303821115612734576127346125cc565b01949350505050565b6020808252601190820152702737ba1037bbb732b210313c903ab9b2b960791b604082015260600190565b60006020828403121561277a57600080fd5b8151611c6f8161244a565b60006020828403121561279757600080fd5b5051919050565b6000826127ad576127ad612699565b500690565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b634e487b7160e01b600052603160045260246000fdfea2646970667358221220c9fd061dc04ebbe43d2dce9f3e92138495099974156400060dcdff700d3435e164736f6c63430008090033

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.