ETH Price: $2,649.15 (+0.26%)

Contract

0x92fC3A00eb7f6d0b1152B96947460f0a9a70BE91
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
0x60806040152458242022-07-30 20:02:01812 days ago1659211321IN
 Create: HeroURIHandler
0 ETH0.0517388918.87164939

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
HeroURIHandler

Compiler Version
v0.8.13+commit.abaa5c0e

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 30 : HeroURIHandler.sol
// SPDX-License-Identifier: MIT

/// @title RaidParty Hero URI Handler

/**
 *   ___      _    _ ___          _
 *  | _ \__ _(_)__| | _ \__ _ _ _| |_ _  _
 *  |   / _` | / _` |  _/ _` | '_|  _| || |
 *  |_|_\__,_|_\__,_|_| \__,_|_|  \__|\_, |
 *                                    |__/
 */

pragma solidity ^0.8.0;

import "@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/access/AccessControlEnumerableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC721/utils/ERC721HolderUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol";
import "../utils/Enhanceable.sol";
import "../interfaces/IHeroURIHandler.sol";
import "../interfaces/IHero.sol";
import "../interfaces/IERC20Burnable.sol";
import "../interfaces/IGuildURIHandler.sol";

contract HeroURIHandler is
    IHeroURIHandler,
    Initializable,
    Enhanceable,
    AccessControlEnumerableUpgradeable,
    ERC721HolderUpgradeable
{
    using StringsUpgradeable for uint256;

    // Contract state and constants
    uint8 public constant MAX_DMG_MULTIPLIER = 17;
    uint8 public constant MIN_DMG_MULTIPLIER = 12;
    uint8 public constant MIN_DMG_MULTIPLIER_GENESIS = 13;
    uint8 public constant MAX_PARTY_SIZE = 6;
    uint8 public constant MIN_PARTY_SIZE = 4;
    uint8 public constant MAX_ENHANCEMENT = 14;
    uint8 public constant MIN_ENHANCEMENT = 0;

    mapping(uint256 => uint8) private _enhancement;
    IERC20Burnable private _confetti;
    address private _team;
    bool private _paused;

    IGuildURIHandler private _guild;
    bytes32 public constant CALL_FOR_ROLE = keccak256("CALL_FOR_ROLE");

    modifier whenNotPaused() {
        require(!_paused, "FighterURIHandler: contract paused");
        _;
    }

    /** PUBLIC */

    function initialize(
        address admin,
        address seeder,
        address hero,
        address confetti
    ) public initializer {
        __AccessControl_init();
        _setupRole(DEFAULT_ADMIN_ROLE, admin);
        __Enhanceable_init(seeder, hero);
        _confetti = IERC20Burnable(confetti);
        _team = admin;
        _paused = true;
    }

    // Returns on-chain stats for a given token
    function getStats(uint256 tokenId)
        public
        view
        override
        returns (Stats.HeroStats memory)
    {
        uint256 seed = _seeder.getSeedSafe(address(_token), tokenId);
        uint8 enh = _enhancement[tokenId];
        uint8 adjustment = _getPartySizeAdjustment(enh);

        if (tokenId <= 1111) {
            uint8 dmgMulRange = MAX_DMG_MULTIPLIER -
                MIN_DMG_MULTIPLIER_GENESIS +
                1;

            return
                Stats.HeroStats(
                    MIN_DMG_MULTIPLIER_GENESIS + 1 + uint8(seed % dmgMulRange),
                    6 + adjustment,
                    enh
                );
        } else {
            uint8 dmgMulRange = MAX_DMG_MULTIPLIER - MIN_DMG_MULTIPLIER + 1;
            uint8 pSizeRange = MAX_PARTY_SIZE - MIN_PARTY_SIZE + 1;

            return
                Stats.HeroStats(
                    MIN_DMG_MULTIPLIER + uint8(seed % dmgMulRange),
                    MIN_PARTY_SIZE +
                        adjustment +
                        uint8(
                            uint256(keccak256(abi.encodePacked(seed))) %
                                pSizeRange
                        ),
                    enh
                );
        }
    }

    // Returns the seeder contract address
    function getSeeder() external view override returns (address) {
        return address(_seeder);
    }

    // Sets the seeder contract address
    function setSeeder(address seeder) external onlyRole(DEFAULT_ADMIN_ROLE) {
        _setSeeder(seeder);
    }

    // Returns the guild contract address
    function getGuild() external view override returns (address) {
        return address(_guild);
    }

    // Sets the guild contract address
    function setGuild(IGuildURIHandler guild)
        external
        onlyRole(DEFAULT_ADMIN_ROLE)
    {
        _guild = guild;
    }

    // Returns the token URI for off-chain cosmetic data
    function tokenURI(uint256 tokenId) public pure returns (string memory) {
        return string(abi.encodePacked(_baseURI(), tokenId.toString()));
    }

    /** ENHANCEMENT */

    // Returns enhancement cost in confetti, and whether a token must be burned
    function enhancementCost(uint256 tokenId)
        external
        view
        override(IEnhanceable, Enhanceable)
        returns (uint256, bool)
    {
        return (
            _getEnhancementCost(_enhancement[tokenId]),
            _enhancement[tokenId] > 3
        );
    }

    function enhance(uint256 tokenId, uint256 burnTokenId)
        public
        override(IEnhanceable, Enhanceable)
        whenNotPaused
    {
        _enhance(tokenId, burnTokenId, msg.sender);
    }

    function enhanceFor(
        uint256 tokenId,
        uint256 burnTokenId,
        address user
    ) public override whenNotPaused onlyRole(CALL_FOR_ROLE) {
        _enhance(tokenId, burnTokenId, user);
    }

    function reveal(uint256[] calldata tokenIds) public override whenNotPaused {
        _reveal(tokenIds, msg.sender);
    }

    function revealFor(uint256[] calldata tokenIds, address user)
        public
        override
        whenNotPaused
        onlyRole(CALL_FOR_ROLE)
    {
        _reveal(tokenIds, user);
    }

    function pause() external onlyRole(DEFAULT_ADMIN_ROLE) {
        _paused = true;
    }

    function unpause() external onlyRole(DEFAULT_ADMIN_ROLE) {
        _paused = false;
    }

    function isGenesis(uint256 tokenId) external pure returns (bool) {
        return tokenId <= 1111;
    }

    /** INTERNAL */

    function _getPartySizeAdjustment(uint8 enhancement)
        internal
        pure
        returns (uint8 adjustment)
    {
        if (enhancement >= 5) {
            adjustment = enhancement - 4;
        }
    }

    function _baseURI() internal pure returns (string memory) {
        return "https://api.raid.party/metadata/hero/";
    }

    function _getEnhancementCost(uint256 enh) internal pure returns (uint256) {
        if (enh == 0) {
            return 250 * 10**18;
        } else if (enh == 1) {
            return 500 * 10**18;
        } else if (enh == 2) {
            return 750 * 10**18;
        } else if (enh == 3) {
            return 1000 * 10**18;
        } else if (enh == 4) {
            return 1250 * 10**18;
        } else if (enh == 5) {
            return 1500 * 10**18;
        } else if (enh == 6) {
            return 1750 * 10**18;
        } else if (enh == 7) {
            return 2000 * 10**18;
        } else if (enh == 8) {
            return 2250 * 10**18;
        } else if (enh == 9) {
            return 2500 * 10**18;
        } else if (enh == 10) {
            return 2500 * 10**18;
        } else if (enh == 11) {
            return 2500 * 10**18;
        } else if (enh == 12) {
            return 2500 * 10**18;
        } else if (enh == 13) {
            return 2500 * 10**18;
        } else {
            return type(uint256).max;
        }
    }

    function _getEnhancementOdds(uint256 enh) internal pure returns (uint256) {
        if (enh == 0) {
            return 9000;
        } else if (enh == 1) {
            return 8500;
        } else if (enh == 2) {
            return 8000;
        } else if (enh == 3) {
            return 7500;
        } else if (enh == 4) {
            return 7000;
        } else if (enh == 5) {
            return 6500;
        } else if (enh == 6) {
            return 6000;
        } else if (enh == 7) {
            return 5500;
        } else if (enh == 8) {
            return 5000;
        } else {
            return 2500;
        }
    }

    function _getEnhancementDegredationOdds(uint256 enh)
        internal
        pure
        returns (uint256)
    {
        if (enh == 0) {
            return 0;
        } else if (enh == 1) {
            return 500;
        } else if (enh == 2) {
            return 1000;
        } else if (enh == 3) {
            return 1500;
        } else if (enh == 4) {
            return 2000;
        } else if (enh == 5) {
            return 2500;
        } else if (enh == 6) {
            return 3000;
        } else if (enh == 7) {
            return 3500;
        } else if (enh == 8) {
            return 4000;
        } else {
            return 5000;
        }
    }

    function _enhance(
        uint256 tokenId,
        uint256 burnTokenId,
        address user
    ) internal {
        require(
            tokenId != burnTokenId,
            "HeroURIHandler::enhance: target token cannot equal burn token"
        );
        require(
            msg.sender == _token.ownerOf(tokenId),
            "HeroURIHandler::enhance: enhancer must be token owner"
        );
        uint8 enhancement = _enhancement[tokenId];
        require(
            enhancement < MAX_ENHANCEMENT,
            "HeroURIHandler::enhance: max enhancement reached"
        );

        uint256 cost = _getEnhancementCost(enhancement);
        uint256 guildId = _guild.getGuild(user);
        if (guildId != 0) {
            cost -=
                (cost *
                    _guild.getGuildTechLevel(
                        guildId,
                        IGuildURIHandler.Branch.FRUGALITY
                    )) /
                200;
        }

        uint256 teamAmount = (cost * 15) / 100;
        _confetti.transferFrom(msg.sender, _team, teamAmount);
        _confetti.burnFrom(msg.sender, cost - teamAmount);

        if (enhancement > 3) {
            _token.safeTransferFrom(msg.sender, address(this), burnTokenId);
            _token.burn(burnTokenId);
        }

        super.enhance(tokenId, burnTokenId);
    }

    function _reveal(uint256[] calldata tokenIds, address user) internal {
        unchecked {
            uint256 guildId = _guild.getGuild(user);
            uint256 indemnityBuff;
            uint256 superstitionBuff;
            uint256 fortuneBuff;

            if (guildId != 0) {
                IGuildURIHandler.TechTree memory tree = _guild.getGuildTechTree(
                    guildId
                );

                // INDEMNITY: Second-wind chance on failure
                // 1% | 2% | 3% | 4% | 10%
                indemnityBuff =
                    ((tree.indemnity == 5) ? 10 : tree.indemnity) *
                    100;

                // SUPERSTITION: Downgrade chance decrease
                // 1% | 2% | 3% | 4% | 5%
                superstitionBuff = tree.superstition * 100;

                // FORTUNE: Enhancement success chance increase
                // 1% | 2% | 3% | 4% | 5%
                fortuneBuff = tree.fortune * 100;
            }

            uint8[] memory enhancements = new uint8[](tokenIds.length);
            for (uint256 i = 0; i < tokenIds.length; i++) {
                require(
                    _token.ownerOf(tokenIds[i]) == msg.sender,
                    "HeroURIHandler::reveal: revealer not owner"
                );

                enhancements[i] = _enhancement[tokenIds[i]];

                uint256 successOdds = _getEnhancementOdds(enhancements[i]);
                successOdds = MathUpgradeable.min(
                    10000,
                    successOdds + fortuneBuff
                );

                uint256 degradeOdds = _getEnhancementDegredationOdds(
                    enhancements[i]
                );
                degradeOdds = (superstitionBuff >= degradeOdds ||
                    enhancements[i] <= MIN_ENHANCEMENT)
                    ? 0
                    : degradeOdds - superstitionBuff;

                (bool success, bool degraded) = _rollEnhancement(
                    _getSeed(tokenIds[i]),
                    successOdds,
                    degradeOdds,
                    indemnityBuff
                );

                if (success) {
                    _enhancement[tokenIds[i]] += 1;
                } else if (degraded) {
                    _enhancement[tokenIds[i]] -= 1;
                }

                emit EnhancementCompleted(
                    tokenIds[i],
                    block.timestamp,
                    success,
                    degraded
                );
            }

            super._reveal(tokenIds);

            require(
                _checkOnEnhancement(tokenIds, enhancements),
                "Enhanceable::reveal: reveal for unsupported contract"
            );
        }
    }

    function _rollEnhancement(
        uint256 seed,
        uint256 successOdds,
        uint256 degradeOdds,
        uint256 secondWindOdds
    ) internal pure returns (bool, bool) {
        bool success = false;
        bool degraded = false;

        // Roll for success using initial seed
        if (successOdds >= 10000 || _roll(seed, successOdds)) {
            success = true;
        } else {
            seed = uint256(keccak256(abi.encode(seed)));
            if (secondWindOdds > 0 && _roll(seed, secondWindOdds)) {
                // Attempt a static second-wind roll with new seed if indemnity has
                // been leveled up, otherwise continue with degrade roll.
                success = true;
            } else if (
                // Attempt another independent roll for enhancement downgrade
                degradeOdds > 0 &&
                _roll(uint256(keccak256(abi.encode(seed))), degradeOdds)
            ) {
                degraded = true;
            }
        }

        return (success, degraded);
    }
}

File 2 of 30 : StringsUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)

pragma solidity ^0.8.0;

/**
 * @dev String operations.
 */
library StringsUpgradeable {
    bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        // Inspired by OraclizeAPI's implementation - MIT licence
        // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol

        if (value == 0) {
            return "0";
        }
        uint256 temp = value;
        uint256 digits;
        while (temp != 0) {
            digits++;
            temp /= 10;
        }
        bytes memory buffer = new bytes(digits);
        while (value != 0) {
            digits -= 1;
            buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
            value /= 10;
        }
        return string(buffer);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        if (value == 0) {
            return "0x00";
        }
        uint256 temp = value;
        uint256 length = 0;
        while (temp != 0) {
            length++;
            temp >>= 8;
        }
        return toHexString(value, length);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = _HEX_SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }
}

File 3 of 30 : Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (proxy/utils/Initializable.sol)

pragma solidity ^0.8.2;

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 proxied contracts do not make use of 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.
 *
 * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
 * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
 * case an upgrade adds a module that needs to be initialized.
 *
 * For example:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * contract MyToken is ERC20Upgradeable {
 *     function initialize() initializer public {
 *         __ERC20_init("MyToken", "MTK");
 *     }
 * }
 * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
 *     function initializeV2() reinitializer(2) public {
 *         __ERC20Permit_init("MyToken");
 *     }
 * }
 * ```
 *
 * 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 prevent the implementation contract from being used, you should invoke
 * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * /// @custom:oz-upgrades-unsafe-allow constructor
 * constructor() {
 *     _disableInitializers();
 * }
 * ```
 * ====
 */
abstract contract Initializable {
    /**
     * @dev Indicates that the contract has been initialized.
     * @custom:oz-retyped-from bool
     */
    uint8 private _initialized;

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

    /**
     * @dev Triggered when the contract has been initialized or reinitialized.
     */
    event Initialized(uint8 version);

    /**
     * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
     * `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`.
     */
    modifier initializer() {
        bool isTopLevelCall = _setInitializedVersion(1);
        if (isTopLevelCall) {
            _initializing = true;
        }
        _;
        if (isTopLevelCall) {
            _initializing = false;
            emit Initialized(1);
        }
    }

    /**
     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
     * used to initialize parent contracts.
     *
     * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original
     * initialization step. This is essential to configure modules that are added through upgrades and that require
     * initialization.
     *
     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
     * a contract, executing them in the right order is up to the developer or operator.
     */
    modifier reinitializer(uint8 version) {
        bool isTopLevelCall = _setInitializedVersion(version);
        if (isTopLevelCall) {
            _initializing = true;
        }
        _;
        if (isTopLevelCall) {
            _initializing = false;
            emit Initialized(version);
        }
    }

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

    /**
     * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
     * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
     * to any version. It is recommended to use this to lock implementation contracts that are designed to be called
     * through proxies.
     */
    function _disableInitializers() internal virtual {
        _setInitializedVersion(type(uint8).max);
    }

    function _setInitializedVersion(uint8 version) private returns (bool) {
        // 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, and for the lowest level
        // of initializers, because in other contexts the contract may have been reentered.
        if (_initializing) {
            require(
                version == 1 && !AddressUpgradeable.isContract(address(this)),
                "Initializable: contract is already initialized"
            );
            return false;
        } else {
            require(_initialized < version, "Initializable: contract is already initialized");
            _initialized = version;
            return true;
        }
    }
}

File 4 of 30 : AccessControlEnumerableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (access/AccessControlEnumerable.sol)

pragma solidity ^0.8.0;

import "./IAccessControlEnumerableUpgradeable.sol";
import "./AccessControlUpgradeable.sol";
import "../utils/structs/EnumerableSetUpgradeable.sol";
import "../proxy/utils/Initializable.sol";

/**
 * @dev Extension of {AccessControl} that allows enumerating the members of each role.
 */
abstract contract AccessControlEnumerableUpgradeable is Initializable, IAccessControlEnumerableUpgradeable, AccessControlUpgradeable {
    function __AccessControlEnumerable_init() internal onlyInitializing {
    }

    function __AccessControlEnumerable_init_unchained() internal onlyInitializing {
    }
    using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet;

    mapping(bytes32 => EnumerableSetUpgradeable.AddressSet) private _roleMembers;

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

    /**
     * @dev Returns one of the accounts that have `role`. `index` must be a
     * value between 0 and {getRoleMemberCount}, non-inclusive.
     *
     * Role bearers are not sorted in any particular way, and their ordering may
     * change at any point.
     *
     * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
     * you perform all queries on the same block. See the following
     * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
     * for more information.
     */
    function getRoleMember(bytes32 role, uint256 index) public view virtual override returns (address) {
        return _roleMembers[role].at(index);
    }

    /**
     * @dev Returns the number of accounts that have `role`. Can be used
     * together with {getRoleMember} to enumerate all bearers of a role.
     */
    function getRoleMemberCount(bytes32 role) public view virtual override returns (uint256) {
        return _roleMembers[role].length();
    }

    /**
     * @dev Overload {_grantRole} to track enumerable memberships
     */
    function _grantRole(bytes32 role, address account) internal virtual override {
        super._grantRole(role, account);
        _roleMembers[role].add(account);
    }

    /**
     * @dev Overload {_revokeRole} to track enumerable memberships
     */
    function _revokeRole(bytes32 role, address account) internal virtual override {
        super._revokeRole(role, account);
        _roleMembers[role].remove(account);
    }

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[49] private __gap;
}

File 5 of 30 : 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 {
    }

    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;
    }

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[50] private __gap;
}

File 6 of 30 : MathUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (utils/math/Math.sol)

pragma solidity ^0.8.0;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library MathUpgradeable {
    /**
     * @dev Returns the largest of two numbers.
     */
    function max(uint256 a, uint256 b) internal pure returns (uint256) {
        return a >= b ? a : b;
    }

    /**
     * @dev Returns the smallest of two numbers.
     */
    function min(uint256 a, uint256 b) internal pure returns (uint256) {
        return a < b ? a : b;
    }

    /**
     * @dev Returns the average of two numbers. The result is rounded towards
     * zero.
     */
    function average(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b) / 2 can overflow.
        return (a & b) + (a ^ b) / 2;
    }

    /**
     * @dev Returns the ceiling of the division of two numbers.
     *
     * This differs from standard division with `/` in that it rounds up instead
     * of rounding down.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b - 1) / b can overflow on addition, so we distribute.
        return a / b + (a % b == 0 ? 0 : 1);
    }
}

File 7 of 30 : Enhanceable.sol
// SPDX-License-Identifier: MIT

/// @title RaidParty Helper Contract for Enhanceability

/**
 *   ___      _    _ ___          _
 *  | _ \__ _(_)__| | _ \__ _ _ _| |_ _  _
 *  |   / _` | / _` |  _/ _` | '_|  _| || |
 *  |_|_\__,_|_\__,_|_| \__,_|_|  \__|\_, |
 *                                    |__/
 */

pragma solidity ^0.8.0;

import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol";
import "../interfaces/ISeeder.sol";
import "../interfaces/IEnhancer.sol";
import "../randomness/Seedable.sol";
import "../interfaces/IRaidERC721.sol";

abstract contract Enhanceable is Initializable, Seedable {
    using AddressUpgradeable for address;

    struct EnhancementRequest {
        uint256 id;
        address requester;
    }

    event EnhancementRequested(
        uint256 indexed tokenId,
        uint256 indexed timestamp
    );

    event EnhancementCompleted(
        uint256 indexed tokenId,
        uint256 indexed timestamp,
        bool success,
        bool degraded
    );

    event SeederUpdated(address indexed caller, address indexed seeder);

    mapping(uint256 => EnhancementRequest) private _enhancements;
    uint256 private _enhancementCounter;
    ISeeder internal _seeder;
    IRaidERC721 internal _token;

    function __Enhanceable_init(address seeder, address token)
        public
        initializer
    {
        _seeder = ISeeder(seeder);
        _token = IRaidERC721(token);
        _enhancementCounter = 1;
    }

    function getEnhancementRequest(uint256 tokenId)
        external
        view
        virtual
        returns (EnhancementRequest memory)
    {
        return _enhancements[tokenId];
    }

    function enhancementCost(uint256 tokenId)
        external
        view
        virtual
        returns (uint256, bool);

    function enhance(uint256 tokenId, uint256) public virtual {
        require(
            _enhancements[tokenId].requester == address(0),
            "Enhanceable::enhance: token bound to pending request"
        );
        _enhancements[tokenId] = EnhancementRequest(
            _enhancementCounter,
            msg.sender
        );
        _seeder.requestSeed(_enhancementCounter);
        unchecked {
            _enhancementCounter += 1;
        }
        emit EnhancementRequested(tokenId, block.timestamp);
    }

    function reveal(uint256[] calldata ids) public virtual;

    // Caller must emit and determine resultant state before calling super
    function _reveal(uint256[] calldata ids) internal {
        unchecked {
            for (uint256 i = 0; i < ids.length; i++) {
                delete _enhancements[ids[i]];
            }
        }
    }

    function _checkOnEnhancement(uint256[] memory tokenIds, uint8[] memory prev)
        internal
        returns (bool)
    {
        require(
            tokenIds.length == prev.length,
            "Enhanceable: update array length mismatch"
        );
        address owner = _token.ownerOf(tokenIds[0]);

        for (uint256 i = 0; i < tokenIds.length; i++) {
            require(
                _token.ownerOf(tokenIds[i]) == owner,
                "Enhanceable: tokens not owned by same owner"
            );
        }

        if (owner.isContract()) {
            try IEnhancer(owner).onEnhancement(tokenIds, prev) returns (
                bytes4 retval
            ) {
                return retval == IEnhancer.onEnhancement.selector;
            } catch (bytes memory reason) {
                if (reason.length == 0) {
                    revert("Enhanceable: transfer to non Enhancer implementer");
                } else {
                    assembly {
                        revert(add(32, reason), mload(reason))
                    }
                }
            }
        } else {
            return true;
        }
    }

    function _roll(uint256 seed, uint256 probability)
        internal
        pure
        returns (bool)
    {
        if (seed % 10000 < probability) {
            return true;
        } else {
            return false;
        }
    }

    function _getSeed(uint256 tokenId) internal view returns (uint256) {
        return _seeder.getSeedSafe(address(this), _enhancements[tokenId].id);
    }

    function _setSeeder(address seeder) internal {
        _seeder = ISeeder(seeder);
        emit SeederUpdated(msg.sender, seeder);
    }
}

File 8 of 30 : IHeroURIHandler.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./IEnhanceable.sol";
import "../lib/Stats.sol";

interface IHeroURIHandler is IEnhanceable {
    function tokenURI(uint256 tokenId) external view returns (string memory);

    function getStats(uint256 tokenId)
        external
        view
        returns (Stats.HeroStats memory);

    function getSeeder() external view returns (address);

    function enhanceFor(
        uint256 tokenId,
        uint256 burnTokenId,
        address user
    ) external;

    function revealFor(uint256[] calldata tokenIds, address user) external;

    function getGuild() external view returns (address);
}

File 9 of 30 : IHero.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./IRaidERC721.sol";
import "./IHeroURIHandler.sol";
import "./ISeeder.sol";

interface IHero is IRaidERC721 {
    event HandlerUpdated(address indexed caller, address indexed handler);

    function setHandler(IHeroURIHandler handler) external;

    function getHandler() external view returns (address);

    function getSeeder() external view returns (address);
}

File 10 of 30 : IERC20Burnable.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

interface IERC20Burnable is IERC20 {
    function mint(address to, uint256 amount) external;

    function burn(uint256 amount) external;

    function burnFrom(address account, uint256 amount) external;
}

File 11 of 30 : IGuildURIHandler.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface IGuildURIHandler {
    /**
     * @notice Branches represent various guild buffs
     * each of which are capped at level 5
     *
     * FRUGALITY: Rebate on CFTI sinks
     * 0.5% | 1% | 1.5% | 2% | 2.5%
     *
     * DISCIPLINE: Flat damage buff
     * 2 * heroBaseDmg * (heroLevel + 1) * perkLevel
     *
     * MORALE: Damage multiplier
     * 1.5% | 3% | 5% | 7% | 10%
     *
     * INDEMNITY: Second-wind chance on failure
     * 1% | 2% | 3% | 4% | 10%
     *
     * SUPERSTITION: Downgrade chance decrease
     * 1% | 2% | 3% | 4% | 5%
     *
     * FORTUNE: Enhancement success chance increase
     * 1% | 2% | 3% | 4% | 5%
     *
     */
    // NOTE: Keep in sync with `struct TechTree`
    enum Branch {
        FRUGALITY,
        DISCIPLINE,
        MORALE,
        INDEMNITY,
        SUPERSTITION,
        FORTUNE
    }

    /** STRUCTS */

    /**
     * @notice Below is documentation on Member struct elements.
     *
     * @param guildId       current active guild ID
     * @param vault         current vault balance
     * @param lastForage    last forage timestamp
     * @param hero          current staked hero
     * @param slot          current slot in guild membership array
     * @param permissions   permissions bitmap for current guild
     *
     */
    struct Member {
        uint256 guildId;
        uint64 vault;
        uint64 lastForage;
        uint32 hero;
        uint16 slot;
        uint8 permissions;
    }

    /**
     * @notice Below is documentation on Guild struct elements.
     *
     * @param balance  current guild GCFTI balance
     * @param vault    cumulative vault holdings of guild members
     * @param level    current guild level
     * @param techTree compact set of tech tree levels for each branch
     * @param members  array of guild members
     *
     */
    struct Guild {
        uint64 balance;
        uint64 vault;
        uint16 level;
        uint256 techTree;
        bytes32 name;
        address[] members;
    }

    struct Invite {
        address user;
        uint256 guildId;
        uint256 timeout;
    }

    // NOTE: Keep in sync with `enum Branch`
    struct TechTree {
        uint16 frugality;
        uint16 discipline;
        uint16 morale;
        uint16 indemnity;
        uint16 superstition;
        uint16 fortune;
        uint160 _scratch;
    }

    /** FUNCTIONS */

    function tokenURI(uint256 tokenId) external view returns (string memory);

    function getMembers(uint256 guildId)
        external
        view
        returns (address[] memory);

    function getGuildLevel(uint256 guildId) external view returns (uint16);

    function getGuildTechLevel(uint256 guildId, Branch branch)
        external
        view
        returns (uint16);

    function getGuildVault(uint256 guildId) external view returns (uint64);

    function getGuildBalance(uint256 guildId) external view returns (uint64);

    function getGuildData(uint256 guildId)
        external
        view
        returns (
            uint64 balance,
            uint16 level,
            uint64 vault,
            TechTree memory techTree,
            address[] memory members,
            string memory name
        );

    function getMember(address user) external view returns (Member memory);

    function getGuild(address user) external view returns (uint256);

    function calculateRewards(uint256 rewards, uint256 guildId)
        external
        view
        returns (uint64);

    function getGuildTechTree(uint256 guildId)
        external
        view
        returns (TechTree memory);

    function mint(address user, uint64 amount) external;
}

File 12 of 30 : AddressUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @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
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 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 13 of 30 : IAccessControlEnumerableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControlEnumerable.sol)

pragma solidity ^0.8.0;

import "./IAccessControlUpgradeable.sol";

/**
 * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.
 */
interface IAccessControlEnumerableUpgradeable is IAccessControlUpgradeable {
    /**
     * @dev Returns one of the accounts that have `role`. `index` must be a
     * value between 0 and {getRoleMemberCount}, non-inclusive.
     *
     * Role bearers are not sorted in any particular way, and their ordering may
     * change at any point.
     *
     * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
     * you perform all queries on the same block. See the following
     * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
     * for more information.
     */
    function getRoleMember(bytes32 role, uint256 index) external view returns (address);

    /**
     * @dev Returns the number of accounts that have `role`. Can be used
     * together with {getRoleMember} to enumerate all bearers of a role.
     */
    function getRoleMemberCount(bytes32 role) external view returns (uint256);
}

File 14 of 30 : AccessControlUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (access/AccessControl.sol)

pragma solidity ^0.8.0;

import "./IAccessControlUpgradeable.sol";
import "../utils/ContextUpgradeable.sol";
import "../utils/StringsUpgradeable.sol";
import "../utils/introspection/ERC165Upgradeable.sol";
import "../proxy/utils/Initializable.sol";

/**
 * @dev Contract module that allows children to implement role-based access
 * control mechanisms. This is a lightweight version that doesn't allow enumerating role
 * members except through off-chain means by accessing the contract event logs. Some
 * applications may benefit from on-chain enumerability, for those cases see
 * {AccessControlEnumerable}.
 *
 * Roles are referred to by their `bytes32` identifier. These should be exposed
 * in the external API and be unique. The best way to achieve this is by
 * using `public constant` hash digests:
 *
 * ```
 * bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
 * ```
 *
 * Roles can be used to represent a set of permissions. To restrict access to a
 * function call, use {hasRole}:
 *
 * ```
 * function foo() public {
 *     require(hasRole(MY_ROLE, msg.sender));
 *     ...
 * }
 * ```
 *
 * Roles can be granted and revoked dynamically via the {grantRole} and
 * {revokeRole} functions. Each role has an associated admin role, and only
 * accounts that have a role's admin role can call {grantRole} and {revokeRole}.
 *
 * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
 * that only accounts with this role will be able to grant or revoke other
 * roles. More complex role relationships can be created by using
 * {_setRoleAdmin}.
 *
 * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
 * grant and revoke this role. Extra precautions should be taken to secure
 * accounts that have been granted it.
 */
abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControlUpgradeable, ERC165Upgradeable {
    function __AccessControl_init() internal onlyInitializing {
    }

    function __AccessControl_init_unchained() internal onlyInitializing {
    }
    struct RoleData {
        mapping(address => bool) members;
        bytes32 adminRole;
    }

    mapping(bytes32 => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

    /**
     * @dev Modifier that checks that an account has a specific role. Reverts
     * with a standardized message including the required role.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     *
     * _Available since v4.1._
     */
    modifier onlyRole(bytes32 role) {
        _checkRole(role);
        _;
    }

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

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) public view virtual override returns (bool) {
        return _roles[role].members[account];
    }

    /**
     * @dev Revert with a standard message if `_msgSender()` is missing `role`.
     * Overriding this function changes the behavior of the {onlyRole} modifier.
     *
     * Format of the revert message is described in {_checkRole}.
     *
     * _Available since v4.6._
     */
    function _checkRole(bytes32 role) internal view virtual {
        _checkRole(role, _msgSender());
    }

    /**
     * @dev Revert with a standard message if `account` is missing `role`.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     */
    function _checkRole(bytes32 role, address account) internal view virtual {
        if (!hasRole(role, account)) {
            revert(
                string(
                    abi.encodePacked(
                        "AccessControl: account ",
                        StringsUpgradeable.toHexString(uint160(account), 20),
                        " is missing role ",
                        StringsUpgradeable.toHexString(uint256(role), 32)
                    )
                )
            );
        }
    }

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {
        return _roles[role].adminRole;
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
        _grantRole(role, account);
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
        _revokeRole(role, account);
    }

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been revoked `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     */
    function renounceRole(bytes32 role, address account) public virtual override {
        require(account == _msgSender(), "AccessControl: can only renounce roles for self");

        _revokeRole(role, account);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event. Note that unlike {grantRole}, this function doesn't perform any
     * checks on the calling account.
     *
     * [WARNING]
     * ====
     * This function should only be called from the constructor when setting
     * up the initial roles for the system.
     *
     * Using this function in any other way is effectively circumventing the admin
     * system imposed by {AccessControl}.
     * ====
     *
     * NOTE: This function is deprecated in favor of {_grantRole}.
     */
    function _setupRole(bytes32 role, address account) internal virtual {
        _grantRole(role, account);
    }

    /**
     * @dev Sets `adminRole` as ``role``'s admin role.
     *
     * Emits a {RoleAdminChanged} event.
     */
    function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
        bytes32 previousAdminRole = getRoleAdmin(role);
        _roles[role].adminRole = adminRole;
        emit RoleAdminChanged(role, previousAdminRole, adminRole);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * Internal function without access restriction.
     */
    function _grantRole(bytes32 role, address account) internal virtual {
        if (!hasRole(role, account)) {
            _roles[role].members[account] = true;
            emit RoleGranted(role, account, _msgSender());
        }
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * Internal function without access restriction.
     */
    function _revokeRole(bytes32 role, address account) internal virtual {
        if (hasRole(role, account)) {
            _roles[role].members[account] = false;
            emit RoleRevoked(role, account, _msgSender());
        }
    }

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[49] private __gap;
}

File 15 of 30 : EnumerableSetUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (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 30 : IERC721ReceiverUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (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 `IERC721Receiver.onERC721Received.selector`.
     */
    function onERC721Received(
        address operator,
        address from,
        uint256 tokenId,
        bytes calldata data
    ) external returns (bytes4);
}

File 17 of 30 : ISeeder.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "../lib/Randomness.sol";

interface ISeeder {
    event Requested(address indexed origin, uint256 indexed identifier);

    event Seeded(bytes32 identifier, uint256 randomness);

    function getIdReferenceCount(
        bytes32 randomnessId,
        address origin,
        uint256 startIdx
    ) external view returns (uint256);

    function getIdentifiers(
        bytes32 randomnessId,
        address origin,
        uint256 startIdx,
        uint256 count
    ) external view returns (uint256[] memory);

    function requestSeed(uint256 identifier) external;

    function getSeed(address origin, uint256 identifier)
        external
        view
        returns (uint256);

    function getSeedSafe(address origin, uint256 identifier)
        external
        view
        returns (uint256);

    function executeRequestMulti() external;

    function isSeeded(address origin, uint256 identifier)
        external
        view
        returns (bool);

    function setFee(uint256 fee) external;

    function getFee() external view returns (uint256);

    function getData(address origin, uint256 identifier)
        external
        view
        returns (Randomness.SeedData memory);
}

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

interface IEnhancer {
    function onEnhancement(uint256[] calldata, uint8[] calldata)
        external
        returns (bytes4);
}

File 19 of 30 : Seedable.sol
// SPDX-License-Identifier: MIT

/// @title RaidParty Helper Contract for Seedability

/**
 *   ___      _    _ ___          _
 *  | _ \__ _(_)__| | _ \__ _ _ _| |_ _  _
 *  |   / _` | / _` |  _/ _` | '_|  _| || |
 *  |_|_\__,_|_\__,_|_| \__,_|_|  \__|\_, |
 *                                    |__/
 */

pragma solidity ^0.8.0;

abstract contract Seedable {
    function _validateSeed(uint256 id) internal pure {
        require(id != 0, "Seedable: not seeded");
    }
}

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

import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol";

interface IRaidERC721 is IERC721 {
    function getSeeder() external view returns (address);

    function burn(uint256 tokenId) external;

    function tokensOfOwner(address owner)
        external
        view
        returns (uint256[] memory);

    function mint(address owner, uint256 amount) external;

    function totalSupply() external view returns (uint256);
}

File 21 of 30 : IEnhanceable.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface IEnhanceable {
    function enhancementCost(uint256 tokenId)
        external
        view
        returns (uint256, bool);

    function enhance(uint256 tokenId, uint256 burnTokenId) external;

    function enhanceFor(
        uint256 tokenId,
        uint256 burnTokenId,
        address user
    ) external;

    function revealFor(uint256[] calldata tokenIds, address user) external;
}

File 22 of 30 : Stats.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

library Stats {
    struct HeroStats {
        uint8 dmgMultiplier;
        uint8 partySize;
        uint8 enhancement;
    }

    struct FighterStats {
        uint32 dmg;
        uint8 enhancement;
    }

    struct EquipmentStats {
        uint32 dmg;
        uint8 dmgMultiplier;
        uint8 slot;
    }
}

File 23 of 30 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);

    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

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

    /**
     * @dev Moves `amount` tokens from the caller's account to `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `from` to `to` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address from,
        address to,
        uint256 amount
    ) external returns (bool);
}

File 24 of 30 : IAccessControlUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)

pragma solidity ^0.8.0;

/**
 * @dev External interface of AccessControl declared to support ERC165 detection.
 */
interface IAccessControlUpgradeable {
    /**
     * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
     *
     * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
     * {RoleAdminChanged} not being emitted signaling this.
     *
     * _Available since v3.1._
     */
    event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);

    /**
     * @dev Emitted when `account` is granted `role`.
     *
     * `sender` is the account that originated the contract call, an admin role
     * bearer except when using {AccessControl-_setupRole}.
     */
    event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Emitted when `account` is revoked `role`.
     *
     * `sender` is the account that originated the contract call:
     *   - if using `revokeRole`, it is the admin role bearer
     *   - if using `renounceRole`, it is the role bearer (i.e. `account`)
     */
    event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) external view returns (bool);

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {AccessControl-_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) external view returns (bytes32);

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function grantRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function revokeRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been granted `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     */
    function renounceRole(bytes32 role, address account) external;
}

File 25 of 30 : 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 {
    }

    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;
    }

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[50] private __gap;
}

File 26 of 30 : 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 {
    }

    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;
    }

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[50] private __gap;
}

File 27 of 30 : Randomness.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

library Randomness {
    struct SeedData {
        uint256 batch;
        bytes32 randomnessId;
    }
}

File 28 of 30 : IERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (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`.
     *
     * 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;

    /**
     * @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 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 the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) external view returns (address operator);

    /**
     * @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);
}

File 29 of 30 : 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 30 of 30 : 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);
}

Settings
{
  "remappings": [
    "@chainlink/=lib/chainlink/",
    "@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
    "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
    "chainlink/=lib/chainlink/",
    "ds-test/=lib/ds-test/src/",
    "forge-std/=lib/forge-std/src/",
    "openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/",
    "openzeppelin-contracts/=lib/openzeppelin-contracts/",
    "script/=script/",
    "src/=src/",
    "test/=test/",
    "src/=src/",
    "test/=test/",
    "script/=script/"
  ],
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "metadata": {
    "bytecodeHash": "ipfs"
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "evmVersion": "london",
  "libraries": {
    "src/lib/Damage.sol": {
      "Damage": "0x1aa1bc989105048951a95baf1f5195af9b19bddb"
    }
  }
}

Contract Security Audit

Contract ABI

[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"timestamp","type":"uint256"},{"indexed":false,"internalType":"bool","name":"success","type":"bool"},{"indexed":false,"internalType":"bool","name":"degraded","type":"bool"}],"name":"EnhancementCompleted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"EnhancementRequested","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":true,"internalType":"address","name":"seeder","type":"address"}],"name":"SeederUpdated","type":"event"},{"inputs":[],"name":"CALL_FOR_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_DMG_MULTIPLIER","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_ENHANCEMENT","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_PARTY_SIZE","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MIN_DMG_MULTIPLIER","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MIN_DMG_MULTIPLIER_GENESIS","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MIN_ENHANCEMENT","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MIN_PARTY_SIZE","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"seeder","type":"address"},{"internalType":"address","name":"token","type":"address"}],"name":"__Enhanceable_init","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"burnTokenId","type":"uint256"}],"name":"enhance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"burnTokenId","type":"uint256"},{"internalType":"address","name":"user","type":"address"}],"name":"enhanceFor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"enhancementCost","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getEnhancementRequest","outputs":[{"components":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"address","name":"requester","type":"address"}],"internalType":"struct Enhanceable.EnhancementRequest","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getGuild","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getRoleMember","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleMemberCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getSeeder","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getStats","outputs":[{"components":[{"internalType":"uint8","name":"dmgMultiplier","type":"uint8"},{"internalType":"uint8","name":"partySize","type":"uint8"},{"internalType":"uint8","name":"enhancement","type":"uint8"}],"internalType":"struct Stats.HeroStats","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"admin","type":"address"},{"internalType":"address","name":"seeder","type":"address"},{"internalType":"address","name":"hero","type":"address"},{"internalType":"address","name":"confetti","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"isGenesis","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","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":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"reveal","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"internalType":"address","name":"user","type":"address"}],"name":"revealFor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IGuildURIHandler","name":"guild","type":"address"}],"name":"setGuild","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"seeder","type":"address"}],"name":"setSeeder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"}]

608060405234801561001057600080fd5b506130a3806100206000396000f3fe608060405234801561001057600080fd5b50600436106102115760003560e01c80638456cb5911610125578063ca15c873116100ad578063dfca4f791161007c578063dfca4f7914610537578063e5f6397514610548578063eb48fada1461055b578063f1e25ea814610563578063f8c8765e1461057957600080fd5b8063ca15c873146104f6578063cd9fddf414610509578063d50b31eb14610511578063d547741f1461052457600080fd5b8063a217fddf116100f4578063a217fddf14610496578063b8202b951461049e578063b836ae6f146104b0578063b93f208a146104c3578063c87b56dd146104d657600080fd5b80638456cb59146104485780639010d07c1461045057806391d148541461047b5780639fd5f53b1461048e57600080fd5b80632f2ff15d116101a85780635c7e7732116101775780635c7e77321461039f57806371621db2146103b2578063764e6236146103ba57806378a8a238146103e15780637b3039651461040957600080fd5b80632f2ff15d1461036957806336568abe1461037c5780633f4ba83a1461038f5780635043a62b1461039757600080fd5b806316559f97116101e457806316559f97146102a45780631974e3f91461031d57806322e720d814610325578063248a9ca31461033857600080fd5b806301ffc9a7146102165780630c7429661461023e578063150b7a0214610253578063150ffae81461028a575b600080fd5b610229610224366004612809565b61058c565b60405190151581526020015b60405180910390f35b61025161024c36600461283b565b6105b7565b005b61027161026136600461289f565b630a85bd0160e11b949350505050565b6040516001600160e01b03199091168152602001610235565b610292600d81565b60405160ff9091168152602001610235565b6102f96102b2366004612963565b604080518082019091526000808252602082015250600090815260016020818152604092839020835180850190945280548452909101546001600160a01b03169082015290565b60408051825181526020928301516001600160a01b03169281019290925201610235565b610292600481565b61025161033336600461297c565b6105e6565b61035b610346366004612963565b60009081526069602052604090206001015490565b604051908152602001610235565b6102516103773660046129b5565b610655565b61025161038a3660046129b5565b61067f565b6102516106fd565b610292601181565b6102516103ad3660046129e5565b610719565b610292600081565b61035b7f41207b22b88d3748f04a6d2ace753afb54baeac67bf1270fb2caeb206211499481565b6103f46103ef366004612963565b61074f565b60408051928352901515602083015201610235565b61041c610417366004612963565b61078d565b60408051825160ff90811682526020808501518216908301529282015190921690820152606001610235565b61025161099b565b61046361045e3660046129e5565b6109bd565b6040516001600160a01b039091168152602001610235565b6102296104893660046129b5565b6109dc565b610292600681565b61035b600081565b610102546001600160a01b0316610463565b6102516104be366004612a53565b610a07565b6102516104d1366004612a9f565b610a67565b6104e96104e4366004612963565b610a9d565b6040516102359190612b0d565b61035b610504366004612963565b610ad7565b610292600c81565b61025161051f36600461283b565b610aee565b6102516105323660046129b5565b610b02565b6003546001600160a01b0316610463565b610251610556366004612b40565b610b27565b610292600e81565b610229610571366004612963565b610457101590565b610251610587366004612b6e565b610bca565b60006001600160e01b03198216635a05180f60e01b14806105b157506105b182610c99565b92915050565b60006105c281610cce565b5061010280546001600160a01b0319166001600160a01b0392909216919091179055565b61010154600160a01b900460ff161561061a5760405162461bcd60e51b815260040161061190612bca565b60405180910390fd5b7f41207b22b88d3748f04a6d2ace753afb54baeac67bf1270fb2caeb206211499461064481610cce565b61064f848484610cdb565b50505050565b60008281526069602052604090206001015461067081610cce565b61067a83836111da565b505050565b6001600160a01b03811633146106ef5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610611565b6106f982826111fc565b5050565b600061070881610cce565b50610101805460ff60a01b19169055565b61010154600160a01b900460ff16156107445760405162461bcd60e51b815260040161061190612bca565b6106f9828233610cdb565b600081815260ff60208190526040822054829161076c911661121e565b600093845260ff602081905260409094205490946003919094161192915050565b604080516060810182526000808252602082018190529181019190915260035460048054604051600162a4080760e01b031981526001600160a01b039182169281019290925260248201859052600092169063ff5bf7f990604401602060405180830381865afa158015610805573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108299190612c0c565b600084815260ff60208190526040822054929350919091169061084b8261137e565b905061045785116108ce576000610864600d6011612c3b565b61086f906001612c5e565b905060405180606001604052808260ff168661088b9190612c99565b610897600d6001612c5e565b6108a19190612c5e565b60ff1681526020016108b4846006612c5e565b60ff1681526020018460ff16815250945050505050919050565b60006108dc600c6011612c3b565b6108e7906001612c5e565b905060006108f760046006612c3b565b610902906001612c5e565b905060405180606001604052808360ff168761091e9190612c99565b61092990600c612c5e565b60ff1681526020018260ff168760405160200161094891815260200190565b6040516020818303038152906040528051906020012060001c61096b9190612c99565b610976866004612c5e565b6109809190612c5e565b60ff1681526020018560ff1681525095505050505050919050565b60006109a681610cce565b50610101805460ff60a01b1916600160a01b179055565b6000828152609b602052604081206109d59083611396565b9392505050565b60009182526069602090815260408084206001600160a01b0393909316845291905290205460ff1690565b61010154600160a01b900460ff1615610a325760405162461bcd60e51b815260040161061190612bca565b7f41207b22b88d3748f04a6d2ace753afb54baeac67bf1270fb2caeb2062114994610a5c81610cce565b61064f8484846113a2565b61010154600160a01b900460ff1615610a925760405162461bcd60e51b815260040161061190612bca565b6106f98282336113a2565b6060610aa761191b565b610ab08361193b565b604051602001610ac1929190612cad565b6040516020818303038152906040529050919050565b6000818152609b602052604081206105b190611a44565b6000610af981610cce565b6106f982611a4e565b600082815260696020526040902060010154610b1d81610cce565b61067a83836111fc565b6000610b336001611a9a565b90508015610b4b576000805461ff0019166101001790555b600380546001600160a01b038086166001600160a01b03199283161790925560048054928516929091169190911790556001600255801561067a576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a1505050565b6000610bd66001611a9a565b90508015610bee576000805461ff0019166101001790555b610bf6611b22565b610c01600086611b8f565b610c0b8484610b27565b61010080546001600160a01b038085166001600160a01b03199092169190911790915561010180546001600160a81b03191691871691909117600160a01b1790558015610c92576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050505050565b60006001600160e01b03198216637965db0b60e01b14806105b157506301ffc9a760e01b6001600160e01b03198316146105b1565b610cd88133611b99565b50565b818303610d505760405162461bcd60e51b815260206004820152603d60248201527f4865726f55524948616e646c65723a3a656e68616e63653a207461726765742060448201527f746f6b656e2063616e6e6f7420657175616c206275726e20746f6b656e0000006064820152608401610611565b600480546040516331a9108f60e11b81529182018590526001600160a01b031690636352211e90602401602060405180830381865afa158015610d97573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dbb9190612cdc565b6001600160a01b0316336001600160a01b031614610e395760405162461bcd60e51b815260206004820152603560248201527f4865726f55524948616e646c65723a3a656e68616e63653a20656e68616e6365604482015274391036bab9ba103132903a37b5b2b71037bbb732b960591b6064820152608401610611565b600083815260ff602081905260409091205416600e8110610eb55760405162461bcd60e51b815260206004820152603060248201527f4865726f55524948616e646c65723a3a656e68616e63653a206d617820656e6860448201526f185b98d95b595b9d081c995858da195960821b6064820152608401610611565b6000610ec38260ff1661121e565b6101025460405163037b9b2d60e41b81526001600160a01b038681166004830152929350600092909116906337b9b2d090602401602060405180830381865afa158015610f14573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f389190612c0c565b90508015610fdb57610102546040516352f7c55360e11b815260c8916001600160a01b03169063a5ef8aa690610f75908590600090600401612cf9565b602060405180830381865afa158015610f92573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fb69190612d3d565b610fc49061ffff1684612d58565b610fce9190612d77565b610fd89083612d8b565b91505b60006064610fea84600f612d58565b610ff49190612d77565b61010054610101546040516323b872dd60e01b81523360048201526001600160a01b0391821660248201526044810184905292935016906323b872dd906064016020604051808303816000875af1158015611053573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110779190612da2565b50610100546001600160a01b03166379cc6790336110958487612d8b565b6040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820152604401600060405180830381600087803b1580156110db57600080fd5b505af11580156110ef573d6000803e3d6000fd5b5050505060038460ff1611156111c75760048054604051632142170760e11b81523392810192909252306024830152604482018890526001600160a01b0316906342842e0e90606401600060405180830381600087803b15801561115257600080fd5b505af1158015611166573d6000803e3d6000fd5b505060048054604051630852cd8d60e31b81529182018a90526001600160a01b031692506342966c689150602401600060405180830381600087803b1580156111ae57600080fd5b505af11580156111c2573d6000803e3d6000fd5b505050505b6111d18787611bfd565b50505050505050565b6111e48282611d5b565b6000828152609b6020526040902061067a9082611de1565b6112068282611df6565b6000828152609b6020526040902061067a9082611e5d565b6000816000036112385750680d8d726b7177a80000919050565b816001036112505750681b1ae4d6e2ef500000919050565b8160020361126857506828a857425466f80000919050565b816003036112805750683635c9adc5dea00000919050565b8160040361129857506843c33c193756480000919050565b816005036112b05750685150ae84a8cdf00000919050565b816006036112c85750685ede20f01a45980000919050565b816007036112e05750686c6b935b8bbd400000919050565b816008036112f857506879f905c6fd34e80000919050565b81600903611310575068878678326eac900000919050565b81600a03611328575068878678326eac900000919050565b81600b03611340575068878678326eac900000919050565b81600c03611358575068878678326eac900000919050565b81600d03611370575068878678326eac900000919050565b50600019919050565b919050565b600060058260ff1610611379576105b1600483612c3b565b60006109d58383611e72565b6101025460405163037b9b2d60e41b81526001600160a01b03838116600483015260009216906337b9b2d090602401602060405180830381865afa1580156113ee573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114129190612c0c565b90506000808083156114d35761010254604051631c68c4b160e01b8152600481018690526000916001600160a01b031690631c68c4b19060240160e060405180830381865afa158015611469573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061148d9190612dc4565b9050806060015161ffff166005146114a95780606001516114ac565b600a5b60640261ffff169350806080015160640261ffff1692508060a0015160640261ffff169150505b60008667ffffffffffffffff8111156114ee576114ee612858565b604051908082528060200260200182016040528015611517578160200160208202803683370190505b50905060005b8781101561185f5760045433906001600160a01b0316636352211e8b8b8581811061154a5761154a612e76565b905060200201356040518263ffffffff1660e01b815260040161156f91815260200190565b602060405180830381865afa15801561158c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115b09190612cdc565b6001600160a01b0316146116195760405162461bcd60e51b815260206004820152602a60248201527f4865726f55524948616e646c65723a3a72657665616c3a2072657665616c6572604482015269103737ba1037bbb732b960b11b6064820152608401610611565b60ff60008a8a8481811061162f5761162f612e76565b90506020020135815260200190815260200160002060009054906101000a900460ff1682828151811061166457611664612e76565b602002602001019060ff16908160ff1681525050600061169f83838151811061168f5761168f612e76565b602002602001015160ff16611e9c565b90506116af612710858301611f40565b905060006116d88484815181106116c8576116c8612e76565b602002602001015160ff16611f56565b905080861015806117095750600060ff168484815181106116fb576116fb612e76565b602002602001015160ff1611155b61171557858103611718565b60005b90506000806117496117418e8e8881811061173557611735612e76565b90506020020135611ff9565b85858c61207f565b9150915081156117a057600160ff60008f8f8981811061176b5761176b612e76565b60209081029290920135835250810191909152604001600020805460ff19811660ff91821693909301169190911790556117ef565b80156117ef57600160ff60008f8f898181106117be576117be612e76565b60209081029290920135835250810191909152604001600020805460ff19811660ff91821693909303169190911790555b428d8d8781811061180257611802612e76565b905060200201357f17a374fef4d399cb50b569659b5757fe6f6c1a236acc0149fe42f796e98ee260848460405161184792919091151582521515602082015260400190565b60405180910390a350506001909201915061151d9050565b5061186a8888612149565b6118a88888808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152508592506121a1915050565b6119115760405162461bcd60e51b815260206004820152603460248201527f456e68616e636561626c653a3a72657665616c3a2072657665616c20666f72206044820152731d5b9cdd5c1c1bdc9d19590818dbdb9d1c9858dd60621b6064820152608401610611565b5050505050505050565b606060405180606001604052806025815260200161304960259139905090565b6060816000036119625750506040805180820190915260018152600360fc1b602082015290565b8160005b811561198c578061197681612e8c565b91506119859050600a83612d77565b9150611966565b60008167ffffffffffffffff8111156119a7576119a7612858565b6040519080825280601f01601f1916602001820160405280156119d1576020820181803683370190505b5090505b8415611a3c576119e6600183612d8b565b91506119f3600a86612c99565b6119fe906030612ea5565b60f81b818381518110611a1357611a13612e76565b60200101906001600160f81b031916908160001a905350611a35600a86612d77565b94506119d5565b949350505050565b60006105b1825490565b600380546001600160a01b0319166001600160a01b03831690811790915560405133907fe6a0768bc7cc02a7502c4e06cdb639aca06180fd05c4e57dddea1b2d1b0e8c0b90600090a350565b60008054610100900460ff1615611ae1578160ff166001148015611abd5750303b155b611ad95760405162461bcd60e51b815260040161061190612ebd565b506000919050565b60005460ff808416911610611b085760405162461bcd60e51b815260040161061190612ebd565b506000805460ff191660ff92909216919091179055600190565b600054610100900460ff16611b8d5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608401610611565b565b6106f982826111da565b611ba382826109dc565b6106f957611bbb816001600160a01b031660146124f8565b611bc68360206124f8565b604051602001611bd7929190612f0b565b60408051601f198184030181529082905262461bcd60e51b825261061191600401612b0d565b600082815260016020819052604090912001546001600160a01b031615611c835760405162461bcd60e51b815260206004820152603460248201527f456e68616e636561626c653a3a656e68616e63653a20746f6b656e20626f756e60448201527319081d1bc81c195b991a5b99c81c995c5d595cdd60621b6064820152608401610611565b6040805180820182526002805482523360208084019182526000878152600191829052859020935184559051920180546001600160a01b0319166001600160a01b03938416179055600354905492516354efc28d60e11b81526004810193909352169063a9df851a90602401600060405180830381600087803b158015611d0957600080fd5b505af1158015611d1d573d6000803e3d6000fd5b50506002805460010190555050604051429083907f9decd01177e5628464489f01eefedd43d7ef0fd8cc63d054f8a0dea6eea94eec90600090a35050565b611d6582826109dc565b6106f95760008281526069602090815260408083206001600160a01b03851684529091529020805460ff19166001179055611d9d3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60006109d5836001600160a01b038416612694565b611e0082826109dc565b156106f95760008281526069602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60006109d5836001600160a01b0384166126e3565b6000826000018281548110611e8957611e89612e76565b9060005260206000200154905092915050565b600081600003611eaf5750612328919050565b81600103611ec05750612134919050565b81600203611ed15750611f40919050565b81600303611ee25750611d4c919050565b81600403611ef35750611b58919050565b81600503611f045750611964919050565b81600603611f155750611770919050565b81600703611f26575061157c919050565b81600803611f375750611388919050565b506109c4919050565b6000818310611f4f57816109d5565b5090919050565b600081600003611f6857506000919050565b81600103611f7957506101f4919050565b81600203611f8a57506103e8919050565b81600303611f9b57506105dc919050565b81600403611fac57506107d0919050565b81600503611fbd57506109c4919050565b81600603611fce5750610bb8919050565b81600703611fdf5750610dac919050565b81600803611ff05750610fa0919050565b50611388919050565b600354600082815260016020526040808220549051600162a4080760e01b03198152306004820152602481019190915290916001600160a01b03169063ff5bf7f990604401602060405180830381865afa15801561205b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105b19190612c0c565b6000806000806127108710158061209b575061209b88886127d6565b156120a9576001915061213c565b60408051602081018a9052016040516020818303038152906040528051906020012060001c97506000851180156120e557506120e588866127d6565b156120f3576001915061213c565b60008611801561213357506121338860405160200161211491815260200190565b6040516020818303038152906040528051906020012060001c876127d6565b1561213c575060015b9097909650945050505050565b60005b8181101561067a576001600084848481811061216a5761216a612e76565b602090810292909201358352508101919091526040016000908120908155600190810180546001600160a01b03191690550161214c565b600081518351146122065760405162461bcd60e51b815260206004820152602960248201527f456e68616e636561626c653a20757064617465206172726179206c656e677468604482015268040dad2e6dac2e8c6d60bb1b6064820152608401610611565b60045483516000916001600160a01b031690636352211e908690849061222e5761222e612e76565b60200260200101516040518263ffffffff1660e01b815260040161225491815260200190565b602060405180830381865afa158015612271573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122959190612cdc565b905060005b84518110156123b15760045485516001600160a01b03808516921690636352211e908890859081106122ce576122ce612e76565b60200260200101516040518263ffffffff1660e01b81526004016122f491815260200190565b602060405180830381865afa158015612311573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123359190612cdc565b6001600160a01b03161461239f5760405162461bcd60e51b815260206004820152602b60248201527f456e68616e636561626c653a20746f6b656e73206e6f74206f776e656420627960448201526a1039b0b6b29037bbb732b960a91b6064820152608401610611565b806123a981612e8c565b91505061229a565b506001600160a01b0381163b156124ee57604051632833859760e11b81526001600160a01b038216906350670b2e906123f09087908790600401612f80565b6020604051808303816000875af192505050801561242b575060408051601f3d908101601f1916820190925261242891810190612ffe565b60015b6124d2573d808015612459576040519150601f19603f3d011682016040523d82523d6000602084013e61245e565b606091505b5080516000036124ca5760405162461bcd60e51b815260206004820152603160248201527f456e68616e636561626c653a207472616e7366657220746f206e6f6e20456e6860448201527030b731b2b91034b6b83632b6b2b73a32b960791b6064820152608401610611565b805181602001fd5b6001600160e01b031916632833859760e11b1491506105b19050565b60019150506105b1565b60606000612507836002612d58565b612512906002612ea5565b67ffffffffffffffff81111561252a5761252a612858565b6040519080825280601f01601f191660200182016040528015612554576020820181803683370190505b509050600360fc1b8160008151811061256f5761256f612e76565b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061259e5761259e612e76565b60200101906001600160f81b031916908160001a90535060006125c2846002612d58565b6125cd906001612ea5565b90505b6001811115612645576f181899199a1a9b1b9c1cb0b131b232b360811b85600f166010811061260157612601612e76565b1a60f81b82828151811061261757612617612e76565b60200101906001600160f81b031916908160001a90535060049490941c9361263e8161301b565b90506125d0565b5083156109d55760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610611565b60008181526001830160205260408120546126db575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556105b1565b5060006105b1565b600081815260018301602052604081205480156127cc576000612707600183612d8b565b855490915060009061271b90600190612d8b565b905081811461278057600086600001828154811061273b5761273b612e76565b906000526020600020015490508087600001848154811061275e5761275e612e76565b6000918252602080832090910192909255918252600188019052604090208390555b855486908061279157612791613032565b6001900381819060005260206000200160009055905585600101600086815260200190815260200160002060009055600193505050506105b1565b60009150506105b1565b6000816127e561271085612c99565b10156126db575060016105b1565b6001600160e01b031981168114610cd857600080fd5b60006020828403121561281b57600080fd5b81356109d5816127f3565b6001600160a01b0381168114610cd857600080fd5b60006020828403121561284d57600080fd5b81356109d581612826565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff8111828210171561289757612897612858565b604052919050565b600080600080608085870312156128b557600080fd5b84356128c081612826565b93506020858101356128d181612826565b935060408601359250606086013567ffffffffffffffff808211156128f557600080fd5b818801915088601f83011261290957600080fd5b81358181111561291b5761291b612858565b61292d601f8201601f1916850161286e565b9150808252898482850101111561294357600080fd5b808484018584013760008482840101525080935050505092959194509250565b60006020828403121561297557600080fd5b5035919050565b60008060006060848603121561299157600080fd5b833592506020840135915060408401356129aa81612826565b809150509250925092565b600080604083850312156129c857600080fd5b8235915060208301356129da81612826565b809150509250929050565b600080604083850312156129f857600080fd5b50508035926020909101359150565b60008083601f840112612a1957600080fd5b50813567ffffffffffffffff811115612a3157600080fd5b6020830191508360208260051b8501011115612a4c57600080fd5b9250929050565b600080600060408486031215612a6857600080fd5b833567ffffffffffffffff811115612a7f57600080fd5b612a8b86828701612a07565b90945092505060208401356129aa81612826565b60008060208385031215612ab257600080fd5b823567ffffffffffffffff811115612ac957600080fd5b612ad585828601612a07565b90969095509350505050565b60005b83811015612afc578181015183820152602001612ae4565b8381111561064f5750506000910152565b6020815260008251806020840152612b2c816040850160208701612ae1565b601f01601f19169190910160400192915050565b60008060408385031215612b5357600080fd5b8235612b5e81612826565b915060208301356129da81612826565b60008060008060808587031215612b8457600080fd5b8435612b8f81612826565b93506020850135612b9f81612826565b92506040850135612baf81612826565b91506060850135612bbf81612826565b939692955090935050565b60208082526022908201527f4669676874657255524948616e646c65723a20636f6e74726163742070617573604082015261195960f21b606082015260800190565b600060208284031215612c1e57600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b600060ff821660ff841680821015612c5557612c55612c25565b90039392505050565b600060ff821660ff84168060ff03821115612c7b57612c7b612c25565b019392505050565b634e487b7160e01b600052601260045260246000fd5b600082612ca857612ca8612c83565b500690565b60008351612cbf818460208801612ae1565b835190830190612cd3818360208801612ae1565b01949350505050565b600060208284031215612cee57600080fd5b81516109d581612826565b8281526040810160068310612d1e57634e487b7160e01b600052602160045260246000fd5b8260208301529392505050565b805161ffff8116811461137957600080fd5b600060208284031215612d4f57600080fd5b6109d582612d2b565b6000816000190483118215151615612d7257612d72612c25565b500290565b600082612d8657612d86612c83565b500490565b600082821015612d9d57612d9d612c25565b500390565b600060208284031215612db457600080fd5b815180151581146109d557600080fd5b600060e08284031215612dd657600080fd5b60405160e0810181811067ffffffffffffffff82111715612df957612df9612858565b604052612e0583612d2b565b8152612e1360208401612d2b565b6020820152612e2460408401612d2b565b6040820152612e3560608401612d2b565b6060820152612e4660808401612d2b565b6080820152612e5760a08401612d2b565b60a082015260c0830151612e6a81612826565b60c08201529392505050565b634e487b7160e01b600052603260045260246000fd5b600060018201612e9e57612e9e612c25565b5060010190565b60008219821115612eb857612eb8612c25565b500190565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351612f43816017850160208801612ae1565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351612f74816028840160208801612ae1565b01602801949350505050565b604080825283519082018190526000906020906060840190828701845b82811015612fb957815184529284019290840190600101612f9d565b5050508381038285015284518082528583019183019060005b81811015612ff157835160ff1683529284019291840191600101612fd2565b5090979650505050505050565b60006020828403121561301057600080fd5b81516109d5816127f3565b60008161302a5761302a612c25565b506000190190565b634e487b7160e01b600052603160045260246000fdfe68747470733a2f2f6170692e726169642e70617274792f6d657461646174612f6865726f2fa26469706673582212203b7d8554337582499f31055624304c2f6991ba9baf7c514b03d700977fb54ef864736f6c634300080d0033

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106102115760003560e01c80638456cb5911610125578063ca15c873116100ad578063dfca4f791161007c578063dfca4f7914610537578063e5f6397514610548578063eb48fada1461055b578063f1e25ea814610563578063f8c8765e1461057957600080fd5b8063ca15c873146104f6578063cd9fddf414610509578063d50b31eb14610511578063d547741f1461052457600080fd5b8063a217fddf116100f4578063a217fddf14610496578063b8202b951461049e578063b836ae6f146104b0578063b93f208a146104c3578063c87b56dd146104d657600080fd5b80638456cb59146104485780639010d07c1461045057806391d148541461047b5780639fd5f53b1461048e57600080fd5b80632f2ff15d116101a85780635c7e7732116101775780635c7e77321461039f57806371621db2146103b2578063764e6236146103ba57806378a8a238146103e15780637b3039651461040957600080fd5b80632f2ff15d1461036957806336568abe1461037c5780633f4ba83a1461038f5780635043a62b1461039757600080fd5b806316559f97116101e457806316559f97146102a45780631974e3f91461031d57806322e720d814610325578063248a9ca31461033857600080fd5b806301ffc9a7146102165780630c7429661461023e578063150b7a0214610253578063150ffae81461028a575b600080fd5b610229610224366004612809565b61058c565b60405190151581526020015b60405180910390f35b61025161024c36600461283b565b6105b7565b005b61027161026136600461289f565b630a85bd0160e11b949350505050565b6040516001600160e01b03199091168152602001610235565b610292600d81565b60405160ff9091168152602001610235565b6102f96102b2366004612963565b604080518082019091526000808252602082015250600090815260016020818152604092839020835180850190945280548452909101546001600160a01b03169082015290565b60408051825181526020928301516001600160a01b03169281019290925201610235565b610292600481565b61025161033336600461297c565b6105e6565b61035b610346366004612963565b60009081526069602052604090206001015490565b604051908152602001610235565b6102516103773660046129b5565b610655565b61025161038a3660046129b5565b61067f565b6102516106fd565b610292601181565b6102516103ad3660046129e5565b610719565b610292600081565b61035b7f41207b22b88d3748f04a6d2ace753afb54baeac67bf1270fb2caeb206211499481565b6103f46103ef366004612963565b61074f565b60408051928352901515602083015201610235565b61041c610417366004612963565b61078d565b60408051825160ff90811682526020808501518216908301529282015190921690820152606001610235565b61025161099b565b61046361045e3660046129e5565b6109bd565b6040516001600160a01b039091168152602001610235565b6102296104893660046129b5565b6109dc565b610292600681565b61035b600081565b610102546001600160a01b0316610463565b6102516104be366004612a53565b610a07565b6102516104d1366004612a9f565b610a67565b6104e96104e4366004612963565b610a9d565b6040516102359190612b0d565b61035b610504366004612963565b610ad7565b610292600c81565b61025161051f36600461283b565b610aee565b6102516105323660046129b5565b610b02565b6003546001600160a01b0316610463565b610251610556366004612b40565b610b27565b610292600e81565b610229610571366004612963565b610457101590565b610251610587366004612b6e565b610bca565b60006001600160e01b03198216635a05180f60e01b14806105b157506105b182610c99565b92915050565b60006105c281610cce565b5061010280546001600160a01b0319166001600160a01b0392909216919091179055565b61010154600160a01b900460ff161561061a5760405162461bcd60e51b815260040161061190612bca565b60405180910390fd5b7f41207b22b88d3748f04a6d2ace753afb54baeac67bf1270fb2caeb206211499461064481610cce565b61064f848484610cdb565b50505050565b60008281526069602052604090206001015461067081610cce565b61067a83836111da565b505050565b6001600160a01b03811633146106ef5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610611565b6106f982826111fc565b5050565b600061070881610cce565b50610101805460ff60a01b19169055565b61010154600160a01b900460ff16156107445760405162461bcd60e51b815260040161061190612bca565b6106f9828233610cdb565b600081815260ff60208190526040822054829161076c911661121e565b600093845260ff602081905260409094205490946003919094161192915050565b604080516060810182526000808252602082018190529181019190915260035460048054604051600162a4080760e01b031981526001600160a01b039182169281019290925260248201859052600092169063ff5bf7f990604401602060405180830381865afa158015610805573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108299190612c0c565b600084815260ff60208190526040822054929350919091169061084b8261137e565b905061045785116108ce576000610864600d6011612c3b565b61086f906001612c5e565b905060405180606001604052808260ff168661088b9190612c99565b610897600d6001612c5e565b6108a19190612c5e565b60ff1681526020016108b4846006612c5e565b60ff1681526020018460ff16815250945050505050919050565b60006108dc600c6011612c3b565b6108e7906001612c5e565b905060006108f760046006612c3b565b610902906001612c5e565b905060405180606001604052808360ff168761091e9190612c99565b61092990600c612c5e565b60ff1681526020018260ff168760405160200161094891815260200190565b6040516020818303038152906040528051906020012060001c61096b9190612c99565b610976866004612c5e565b6109809190612c5e565b60ff1681526020018560ff1681525095505050505050919050565b60006109a681610cce565b50610101805460ff60a01b1916600160a01b179055565b6000828152609b602052604081206109d59083611396565b9392505050565b60009182526069602090815260408084206001600160a01b0393909316845291905290205460ff1690565b61010154600160a01b900460ff1615610a325760405162461bcd60e51b815260040161061190612bca565b7f41207b22b88d3748f04a6d2ace753afb54baeac67bf1270fb2caeb2062114994610a5c81610cce565b61064f8484846113a2565b61010154600160a01b900460ff1615610a925760405162461bcd60e51b815260040161061190612bca565b6106f98282336113a2565b6060610aa761191b565b610ab08361193b565b604051602001610ac1929190612cad565b6040516020818303038152906040529050919050565b6000818152609b602052604081206105b190611a44565b6000610af981610cce565b6106f982611a4e565b600082815260696020526040902060010154610b1d81610cce565b61067a83836111fc565b6000610b336001611a9a565b90508015610b4b576000805461ff0019166101001790555b600380546001600160a01b038086166001600160a01b03199283161790925560048054928516929091169190911790556001600255801561067a576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a1505050565b6000610bd66001611a9a565b90508015610bee576000805461ff0019166101001790555b610bf6611b22565b610c01600086611b8f565b610c0b8484610b27565b61010080546001600160a01b038085166001600160a01b03199092169190911790915561010180546001600160a81b03191691871691909117600160a01b1790558015610c92576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050505050565b60006001600160e01b03198216637965db0b60e01b14806105b157506301ffc9a760e01b6001600160e01b03198316146105b1565b610cd88133611b99565b50565b818303610d505760405162461bcd60e51b815260206004820152603d60248201527f4865726f55524948616e646c65723a3a656e68616e63653a207461726765742060448201527f746f6b656e2063616e6e6f7420657175616c206275726e20746f6b656e0000006064820152608401610611565b600480546040516331a9108f60e11b81529182018590526001600160a01b031690636352211e90602401602060405180830381865afa158015610d97573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dbb9190612cdc565b6001600160a01b0316336001600160a01b031614610e395760405162461bcd60e51b815260206004820152603560248201527f4865726f55524948616e646c65723a3a656e68616e63653a20656e68616e6365604482015274391036bab9ba103132903a37b5b2b71037bbb732b960591b6064820152608401610611565b600083815260ff602081905260409091205416600e8110610eb55760405162461bcd60e51b815260206004820152603060248201527f4865726f55524948616e646c65723a3a656e68616e63653a206d617820656e6860448201526f185b98d95b595b9d081c995858da195960821b6064820152608401610611565b6000610ec38260ff1661121e565b6101025460405163037b9b2d60e41b81526001600160a01b038681166004830152929350600092909116906337b9b2d090602401602060405180830381865afa158015610f14573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f389190612c0c565b90508015610fdb57610102546040516352f7c55360e11b815260c8916001600160a01b03169063a5ef8aa690610f75908590600090600401612cf9565b602060405180830381865afa158015610f92573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fb69190612d3d565b610fc49061ffff1684612d58565b610fce9190612d77565b610fd89083612d8b565b91505b60006064610fea84600f612d58565b610ff49190612d77565b61010054610101546040516323b872dd60e01b81523360048201526001600160a01b0391821660248201526044810184905292935016906323b872dd906064016020604051808303816000875af1158015611053573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110779190612da2565b50610100546001600160a01b03166379cc6790336110958487612d8b565b6040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820152604401600060405180830381600087803b1580156110db57600080fd5b505af11580156110ef573d6000803e3d6000fd5b5050505060038460ff1611156111c75760048054604051632142170760e11b81523392810192909252306024830152604482018890526001600160a01b0316906342842e0e90606401600060405180830381600087803b15801561115257600080fd5b505af1158015611166573d6000803e3d6000fd5b505060048054604051630852cd8d60e31b81529182018a90526001600160a01b031692506342966c689150602401600060405180830381600087803b1580156111ae57600080fd5b505af11580156111c2573d6000803e3d6000fd5b505050505b6111d18787611bfd565b50505050505050565b6111e48282611d5b565b6000828152609b6020526040902061067a9082611de1565b6112068282611df6565b6000828152609b6020526040902061067a9082611e5d565b6000816000036112385750680d8d726b7177a80000919050565b816001036112505750681b1ae4d6e2ef500000919050565b8160020361126857506828a857425466f80000919050565b816003036112805750683635c9adc5dea00000919050565b8160040361129857506843c33c193756480000919050565b816005036112b05750685150ae84a8cdf00000919050565b816006036112c85750685ede20f01a45980000919050565b816007036112e05750686c6b935b8bbd400000919050565b816008036112f857506879f905c6fd34e80000919050565b81600903611310575068878678326eac900000919050565b81600a03611328575068878678326eac900000919050565b81600b03611340575068878678326eac900000919050565b81600c03611358575068878678326eac900000919050565b81600d03611370575068878678326eac900000919050565b50600019919050565b919050565b600060058260ff1610611379576105b1600483612c3b565b60006109d58383611e72565b6101025460405163037b9b2d60e41b81526001600160a01b03838116600483015260009216906337b9b2d090602401602060405180830381865afa1580156113ee573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114129190612c0c565b90506000808083156114d35761010254604051631c68c4b160e01b8152600481018690526000916001600160a01b031690631c68c4b19060240160e060405180830381865afa158015611469573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061148d9190612dc4565b9050806060015161ffff166005146114a95780606001516114ac565b600a5b60640261ffff169350806080015160640261ffff1692508060a0015160640261ffff169150505b60008667ffffffffffffffff8111156114ee576114ee612858565b604051908082528060200260200182016040528015611517578160200160208202803683370190505b50905060005b8781101561185f5760045433906001600160a01b0316636352211e8b8b8581811061154a5761154a612e76565b905060200201356040518263ffffffff1660e01b815260040161156f91815260200190565b602060405180830381865afa15801561158c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115b09190612cdc565b6001600160a01b0316146116195760405162461bcd60e51b815260206004820152602a60248201527f4865726f55524948616e646c65723a3a72657665616c3a2072657665616c6572604482015269103737ba1037bbb732b960b11b6064820152608401610611565b60ff60008a8a8481811061162f5761162f612e76565b90506020020135815260200190815260200160002060009054906101000a900460ff1682828151811061166457611664612e76565b602002602001019060ff16908160ff1681525050600061169f83838151811061168f5761168f612e76565b602002602001015160ff16611e9c565b90506116af612710858301611f40565b905060006116d88484815181106116c8576116c8612e76565b602002602001015160ff16611f56565b905080861015806117095750600060ff168484815181106116fb576116fb612e76565b602002602001015160ff1611155b61171557858103611718565b60005b90506000806117496117418e8e8881811061173557611735612e76565b90506020020135611ff9565b85858c61207f565b9150915081156117a057600160ff60008f8f8981811061176b5761176b612e76565b60209081029290920135835250810191909152604001600020805460ff19811660ff91821693909301169190911790556117ef565b80156117ef57600160ff60008f8f898181106117be576117be612e76565b60209081029290920135835250810191909152604001600020805460ff19811660ff91821693909303169190911790555b428d8d8781811061180257611802612e76565b905060200201357f17a374fef4d399cb50b569659b5757fe6f6c1a236acc0149fe42f796e98ee260848460405161184792919091151582521515602082015260400190565b60405180910390a350506001909201915061151d9050565b5061186a8888612149565b6118a88888808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152508592506121a1915050565b6119115760405162461bcd60e51b815260206004820152603460248201527f456e68616e636561626c653a3a72657665616c3a2072657665616c20666f72206044820152731d5b9cdd5c1c1bdc9d19590818dbdb9d1c9858dd60621b6064820152608401610611565b5050505050505050565b606060405180606001604052806025815260200161304960259139905090565b6060816000036119625750506040805180820190915260018152600360fc1b602082015290565b8160005b811561198c578061197681612e8c565b91506119859050600a83612d77565b9150611966565b60008167ffffffffffffffff8111156119a7576119a7612858565b6040519080825280601f01601f1916602001820160405280156119d1576020820181803683370190505b5090505b8415611a3c576119e6600183612d8b565b91506119f3600a86612c99565b6119fe906030612ea5565b60f81b818381518110611a1357611a13612e76565b60200101906001600160f81b031916908160001a905350611a35600a86612d77565b94506119d5565b949350505050565b60006105b1825490565b600380546001600160a01b0319166001600160a01b03831690811790915560405133907fe6a0768bc7cc02a7502c4e06cdb639aca06180fd05c4e57dddea1b2d1b0e8c0b90600090a350565b60008054610100900460ff1615611ae1578160ff166001148015611abd5750303b155b611ad95760405162461bcd60e51b815260040161061190612ebd565b506000919050565b60005460ff808416911610611b085760405162461bcd60e51b815260040161061190612ebd565b506000805460ff191660ff92909216919091179055600190565b600054610100900460ff16611b8d5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608401610611565b565b6106f982826111da565b611ba382826109dc565b6106f957611bbb816001600160a01b031660146124f8565b611bc68360206124f8565b604051602001611bd7929190612f0b565b60408051601f198184030181529082905262461bcd60e51b825261061191600401612b0d565b600082815260016020819052604090912001546001600160a01b031615611c835760405162461bcd60e51b815260206004820152603460248201527f456e68616e636561626c653a3a656e68616e63653a20746f6b656e20626f756e60448201527319081d1bc81c195b991a5b99c81c995c5d595cdd60621b6064820152608401610611565b6040805180820182526002805482523360208084019182526000878152600191829052859020935184559051920180546001600160a01b0319166001600160a01b03938416179055600354905492516354efc28d60e11b81526004810193909352169063a9df851a90602401600060405180830381600087803b158015611d0957600080fd5b505af1158015611d1d573d6000803e3d6000fd5b50506002805460010190555050604051429083907f9decd01177e5628464489f01eefedd43d7ef0fd8cc63d054f8a0dea6eea94eec90600090a35050565b611d6582826109dc565b6106f95760008281526069602090815260408083206001600160a01b03851684529091529020805460ff19166001179055611d9d3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60006109d5836001600160a01b038416612694565b611e0082826109dc565b156106f95760008281526069602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60006109d5836001600160a01b0384166126e3565b6000826000018281548110611e8957611e89612e76565b9060005260206000200154905092915050565b600081600003611eaf5750612328919050565b81600103611ec05750612134919050565b81600203611ed15750611f40919050565b81600303611ee25750611d4c919050565b81600403611ef35750611b58919050565b81600503611f045750611964919050565b81600603611f155750611770919050565b81600703611f26575061157c919050565b81600803611f375750611388919050565b506109c4919050565b6000818310611f4f57816109d5565b5090919050565b600081600003611f6857506000919050565b81600103611f7957506101f4919050565b81600203611f8a57506103e8919050565b81600303611f9b57506105dc919050565b81600403611fac57506107d0919050565b81600503611fbd57506109c4919050565b81600603611fce5750610bb8919050565b81600703611fdf5750610dac919050565b81600803611ff05750610fa0919050565b50611388919050565b600354600082815260016020526040808220549051600162a4080760e01b03198152306004820152602481019190915290916001600160a01b03169063ff5bf7f990604401602060405180830381865afa15801561205b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105b19190612c0c565b6000806000806127108710158061209b575061209b88886127d6565b156120a9576001915061213c565b60408051602081018a9052016040516020818303038152906040528051906020012060001c97506000851180156120e557506120e588866127d6565b156120f3576001915061213c565b60008611801561213357506121338860405160200161211491815260200190565b6040516020818303038152906040528051906020012060001c876127d6565b1561213c575060015b9097909650945050505050565b60005b8181101561067a576001600084848481811061216a5761216a612e76565b602090810292909201358352508101919091526040016000908120908155600190810180546001600160a01b03191690550161214c565b600081518351146122065760405162461bcd60e51b815260206004820152602960248201527f456e68616e636561626c653a20757064617465206172726179206c656e677468604482015268040dad2e6dac2e8c6d60bb1b6064820152608401610611565b60045483516000916001600160a01b031690636352211e908690849061222e5761222e612e76565b60200260200101516040518263ffffffff1660e01b815260040161225491815260200190565b602060405180830381865afa158015612271573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122959190612cdc565b905060005b84518110156123b15760045485516001600160a01b03808516921690636352211e908890859081106122ce576122ce612e76565b60200260200101516040518263ffffffff1660e01b81526004016122f491815260200190565b602060405180830381865afa158015612311573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123359190612cdc565b6001600160a01b03161461239f5760405162461bcd60e51b815260206004820152602b60248201527f456e68616e636561626c653a20746f6b656e73206e6f74206f776e656420627960448201526a1039b0b6b29037bbb732b960a91b6064820152608401610611565b806123a981612e8c565b91505061229a565b506001600160a01b0381163b156124ee57604051632833859760e11b81526001600160a01b038216906350670b2e906123f09087908790600401612f80565b6020604051808303816000875af192505050801561242b575060408051601f3d908101601f1916820190925261242891810190612ffe565b60015b6124d2573d808015612459576040519150601f19603f3d011682016040523d82523d6000602084013e61245e565b606091505b5080516000036124ca5760405162461bcd60e51b815260206004820152603160248201527f456e68616e636561626c653a207472616e7366657220746f206e6f6e20456e6860448201527030b731b2b91034b6b83632b6b2b73a32b960791b6064820152608401610611565b805181602001fd5b6001600160e01b031916632833859760e11b1491506105b19050565b60019150506105b1565b60606000612507836002612d58565b612512906002612ea5565b67ffffffffffffffff81111561252a5761252a612858565b6040519080825280601f01601f191660200182016040528015612554576020820181803683370190505b509050600360fc1b8160008151811061256f5761256f612e76565b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061259e5761259e612e76565b60200101906001600160f81b031916908160001a90535060006125c2846002612d58565b6125cd906001612ea5565b90505b6001811115612645576f181899199a1a9b1b9c1cb0b131b232b360811b85600f166010811061260157612601612e76565b1a60f81b82828151811061261757612617612e76565b60200101906001600160f81b031916908160001a90535060049490941c9361263e8161301b565b90506125d0565b5083156109d55760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610611565b60008181526001830160205260408120546126db575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556105b1565b5060006105b1565b600081815260018301602052604081205480156127cc576000612707600183612d8b565b855490915060009061271b90600190612d8b565b905081811461278057600086600001828154811061273b5761273b612e76565b906000526020600020015490508087600001848154811061275e5761275e612e76565b6000918252602080832090910192909255918252600188019052604090208390555b855486908061279157612791613032565b6001900381819060005260206000200160009055905585600101600086815260200190815260200160002060009055600193505050506105b1565b60009150506105b1565b6000816127e561271085612c99565b10156126db575060016105b1565b6001600160e01b031981168114610cd857600080fd5b60006020828403121561281b57600080fd5b81356109d5816127f3565b6001600160a01b0381168114610cd857600080fd5b60006020828403121561284d57600080fd5b81356109d581612826565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff8111828210171561289757612897612858565b604052919050565b600080600080608085870312156128b557600080fd5b84356128c081612826565b93506020858101356128d181612826565b935060408601359250606086013567ffffffffffffffff808211156128f557600080fd5b818801915088601f83011261290957600080fd5b81358181111561291b5761291b612858565b61292d601f8201601f1916850161286e565b9150808252898482850101111561294357600080fd5b808484018584013760008482840101525080935050505092959194509250565b60006020828403121561297557600080fd5b5035919050565b60008060006060848603121561299157600080fd5b833592506020840135915060408401356129aa81612826565b809150509250925092565b600080604083850312156129c857600080fd5b8235915060208301356129da81612826565b809150509250929050565b600080604083850312156129f857600080fd5b50508035926020909101359150565b60008083601f840112612a1957600080fd5b50813567ffffffffffffffff811115612a3157600080fd5b6020830191508360208260051b8501011115612a4c57600080fd5b9250929050565b600080600060408486031215612a6857600080fd5b833567ffffffffffffffff811115612a7f57600080fd5b612a8b86828701612a07565b90945092505060208401356129aa81612826565b60008060208385031215612ab257600080fd5b823567ffffffffffffffff811115612ac957600080fd5b612ad585828601612a07565b90969095509350505050565b60005b83811015612afc578181015183820152602001612ae4565b8381111561064f5750506000910152565b6020815260008251806020840152612b2c816040850160208701612ae1565b601f01601f19169190910160400192915050565b60008060408385031215612b5357600080fd5b8235612b5e81612826565b915060208301356129da81612826565b60008060008060808587031215612b8457600080fd5b8435612b8f81612826565b93506020850135612b9f81612826565b92506040850135612baf81612826565b91506060850135612bbf81612826565b939692955090935050565b60208082526022908201527f4669676874657255524948616e646c65723a20636f6e74726163742070617573604082015261195960f21b606082015260800190565b600060208284031215612c1e57600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b600060ff821660ff841680821015612c5557612c55612c25565b90039392505050565b600060ff821660ff84168060ff03821115612c7b57612c7b612c25565b019392505050565b634e487b7160e01b600052601260045260246000fd5b600082612ca857612ca8612c83565b500690565b60008351612cbf818460208801612ae1565b835190830190612cd3818360208801612ae1565b01949350505050565b600060208284031215612cee57600080fd5b81516109d581612826565b8281526040810160068310612d1e57634e487b7160e01b600052602160045260246000fd5b8260208301529392505050565b805161ffff8116811461137957600080fd5b600060208284031215612d4f57600080fd5b6109d582612d2b565b6000816000190483118215151615612d7257612d72612c25565b500290565b600082612d8657612d86612c83565b500490565b600082821015612d9d57612d9d612c25565b500390565b600060208284031215612db457600080fd5b815180151581146109d557600080fd5b600060e08284031215612dd657600080fd5b60405160e0810181811067ffffffffffffffff82111715612df957612df9612858565b604052612e0583612d2b565b8152612e1360208401612d2b565b6020820152612e2460408401612d2b565b6040820152612e3560608401612d2b565b6060820152612e4660808401612d2b565b6080820152612e5760a08401612d2b565b60a082015260c0830151612e6a81612826565b60c08201529392505050565b634e487b7160e01b600052603260045260246000fd5b600060018201612e9e57612e9e612c25565b5060010190565b60008219821115612eb857612eb8612c25565b500190565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351612f43816017850160208801612ae1565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351612f74816028840160208801612ae1565b01602801949350505050565b604080825283519082018190526000906020906060840190828701845b82811015612fb957815184529284019290840190600101612f9d565b5050508381038285015284518082528583019183019060005b81811015612ff157835160ff1683529284019291840191600101612fd2565b5090979650505050505050565b60006020828403121561301057600080fd5b81516109d5816127f3565b60008161302a5761302a612c25565b506000190190565b634e487b7160e01b600052603160045260246000fdfe68747470733a2f2f6170692e726169642e70617274792f6d657461646174612f6865726f2fa26469706673582212203b7d8554337582499f31055624304c2f6991ba9baf7c514b03d700977fb54ef864736f6c634300080d0033

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
[ Download: CSV Export  ]

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.