ETH Price: $2,040.20 (+2.26%)
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

More Info

Private Name Tags

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To

There are no matching entries

Please try again later

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading
Loading...
Loading
Cross-Chain Transactions

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
ImxMintableERC721

Compiler Version
v0.8.11+commit.d7f03943

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

import "../interfaces/ImmutableSpec.sol";
import "./RoyalERC721.sol";
import "@imtbl/imx-contracts/contracts/utils/Minting.sol";

/**
 * @title Immutable Mintable ERC721
 *
 * @notice Generic contract compatible with IMX (ImmutableMintableERC721) to be reused
 *      to deploy any ERC721 asset on IMX (ex.: IlluvitarERC721, AccessoryERC721, D1skERC721)
 *
 * @notice Contract can be redeployed in full,
 *      or a proxy can be used pointing to already deployed implementation
 *
 * @author Yuri Fernandes
 */
contract ImxMintableERC721 is RoyalERC721, ImmutableMintableERC721 {
	/**
	 * @dev "Constructor replacement" for upgradeable, must be execute immediately after deployment
	 *      see https://docs.openzeppelin.com/upgrades-plugins/1.x/writing-upgradeable#initializers
	 *
	 * @param _name token name (ERC721Metadata)
	 * @param _symbol token symbol (ERC721Metadata)
	 */
	function postConstruct(string memory _name, string memory _symbol) public virtual initializer {
		// execute all parent initializers in cascade
		super._postConstruct(_name, _symbol, msg.sender);
	}

	/**
	 * @inheritdoc ImmutableMintableERC721
	 *
	 * @dev Restricted access function to mint the token  and assign
	 *      the metadata packed into the IMX `mintingBlob` bytes array
	 *
	 * @dev Creates new token with the token ID specified
	 *      and assigns an ownership `_to` for this token
	 *
	 * @dev Unsafe: doesn't execute `onERC721Received` on the receiver.
	 *
	 * @dev Requires executor to have ROLE_TOKEN_CREATOR permission
	 *
	 * @param _to an address to mint token to
	 * @param _quantity rudimentary (ERC20 amount of tokens to mint) equal to one,
	 *      implementation MUST revert if it not equal to one
	 * @param _mintingBlob blob containing the ID of the NFT and its metadata as
	 *      `{tokenId}:{metadata}` string, where `tokenId` is encoded as decimal string,
	 *      and metadata can be anything, but most likely is also encoded as decimal string
	 */
	function mintFor(address _to, uint256 _quantity, bytes calldata _mintingBlob) public virtual override {
		// ensure quantity is equal to one (rudimentary ERC20 amount of tokens to mint)
		require(_quantity == 1, "quantity must be equal to one");

		// parse the `_mintingBlob` and extract the tokenId and metadata from it
		(uint256 _tokenId,) = Minting.split(_mintingBlob);

		// delegate to `mint`
		mint(_to, _tokenId);
	}

}

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

library Bytes {
    /**
     * @dev Converts a `uint256` to a `string`.
     * via OraclizeAPI - MIT licence
     * https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
     */
    function fromUint(uint256 value) internal pure returns (string memory) {
        if (value == 0) {
            return "0";
        }
        uint256 temp = value;
        uint256 digits;
        while (temp != 0) {
            digits++;
            temp /= 10;
        }
        bytes memory buffer = new bytes(digits);
        uint256 index = digits - 1;
        temp = value;
        while (temp != 0) {
            buffer[index--] = bytes1(uint8(48 + (temp % 10)));
            temp /= 10;
        }
        return string(buffer);
    }

    bytes constant alphabet = "0123456789abcdef";

    /**
     * Index Of
     *
     * Locates and returns the position of a character within a string starting
     * from a defined offset
     *
     * @param _base When being used for a data type this is the extended object
     *              otherwise this is the string acting as the haystack to be
     *              searched
     * @param _value The needle to search for, at present this is currently
     *               limited to one character
     * @param _offset The starting point to start searching from which can start
     *                from 0, but must not exceed the length of the string
     * @return int The position of the needle starting from 0 and returning -1
     *             in the case of no matches found
     */
    function indexOf(
        bytes memory _base,
        string memory _value,
        uint256 _offset
    ) internal pure returns (int256) {
        bytes memory _valueBytes = bytes(_value);

        assert(_valueBytes.length == 1);

        for (uint256 i = _offset; i < _base.length; i++) {
            if (_base[i] == _valueBytes[0]) {
                return int256(i);
            }
        }

        return -1;
    }

    function substring(
        bytes memory strBytes,
        uint256 startIndex,
        uint256 endIndex
    ) internal pure returns (string memory) {
        bytes memory result = new bytes(endIndex - startIndex);
        for (uint256 i = startIndex; i < endIndex; i++) {
            result[i - startIndex] = strBytes[i];
        }
        return string(result);
    }

    function toUint(bytes memory b) internal pure returns (uint256) {
        uint256 result = 0;
        for (uint256 i = 0; i < b.length; i++) {
            uint256 val = uint256(uint8(b[i]));
            if (val >= 48 && val <= 57) {
                // input is 0-9
                result = result * 10 + (val - 48);
            } else {
                // invalid character, expecting integer input
                revert("invalid input, only numbers allowed");
            }
        }
        return result;
    }
}

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

import "./Bytes.sol";

library Minting {
    // Split the minting blob into token_id and blueprint portions
    // {token_id}:{blueprint}

    function split(bytes calldata blob)
        internal
        pure
        returns (uint256, bytes memory)
    {
        int256 index = Bytes.indexOf(blob, ":", 0);
        require(index >= 0, "Separator must exist");
        // Trim the { and } from the parameters
        uint256 tokenID = Bytes.toUint(blob[1:uint256(index) - 1]);
        uint256 blueprintLength = blob.length - uint256(index) - 3;
        if (blueprintLength == 0) {
            return (tokenID, bytes(""));
        }
        bytes calldata blueprint = blob[uint256(index) + 2:blob.length - 1];
        return (tokenID, blueprint);
    }
}

File 4 of 32 : draft-IERC1822Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)

pragma solidity ^0.8.0;

/**
 * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified
 * proxy whose upgrades are fully controlled by the current implementation.
 */
interface IERC1822ProxiableUpgradeable {
    /**
     * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation
     * address.
     *
     * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
     * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
     * function revert if invoked through a proxy.
     */
    function proxiableUUID() external view returns (bytes32);
}

File 5 of 32 : IBeaconUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)

pragma solidity ^0.8.0;

/**
 * @dev This is the interface that {BeaconProxy} expects of its beacon.
 */
interface IBeaconUpgradeable {
    /**
     * @dev Must return an address that can be used as a delegate call target.
     *
     * {BeaconProxy} will check that this address is a contract.
     */
    function implementation() external view returns (address);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)

pragma solidity ^0.8.2;

import "../beacon/IBeaconUpgradeable.sol";
import "../../interfaces/draft-IERC1822Upgradeable.sol";
import "../../utils/AddressUpgradeable.sol";
import "../../utils/StorageSlotUpgradeable.sol";
import "../utils/Initializable.sol";

/**
 * @dev This abstract contract provides getters and event emitting update functions for
 * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
 *
 * _Available since v4.1._
 *
 * @custom:oz-upgrades-unsafe-allow delegatecall
 */
abstract contract ERC1967UpgradeUpgradeable is Initializable {
    function __ERC1967Upgrade_init() internal onlyInitializing {
    }

    function __ERC1967Upgrade_init_unchained() internal onlyInitializing {
    }
    // This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1
    bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;

    /**
     * @dev Storage slot with the address of the current implementation.
     * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is
     * validated in the constructor.
     */
    bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;

    /**
     * @dev Emitted when the implementation is upgraded.
     */
    event Upgraded(address indexed implementation);

    /**
     * @dev Returns the current implementation address.
     */
    function _getImplementation() internal view returns (address) {
        return StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value;
    }

    /**
     * @dev Stores a new address in the EIP1967 implementation slot.
     */
    function _setImplementation(address newImplementation) private {
        require(AddressUpgradeable.isContract(newImplementation), "ERC1967: new implementation is not a contract");
        StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
    }

    /**
     * @dev Perform implementation upgrade
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeTo(address newImplementation) internal {
        _setImplementation(newImplementation);
        emit Upgraded(newImplementation);
    }

    /**
     * @dev Perform implementation upgrade with additional setup call.
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeToAndCall(
        address newImplementation,
        bytes memory data,
        bool forceCall
    ) internal {
        _upgradeTo(newImplementation);
        if (data.length > 0 || forceCall) {
            _functionDelegateCall(newImplementation, data);
        }
    }

    /**
     * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeToAndCallUUPS(
        address newImplementation,
        bytes memory data,
        bool forceCall
    ) internal {
        // Upgrades from old implementations will perform a rollback test. This test requires the new
        // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing
        // this special case will break upgrade paths from old UUPS implementation to new ones.
        if (StorageSlotUpgradeable.getBooleanSlot(_ROLLBACK_SLOT).value) {
            _setImplementation(newImplementation);
        } else {
            try IERC1822ProxiableUpgradeable(newImplementation).proxiableUUID() returns (bytes32 slot) {
                require(slot == _IMPLEMENTATION_SLOT, "ERC1967Upgrade: unsupported proxiableUUID");
            } catch {
                revert("ERC1967Upgrade: new implementation is not UUPS");
            }
            _upgradeToAndCall(newImplementation, data, forceCall);
        }
    }

    /**
     * @dev Storage slot with the admin of the contract.
     * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is
     * validated in the constructor.
     */
    bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;

    /**
     * @dev Emitted when the admin account has changed.
     */
    event AdminChanged(address previousAdmin, address newAdmin);

    /**
     * @dev Returns the current admin.
     */
    function _getAdmin() internal view returns (address) {
        return StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value;
    }

    /**
     * @dev Stores a new address in the EIP1967 admin slot.
     */
    function _setAdmin(address newAdmin) private {
        require(newAdmin != address(0), "ERC1967: new admin is the zero address");
        StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value = newAdmin;
    }

    /**
     * @dev Changes the admin of the proxy.
     *
     * Emits an {AdminChanged} event.
     */
    function _changeAdmin(address newAdmin) internal {
        emit AdminChanged(_getAdmin(), newAdmin);
        _setAdmin(newAdmin);
    }

    /**
     * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
     * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.
     */
    bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;

    /**
     * @dev Emitted when the beacon is upgraded.
     */
    event BeaconUpgraded(address indexed beacon);

    /**
     * @dev Returns the current beacon.
     */
    function _getBeacon() internal view returns (address) {
        return StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value;
    }

    /**
     * @dev Stores a new beacon in the EIP1967 beacon slot.
     */
    function _setBeacon(address newBeacon) private {
        require(AddressUpgradeable.isContract(newBeacon), "ERC1967: new beacon is not a contract");
        require(
            AddressUpgradeable.isContract(IBeaconUpgradeable(newBeacon).implementation()),
            "ERC1967: beacon implementation is not a contract"
        );
        StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value = newBeacon;
    }

    /**
     * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does
     * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).
     *
     * Emits a {BeaconUpgraded} event.
     */
    function _upgradeBeaconToAndCall(
        address newBeacon,
        bytes memory data,
        bool forceCall
    ) internal {
        _setBeacon(newBeacon);
        emit BeaconUpgraded(newBeacon);
        if (data.length > 0 || forceCall) {
            _functionDelegateCall(IBeaconUpgradeable(newBeacon).implementation(), data);
        }
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function _functionDelegateCall(address target, bytes memory data) private returns (bytes memory) {
        require(AddressUpgradeable.isContract(target), "Address: delegate call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return AddressUpgradeable.verifyCallResult(success, returndata, "Address: low-level delegate call failed");
    }

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.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.
     *
     * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a
     * constructor.
     *
     * Emits an {Initialized} event.
     */
    modifier initializer() {
        bool isTopLevelCall = !_initializing;
        require(
            (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),
            "Initializable: contract is already initialized"
        );
        _initialized = 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.
     *
     * 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.
     *
     * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
     * cannot be nested. If one is invoked in the context of another, execution will revert.
     *
     * 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.
     *
     * WARNING: setting the version to 255 will prevent any future reinitialization.
     *
     * Emits an {Initialized} event.
     */
    modifier reinitializer(uint8 version) {
        require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
        _initialized = version;
        _initializing = true;
        _;
        _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.
     *
     * Emits an {Initialized} event the first time it is successfully executed.
     */
    function _disableInitializers() internal virtual {
        require(!_initializing, "Initializable: contract is initializing");
        if (_initialized < type(uint8).max) {
            _initialized = type(uint8).max;
            emit Initialized(type(uint8).max);
        }
    }

    /**
     * @dev Internal function that returns the initialized version. Returns `_initialized`
     */
    function _getInitializedVersion() internal view returns (uint8) {
        return _initialized;
    }

    /**
     * @dev Internal function that returns the initialized version. Returns `_initializing`
     */
    function _isInitializing() internal view returns (bool) {
        return _initializing;
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (proxy/utils/UUPSUpgradeable.sol)

pragma solidity ^0.8.0;

import "../../interfaces/draft-IERC1822Upgradeable.sol";
import "../ERC1967/ERC1967UpgradeUpgradeable.sol";
import "./Initializable.sol";

/**
 * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an
 * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy.
 *
 * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is
 * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing
 * `UUPSUpgradeable` with a custom implementation of upgrades.
 *
 * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism.
 *
 * _Available since v4.1._
 */
abstract contract UUPSUpgradeable is Initializable, IERC1822ProxiableUpgradeable, ERC1967UpgradeUpgradeable {
    function __UUPSUpgradeable_init() internal onlyInitializing {
    }

    function __UUPSUpgradeable_init_unchained() internal onlyInitializing {
    }
    /// @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment
    address private immutable __self = address(this);

    /**
     * @dev Check that the execution is being performed through a delegatecall call and that the execution context is
     * a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case
     * for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a
     * function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to
     * fail.
     */
    modifier onlyProxy() {
        require(address(this) != __self, "Function must be called through delegatecall");
        require(_getImplementation() == __self, "Function must be called through active proxy");
        _;
    }

    /**
     * @dev Check that the execution is not being performed through a delegate call. This allows a function to be
     * callable on the implementing contract but not through proxies.
     */
    modifier notDelegated() {
        require(address(this) == __self, "UUPSUpgradeable: must not be called through delegatecall");
        _;
    }

    /**
     * @dev Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the
     * implementation. It is used to validate the implementation's compatibility when performing an upgrade.
     *
     * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
     * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
     * function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier.
     */
    function proxiableUUID() external view virtual override notDelegated returns (bytes32) {
        return _IMPLEMENTATION_SLOT;
    }

    /**
     * @dev Upgrade the implementation of the proxy to `newImplementation`.
     *
     * Calls {_authorizeUpgrade}.
     *
     * Emits an {Upgraded} event.
     */
    function upgradeTo(address newImplementation) external virtual onlyProxy {
        _authorizeUpgrade(newImplementation);
        _upgradeToAndCallUUPS(newImplementation, new bytes(0), false);
    }

    /**
     * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call
     * encoded in `data`.
     *
     * Calls {_authorizeUpgrade}.
     *
     * Emits an {Upgraded} event.
     */
    function upgradeToAndCall(address newImplementation, bytes memory data) external payable virtual onlyProxy {
        _authorizeUpgrade(newImplementation);
        _upgradeToAndCallUUPS(newImplementation, data, true);
    }

    /**
     * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by
     * {upgradeTo} and {upgradeToAndCall}.
     *
     * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.
     *
     * ```solidity
     * function _authorizeUpgrade(address) internal override onlyOwner {}
     * ```
     */
    function _authorizeUpgrade(address newImplementation) internal virtual;

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/ERC721.sol)

pragma solidity ^0.8.0;

import "./IERC721Upgradeable.sol";
import "./IERC721ReceiverUpgradeable.sol";
import "./extensions/IERC721MetadataUpgradeable.sol";
import "../../utils/AddressUpgradeable.sol";
import "../../utils/ContextUpgradeable.sol";
import "../../utils/StringsUpgradeable.sol";
import "../../utils/introspection/ERC165Upgradeable.sol";
import "../../proxy/utils/Initializable.sol";

/**
 * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
 * the Metadata extension, but not including the Enumerable extension, which is available separately as
 * {ERC721Enumerable}.
 */
contract ERC721Upgradeable is Initializable, ContextUpgradeable, ERC165Upgradeable, IERC721Upgradeable, IERC721MetadataUpgradeable {
    using AddressUpgradeable for address;
    using StringsUpgradeable for uint256;

    // Token name
    string private _name;

    // Token symbol
    string private _symbol;

    // Mapping from token ID to owner address
    mapping(uint256 => address) private _owners;

    // Mapping owner address to token count
    mapping(address => uint256) private _balances;

    // Mapping from token ID to approved address
    mapping(uint256 => address) private _tokenApprovals;

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

    /**
     * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
     */
    function __ERC721_init(string memory name_, string memory symbol_) internal onlyInitializing {
        __ERC721_init_unchained(name_, symbol_);
    }

    function __ERC721_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing {
        _name = name_;
        _symbol = symbol_;
    }

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

    /**
     * @dev See {IERC721-balanceOf}.
     */
    function balanceOf(address owner) public view virtual override returns (uint256) {
        require(owner != address(0), "ERC721: address zero is not a valid owner");
        return _balances[owner];
    }

    /**
     * @dev See {IERC721-ownerOf}.
     */
    function ownerOf(uint256 tokenId) public view virtual override returns (address) {
        address owner = _ownerOf(tokenId);
        require(owner != address(0), "ERC721: invalid token ID");
        return owner;
    }

    /**
     * @dev See {IERC721Metadata-name}.
     */
    function name() public view virtual override returns (string memory) {
        return _name;
    }

    /**
     * @dev See {IERC721Metadata-symbol}.
     */
    function symbol() public view virtual override returns (string memory) {
        return _symbol;
    }

    /**
     * @dev See {IERC721Metadata-tokenURI}.
     */
    function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
        _requireMinted(tokenId);

        string memory baseURI = _baseURI();
        return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : "";
    }

    /**
     * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
     * token will be the concatenation of the `baseURI` and the `tokenId`. Empty
     * by default, can be overridden in child contracts.
     */
    function _baseURI() internal view virtual returns (string memory) {
        return "";
    }

    /**
     * @dev See {IERC721-approve}.
     */
    function approve(address to, uint256 tokenId) public virtual override {
        address owner = ERC721Upgradeable.ownerOf(tokenId);
        require(to != owner, "ERC721: approval to current owner");

        require(
            _msgSender() == owner || isApprovedForAll(owner, _msgSender()),
            "ERC721: approve caller is not token owner or approved for all"
        );

        _approve(to, tokenId);
    }

    /**
     * @dev See {IERC721-getApproved}.
     */
    function getApproved(uint256 tokenId) public view virtual override returns (address) {
        _requireMinted(tokenId);

        return _tokenApprovals[tokenId];
    }

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

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

    /**
     * @dev See {IERC721-transferFrom}.
     */
    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) public virtual override {
        //solhint-disable-next-line max-line-length
        require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner or approved");

        _transfer(from, to, tokenId);
    }

    /**
     * @dev See {IERC721-safeTransferFrom}.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    ) public virtual override {
        safeTransferFrom(from, to, tokenId, "");
    }

    /**
     * @dev See {IERC721-safeTransferFrom}.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId,
        bytes memory data
    ) public virtual override {
        require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner or approved");
        _safeTransfer(from, to, tokenId, data);
    }

    /**
     * @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.
     *
     * `data` is additional data, it has no specified format and it is sent in call to `to`.
     *
     * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
     * implement alternative mechanisms to perform token transfer, such as signature-based.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function _safeTransfer(
        address from,
        address to,
        uint256 tokenId,
        bytes memory data
    ) internal virtual {
        _transfer(from, to, tokenId);
        require(_checkOnERC721Received(from, to, tokenId, data), "ERC721: transfer to non ERC721Receiver implementer");
    }

    /**
     * @dev Returns the owner of the `tokenId`. Does NOT revert if token doesn't exist
     */
    function _ownerOf(uint256 tokenId) internal view virtual returns (address) {
        return _owners[tokenId];
    }

    /**
     * @dev Returns whether `tokenId` exists.
     *
     * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
     *
     * Tokens start existing when they are minted (`_mint`),
     * and stop existing when they are burned (`_burn`).
     */
    function _exists(uint256 tokenId) internal view virtual returns (bool) {
        return _ownerOf(tokenId) != address(0);
    }

    /**
     * @dev Returns whether `spender` is allowed to manage `tokenId`.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
        address owner = ERC721Upgradeable.ownerOf(tokenId);
        return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender);
    }

    /**
     * @dev Safely mints `tokenId` and transfers it to `to`.
     *
     * Requirements:
     *
     * - `tokenId` must not exist.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function _safeMint(address to, uint256 tokenId) internal virtual {
        _safeMint(to, tokenId, "");
    }

    /**
     * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
     * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
     */
    function _safeMint(
        address to,
        uint256 tokenId,
        bytes memory data
    ) internal virtual {
        _mint(to, tokenId);
        require(
            _checkOnERC721Received(address(0), to, tokenId, data),
            "ERC721: transfer to non ERC721Receiver implementer"
        );
    }

    /**
     * @dev Mints `tokenId` and transfers it to `to`.
     *
     * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
     *
     * Requirements:
     *
     * - `tokenId` must not exist.
     * - `to` cannot be the zero address.
     *
     * Emits a {Transfer} event.
     */
    function _mint(address to, uint256 tokenId) internal virtual {
        require(to != address(0), "ERC721: mint to the zero address");
        require(!_exists(tokenId), "ERC721: token already minted");

        _beforeTokenTransfer(address(0), to, tokenId, 1);

        // Check that tokenId was not minted by `_beforeTokenTransfer` hook
        require(!_exists(tokenId), "ERC721: token already minted");

        unchecked {
            // Will not overflow unless all 2**256 token ids are minted to the same owner.
            // Given that tokens are minted one by one, it is impossible in practice that
            // this ever happens. Might change if we allow batch minting.
            // The ERC fails to describe this case.
            _balances[to] += 1;
        }

        _owners[tokenId] = to;

        emit Transfer(address(0), to, tokenId);

        _afterTokenTransfer(address(0), to, tokenId, 1);
    }

    /**
     * @dev Destroys `tokenId`.
     * The approval is cleared when the token is burned.
     * This is an internal function that does not check if the sender is authorized to operate on the token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     *
     * Emits a {Transfer} event.
     */
    function _burn(uint256 tokenId) internal virtual {
        address owner = ERC721Upgradeable.ownerOf(tokenId);

        _beforeTokenTransfer(owner, address(0), tokenId, 1);

        // Update ownership in case tokenId was transferred by `_beforeTokenTransfer` hook
        owner = ERC721Upgradeable.ownerOf(tokenId);

        // Clear approvals
        delete _tokenApprovals[tokenId];

        unchecked {
            // Cannot overflow, as that would require more tokens to be burned/transferred
            // out than the owner initially received through minting and transferring in.
            _balances[owner] -= 1;
        }
        delete _owners[tokenId];

        emit Transfer(owner, address(0), tokenId);

        _afterTokenTransfer(owner, address(0), tokenId, 1);
    }

    /**
     * @dev Transfers `tokenId` from `from` to `to`.
     *  As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     *
     * Emits a {Transfer} event.
     */
    function _transfer(
        address from,
        address to,
        uint256 tokenId
    ) internal virtual {
        require(ERC721Upgradeable.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner");
        require(to != address(0), "ERC721: transfer to the zero address");

        _beforeTokenTransfer(from, to, tokenId, 1);

        // Check that tokenId was not transferred by `_beforeTokenTransfer` hook
        require(ERC721Upgradeable.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner");

        // Clear approvals from the previous owner
        delete _tokenApprovals[tokenId];

        unchecked {
            // `_balances[from]` cannot overflow for the same reason as described in `_burn`:
            // `from`'s balance is the number of token held, which is at least one before the current
            // transfer.
            // `_balances[to]` could overflow in the conditions described in `_mint`. That would require
            // all 2**256 token ids to be minted, which in practice is impossible.
            _balances[from] -= 1;
            _balances[to] += 1;
        }
        _owners[tokenId] = to;

        emit Transfer(from, to, tokenId);

        _afterTokenTransfer(from, to, tokenId, 1);
    }

    /**
     * @dev Approve `to` to operate on `tokenId`
     *
     * Emits an {Approval} event.
     */
    function _approve(address to, uint256 tokenId) internal virtual {
        _tokenApprovals[tokenId] = to;
        emit Approval(ERC721Upgradeable.ownerOf(tokenId), to, tokenId);
    }

    /**
     * @dev Approve `operator` to operate on all of `owner` tokens
     *
     * Emits an {ApprovalForAll} event.
     */
    function _setApprovalForAll(
        address owner,
        address operator,
        bool approved
    ) internal virtual {
        require(owner != operator, "ERC721: approve to caller");
        _operatorApprovals[owner][operator] = approved;
        emit ApprovalForAll(owner, operator, approved);
    }

    /**
     * @dev Reverts if the `tokenId` has not been minted yet.
     */
    function _requireMinted(uint256 tokenId) internal view virtual {
        require(_exists(tokenId), "ERC721: invalid token ID");
    }

    /**
     * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
     * The call is not executed if the target address is not a contract.
     *
     * @param from address representing the previous owner of the given token ID
     * @param to target address that will receive the tokens
     * @param tokenId uint256 ID of the token to be transferred
     * @param data bytes optional data to send along with the call
     * @return bool whether the call correctly returned the expected magic value
     */
    function _checkOnERC721Received(
        address from,
        address to,
        uint256 tokenId,
        bytes memory data
    ) private returns (bool) {
        if (to.isContract()) {
            try IERC721ReceiverUpgradeable(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) {
                return retval == IERC721ReceiverUpgradeable.onERC721Received.selector;
            } catch (bytes memory reason) {
                if (reason.length == 0) {
                    revert("ERC721: transfer to non ERC721Receiver implementer");
                } else {
                    /// @solidity memory-safe-assembly
                    assembly {
                        revert(add(32, reason), mload(reason))
                    }
                }
            }
        } else {
            return true;
        }
    }

    /**
     * @dev Hook that is called before any token transfer. This includes minting and burning. If {ERC721Consecutive} is
     * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1.
     *
     * Calling conditions:
     *
     * - When `from` and `to` are both non-zero, ``from``'s tokens will be transferred to `to`.
     * - When `from` is zero, the tokens will be minted for `to`.
     * - When `to` is zero, ``from``'s tokens will be burned.
     * - `from` and `to` are never both zero.
     * - `batchSize` is non-zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(
        address from,
        address to,
        uint256, /* firstTokenId */
        uint256 batchSize
    ) internal virtual {
        if (batchSize > 1) {
            if (from != address(0)) {
                _balances[from] -= batchSize;
            }
            if (to != address(0)) {
                _balances[to] += batchSize;
            }
        }
    }

    /**
     * @dev Hook that is called after any token transfer. This includes minting and burning. If {ERC721Consecutive} is
     * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1.
     *
     * Calling conditions:
     *
     * - When `from` and `to` are both non-zero, ``from``'s tokens were transferred to `to`.
     * - When `from` is zero, the tokens were minted for `to`.
     * - When `to` is zero, ``from``'s tokens were burned.
     * - `from` and `to` are never both zero.
     * - `batchSize` is non-zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _afterTokenTransfer(
        address from,
        address to,
        uint256 firstTokenId,
        uint256 batchSize
    ) internal virtual {}

    /**
     * @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[44] private __gap;
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/extensions/ERC721Enumerable.sol)

pragma solidity ^0.8.0;

import "../ERC721Upgradeable.sol";
import "./IERC721EnumerableUpgradeable.sol";
import "../../../proxy/utils/Initializable.sol";

/**
 * @dev This implements an optional extension of {ERC721} defined in the EIP that adds
 * enumerability of all the token ids in the contract as well as all token ids owned by each
 * account.
 */
abstract contract ERC721EnumerableUpgradeable is Initializable, ERC721Upgradeable, IERC721EnumerableUpgradeable {
    function __ERC721Enumerable_init() internal onlyInitializing {
    }

    function __ERC721Enumerable_init_unchained() internal onlyInitializing {
    }
    // Mapping from owner to list of owned token IDs
    mapping(address => mapping(uint256 => uint256)) private _ownedTokens;

    // Mapping from token ID to index of the owner tokens list
    mapping(uint256 => uint256) private _ownedTokensIndex;

    // Array with all token ids, used for enumeration
    uint256[] private _allTokens;

    // Mapping from token id to position in the allTokens array
    mapping(uint256 => uint256) private _allTokensIndex;

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

    /**
     * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
     */
    function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) {
        require(index < ERC721Upgradeable.balanceOf(owner), "ERC721Enumerable: owner index out of bounds");
        return _ownedTokens[owner][index];
    }

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

    /**
     * @dev See {IERC721Enumerable-tokenByIndex}.
     */
    function tokenByIndex(uint256 index) public view virtual override returns (uint256) {
        require(index < ERC721EnumerableUpgradeable.totalSupply(), "ERC721Enumerable: global index out of bounds");
        return _allTokens[index];
    }

    /**
     * @dev See {ERC721-_beforeTokenTransfer}.
     */
    function _beforeTokenTransfer(
        address from,
        address to,
        uint256 firstTokenId,
        uint256 batchSize
    ) internal virtual override {
        super._beforeTokenTransfer(from, to, firstTokenId, batchSize);

        if (batchSize > 1) {
            // Will only trigger during construction. Batch transferring (minting) is not available afterwards.
            revert("ERC721Enumerable: consecutive transfers not supported");
        }

        uint256 tokenId = firstTokenId;

        if (from == address(0)) {
            _addTokenToAllTokensEnumeration(tokenId);
        } else if (from != to) {
            _removeTokenFromOwnerEnumeration(from, tokenId);
        }
        if (to == address(0)) {
            _removeTokenFromAllTokensEnumeration(tokenId);
        } else if (to != from) {
            _addTokenToOwnerEnumeration(to, tokenId);
        }
    }

    /**
     * @dev Private function to add a token to this extension's ownership-tracking data structures.
     * @param to address representing the new owner of the given token ID
     * @param tokenId uint256 ID of the token to be added to the tokens list of the given address
     */
    function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {
        uint256 length = ERC721Upgradeable.balanceOf(to);
        _ownedTokens[to][length] = tokenId;
        _ownedTokensIndex[tokenId] = length;
    }

    /**
     * @dev Private function to add a token to this extension's token tracking data structures.
     * @param tokenId uint256 ID of the token to be added to the tokens list
     */
    function _addTokenToAllTokensEnumeration(uint256 tokenId) private {
        _allTokensIndex[tokenId] = _allTokens.length;
        _allTokens.push(tokenId);
    }

    /**
     * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that
     * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for
     * gas optimizations e.g. when performing a transfer operation (avoiding double writes).
     * This has O(1) time complexity, but alters the order of the _ownedTokens array.
     * @param from address representing the previous owner of the given token ID
     * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address
     */
    function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private {
        // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and
        // then delete the last slot (swap and pop).

        uint256 lastTokenIndex = ERC721Upgradeable.balanceOf(from) - 1;
        uint256 tokenIndex = _ownedTokensIndex[tokenId];

        // When the token to delete is the last token, the swap operation is unnecessary
        if (tokenIndex != lastTokenIndex) {
            uint256 lastTokenId = _ownedTokens[from][lastTokenIndex];

            _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
            _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
        }

        // This also deletes the contents at the last position of the array
        delete _ownedTokensIndex[tokenId];
        delete _ownedTokens[from][lastTokenIndex];
    }

    /**
     * @dev Private function to remove a token from this extension's token tracking data structures.
     * This has O(1) time complexity, but alters the order of the _allTokens array.
     * @param tokenId uint256 ID of the token to be removed from the tokens list
     */
    function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {
        // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and
        // then delete the last slot (swap and pop).

        uint256 lastTokenIndex = _allTokens.length - 1;
        uint256 tokenIndex = _allTokensIndex[tokenId];

        // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so
        // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding
        // an 'if' statement (like in _removeTokenFromOwnerEnumeration)
        uint256 lastTokenId = _allTokens[lastTokenIndex];

        _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
        _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index

        // This also deletes the contents at the last position of the array
        delete _allTokensIndex[tokenId];
        _allTokens.pop();
    }

    /**
     * @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[46] private __gap;
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/extensions/ERC721URIStorage.sol)

pragma solidity ^0.8.0;

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

/**
 * @dev ERC721 token with storage based token URI management.
 */
abstract contract ERC721URIStorageUpgradeable is Initializable, ERC721Upgradeable {
    function __ERC721URIStorage_init() internal onlyInitializing {
    }

    function __ERC721URIStorage_init_unchained() internal onlyInitializing {
    }
    using StringsUpgradeable for uint256;

    // Optional mapping for token URIs
    mapping(uint256 => string) private _tokenURIs;

    /**
     * @dev See {IERC721Metadata-tokenURI}.
     */
    function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
        _requireMinted(tokenId);

        string memory _tokenURI = _tokenURIs[tokenId];
        string memory base = _baseURI();

        // If there is no base URI, return the token URI.
        if (bytes(base).length == 0) {
            return _tokenURI;
        }
        // If both are set, concatenate the baseURI and tokenURI (via abi.encodePacked).
        if (bytes(_tokenURI).length > 0) {
            return string(abi.encodePacked(base, _tokenURI));
        }

        return super.tokenURI(tokenId);
    }

    /**
     * @dev Sets `_tokenURI` as the tokenURI of `tokenId`.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal virtual {
        require(_exists(tokenId), "ERC721URIStorage: URI set of nonexistent token");
        _tokenURIs[tokenId] = _tokenURI;
    }

    /**
     * @dev See {ERC721-_burn}. This override additionally checks to see if a
     * token-specific URI was set for the token, and if so, it deletes the token URI from
     * the storage mapping.
     */
    function _burn(uint256 tokenId) internal virtual override {
        super._burn(tokenId);

        if (bytes(_tokenURIs[tokenId]).length != 0) {
            delete _tokenURIs[tokenId];
        }
    }

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol)

pragma solidity ^0.8.0;

import "../IERC721Upgradeable.sol";

/**
 * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
 * @dev See https://eips.ethereum.org/EIPS/eip-721
 */
interface IERC721EnumerableUpgradeable is IERC721Upgradeable {
    /**
     * @dev Returns the total amount of tokens stored by the contract.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns a token ID owned by `owner` at a given `index` of its token list.
     * Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
     */
    function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256);

    /**
     * @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
     * Use along with {totalSupply} to enumerate all tokens.
     */
    function tokenByIndex(uint256 index) external view returns (uint256);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)

pragma solidity ^0.8.0;

import "../IERC721Upgradeable.sol";

/**
 * @title ERC-721 Non-Fungible Token Standard, optional metadata extension
 * @dev See https://eips.ethereum.org/EIPS/eip-721
 */
interface IERC721MetadataUpgradeable is IERC721Upgradeable {
    /**
     * @dev Returns the token collection name.
     */
    function name() external view returns (string memory);

    /**
     * @dev Returns the token collection symbol.
     */
    function symbol() external view returns (string memory);

    /**
     * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
     */
    function tokenURI(uint256 tokenId) external view returns (string memory);
}

File 14 of 32 : 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);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol)

pragma solidity ^0.8.0;

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

/**
 * @dev Required interface of an ERC721 compliant contract.
 */
interface IERC721Upgradeable is IERC165Upgradeable {
    /**
     * @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 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: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721
     * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
     * understand this adds an external call which potentially creates a reentrancy vulnerability.
     *
     * 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);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.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 functionCallWithValue(target, data, 0, "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");
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, 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) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
     *
     * _Available since v4.8._
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        if (success) {
            if (returndata.length == 0) {
                // only check isContract if the call was successful and the return data is empty
                // otherwise we already know that it was a contract
                require(isContract(target), "Address: call to non-contract");
            }
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason or 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 {
            _revert(returndata, errorMessage);
        }
    }

    function _revert(bytes memory returndata, string memory errorMessage) private pure {
        // 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
            /// @solidity memory-safe-assembly
            assembly {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert(errorMessage);
        }
    }
}

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

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

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)

pragma solidity ^0.8.0;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library MathUpgradeable {
    enum Rounding {
        Down, // Toward negative infinity
        Up, // Toward infinity
        Zero // Toward zero
    }

    /**
     * @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 == 0 ? 0 : (a - 1) / b + 1;
    }

    /**
     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
     * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
     * with further edits by Uniswap Labs also under MIT license.
     */
    function mulDiv(
        uint256 x,
        uint256 y,
        uint256 denominator
    ) internal pure returns (uint256 result) {
        unchecked {
            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
            // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
            // variables such that product = prod1 * 2^256 + prod0.
            uint256 prod0; // Least significant 256 bits of the product
            uint256 prod1; // Most significant 256 bits of the product
            assembly {
                let mm := mulmod(x, y, not(0))
                prod0 := mul(x, y)
                prod1 := sub(sub(mm, prod0), lt(mm, prod0))
            }

            // Handle non-overflow cases, 256 by 256 division.
            if (prod1 == 0) {
                return prod0 / denominator;
            }

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            require(denominator > prod1);

            ///////////////////////////////////////////////
            // 512 by 256 division.
            ///////////////////////////////////////////////

            // Make division exact by subtracting the remainder from [prod1 prod0].
            uint256 remainder;
            assembly {
                // Compute remainder using mulmod.
                remainder := mulmod(x, y, denominator)

                // Subtract 256 bit number from 512 bit number.
                prod1 := sub(prod1, gt(remainder, prod0))
                prod0 := sub(prod0, remainder)
            }

            // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
            // See https://cs.stackexchange.com/q/138556/92363.

            // Does not overflow because the denominator cannot be zero at this stage in the function.
            uint256 twos = denominator & (~denominator + 1);
            assembly {
                // Divide denominator by twos.
                denominator := div(denominator, twos)

                // Divide [prod1 prod0] by twos.
                prod0 := div(prod0, twos)

                // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
                twos := add(div(sub(0, twos), twos), 1)
            }

            // Shift in bits from prod1 into prod0.
            prod0 |= prod1 * twos;

            // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
            // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
            // four bits. That is, denominator * inv = 1 mod 2^4.
            uint256 inverse = (3 * denominator) ^ 2;

            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
            // in modular arithmetic, doubling the correct bits in each step.
            inverse *= 2 - denominator * inverse; // inverse mod 2^8
            inverse *= 2 - denominator * inverse; // inverse mod 2^16
            inverse *= 2 - denominator * inverse; // inverse mod 2^32
            inverse *= 2 - denominator * inverse; // inverse mod 2^64
            inverse *= 2 - denominator * inverse; // inverse mod 2^128
            inverse *= 2 - denominator * inverse; // inverse mod 2^256

            // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
            // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
            // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
            // is no longer required.
            result = prod0 * inverse;
            return result;
        }
    }

    /**
     * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
     */
    function mulDiv(
        uint256 x,
        uint256 y,
        uint256 denominator,
        Rounding rounding
    ) internal pure returns (uint256) {
        uint256 result = mulDiv(x, y, denominator);
        if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
            result += 1;
        }
        return result;
    }

    /**
     * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
     *
     * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
     */
    function sqrt(uint256 a) internal pure returns (uint256) {
        if (a == 0) {
            return 0;
        }

        // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
        //
        // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
        // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
        //
        // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
        // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
        // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
        //
        // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
        uint256 result = 1 << (log2(a) >> 1);

        // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
        // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
        // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
        // into the expected uint128 result.
        unchecked {
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            return min(result, a / result);
        }
    }

    /**
     * @notice Calculates sqrt(a), following the selected rounding direction.
     */
    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = sqrt(a);
            return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 2, rounded down, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 128;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 64;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 32;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 16;
            }
            if (value >> 8 > 0) {
                value >>= 8;
                result += 8;
            }
            if (value >> 4 > 0) {
                value >>= 4;
                result += 4;
            }
            if (value >> 2 > 0) {
                value >>= 2;
                result += 2;
            }
            if (value >> 1 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 2, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log2(value);
            return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 10, rounded down, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >= 10**64) {
                value /= 10**64;
                result += 64;
            }
            if (value >= 10**32) {
                value /= 10**32;
                result += 32;
            }
            if (value >= 10**16) {
                value /= 10**16;
                result += 16;
            }
            if (value >= 10**8) {
                value /= 10**8;
                result += 8;
            }
            if (value >= 10**4) {
                value /= 10**4;
                result += 4;
            }
            if (value >= 10**2) {
                value /= 10**2;
                result += 2;
            }
            if (value >= 10**1) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log10(value);
            return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 256, rounded down, of a positive value.
     * Returns 0 if given 0.
     *
     * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
     */
    function log256(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 16;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 8;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 4;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 2;
            }
            if (value >> 8 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log256(value);
            return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);
        }
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)

pragma solidity ^0.8.0;

/**
 * @dev Library for reading and writing primitive types to specific storage slots.
 *
 * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
 * This library helps with reading and writing to such slots without the need for inline assembly.
 *
 * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
 *
 * Example usage to set ERC1967 implementation slot:
 * ```
 * contract ERC1967 {
 *     bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
 *
 *     function _getImplementation() internal view returns (address) {
 *         return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
 *     }
 *
 *     function _setImplementation(address newImplementation) internal {
 *         require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
 *         StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
 *     }
 * }
 * ```
 *
 * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._
 */
library StorageSlotUpgradeable {
    struct AddressSlot {
        address value;
    }

    struct BooleanSlot {
        bool value;
    }

    struct Bytes32Slot {
        bytes32 value;
    }

    struct Uint256Slot {
        uint256 value;
    }

    /**
     * @dev Returns an `AddressSlot` with member `value` located at `slot`.
     */
    function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `BooleanSlot` with member `value` located at `slot`.
     */
    function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
     */
    function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `Uint256Slot` with member `value` located at `slot`.
     */
    function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol)

pragma solidity ^0.8.0;

import "./math/MathUpgradeable.sol";

/**
 * @dev String operations.
 */
library StringsUpgradeable {
    bytes16 private constant _SYMBOLS = "0123456789abcdef";
    uint8 private constant _ADDRESS_LENGTH = 20;

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        unchecked {
            uint256 length = MathUpgradeable.log10(value) + 1;
            string memory buffer = new string(length);
            uint256 ptr;
            /// @solidity memory-safe-assembly
            assembly {
                ptr := add(buffer, add(32, length))
            }
            while (true) {
                ptr--;
                /// @solidity memory-safe-assembly
                assembly {
                    mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
                }
                value /= 10;
                if (value == 0) break;
            }
            return buffer;
        }
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        unchecked {
            return toHexString(value, MathUpgradeable.log256(value) + 1);
        }
    }

    /**
     * @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] = _SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }

    /**
     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
     */
    function toHexString(address addr) internal pure returns (string memory) {
        return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @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 functionCallWithValue(target, data, 0, "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");
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, 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) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
     *
     * _Available since v4.8._
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        if (success) {
            if (returndata.length == 0) {
                // only check isContract if the call was successful and the return data is empty
                // otherwise we already know that it was a contract
                require(isContract(target), "Address: call to non-contract");
            }
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason or 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 {
            _revert(returndata, errorMessage);
        }
    }

    function _revert(bytes memory returndata, string memory errorMessage) private pure {
        // 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
            /// @solidity memory-safe-assembly
            assembly {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert(errorMessage);
        }
    }
}

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

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

import "@openzeppelin/contracts/utils/introspection/IERC165.sol";

/**
 * @title EIP-2981: NFT Royalty Standard
 *
 * @notice A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs)
 *      to enable universal support for royalty payments across all NFT marketplaces and ecosystem participants.
 *
 * @author Zach Burks, James Morgan, Blaine Malone, James Seibel
 */
interface EIP2981 is IERC165 {
	/**
	 * @dev ERC165 bytes to add to interface array - set in parent contract
	 *      implementing this standard:
	 *      bytes4(keccak256("royaltyInfo(uint256,uint256)")) == 0x2a55205a
	 *      bytes4 private constant _INTERFACE_ID_ERC2981 = 0x2a55205a;
	 *      _registerInterface(_INTERFACE_ID_ERC2981);
	 *
	 * @notice Called with the sale price to determine how much royalty
	 *      is owed and to whom.
	 * @param _tokenId token ID to calculate royalty info for;
	 *      the NFT asset queried for royalty information
	 * @param _salePrice the price (in any unit, .e.g wei, ERC20 token, et.c.) of the token to be sold;
	 *      the sale price of the NFT asset specified by _tokenId
	 * @return receiver the royalty receiver, an address of who should be sent the royalty payment
	 * @return royaltyAmount royalty amount in the same unit as _salePrice;
	 *      the royalty payment amount for _salePrice
	 */
	function royaltyInfo(
		uint256 _tokenId,
		uint256 _salePrice
	) external view returns (
		address receiver,
		uint256 royaltyAmount
	);
}

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

/**
 * @title EIP-20: ERC-20 Token Standard
 *
 * @notice The ERC-20 (Ethereum Request for Comments 20), proposed by Fabian Vogelsteller in November 2015,
 *      is a Token Standard that implements an API for tokens within Smart Contracts.
 *
 * @notice It provides functionalities like to transfer tokens from one account to another,
 *      to get the current token balance of an account and also the total supply of the token available on the network.
 *      Besides these it also has some other functionalities like to approve that an amount of
 *      token from an account can be spent by a third party account.
 *
 * @notice If a Smart Contract implements the following methods and events it can be called an ERC-20 Token
 *      Contract and, once deployed, it will be responsible to keep track of the created tokens on Ethereum.
 *
 * @notice See https://ethereum.org/en/developers/docs/standards/tokens/erc-20/
 * @notice See https://eips.ethereum.org/EIPS/eip-20
 */
interface ERC20 {
	/**
	 * @dev Fired in transfer(), transferFrom() to indicate that token transfer happened
	 *
	 * @param from an address tokens were consumed from
	 * @param to an address tokens were sent to
	 * @param value number of tokens transferred
	 */
	event Transfer(address indexed from, address indexed to, uint256 value);

	/**
	 * @dev Fired in approve() to indicate an approval event happened
	 *
	 * @param owner an address which granted a permission to transfer
	 *      tokens on its behalf
	 * @param spender an address which received a permission to transfer
	 *      tokens on behalf of the owner `_owner`
	 * @param value amount of tokens granted to transfer on behalf
	 */
	event Approval(address indexed owner, address indexed spender, uint256 value);

	/**
	 * @return name of the token (ex.: USD Coin)
	 */
	// OPTIONAL - This method can be used to improve usability,
	// but interfaces and other contracts MUST NOT expect these values to be present.
	// function name() external view returns (string memory);

	/**
	 * @return symbol of the token (ex.: USDC)
	 */
	// OPTIONAL - This method can be used to improve usability,
	// but interfaces and other contracts MUST NOT expect these values to be present.
	// function symbol() external view returns (string memory);

	/**
	 * @dev Returns the number of decimals used to get its user representation.
	 *      For example, if `decimals` equals `2`, a balance of `505` tokens should
	 *      be displayed to a user as `5,05` (`505 / 10 ** 2`).
	 *
	 * @dev Tokens usually opt for a value of 18, imitating the relationship between
	 *      Ether and Wei. This is the value {ERC20} uses, unless this function is
	 *      overridden;
	 *
	 * @dev NOTE: This information is only used for _display_ purposes: it in
	 *      no way affects any of the arithmetic of the contract, including
	 *      {IERC20-balanceOf} and {IERC20-transfer}.
	 *
	 * @return token decimals
	 */
	// OPTIONAL - This method can be used to improve usability,
	// but interfaces and other contracts MUST NOT expect these values to be present.
	// function decimals() external view returns (uint8);

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

	/**
	 * @notice Gets the balance of a particular address
	 *
	 * @param _owner the address to query the the balance for
	 * @return balance an amount of tokens owned by the address specified
	 */
	function balanceOf(address _owner) external view returns (uint256 balance);

	/**
	 * @notice Transfers some tokens to an external address or a smart contract
	 *
	 * @dev Called by token owner (an address which has a
	 *      positive token balance tracked by this smart contract)
	 * @dev Throws on any error like
	 *      * insufficient token balance or
	 *      * incorrect `_to` address:
	 *          * zero address or
	 *          * self address or
	 *          * smart contract which doesn't support ERC20
	 *
	 * @param _to an address to transfer tokens to,
	 *      must be either an external address or a smart contract,
	 *      compliant with the ERC20 standard
	 * @param _value amount of tokens to be transferred,, zero
	 *      value is allowed
	 * @return success true on success, throws otherwise
	 */
	function transfer(address _to, uint256 _value) external returns (bool success);

	/**
	 * @notice Transfers some tokens on behalf of address `_from' (token owner)
	 *      to some other address `_to`
	 *
	 * @dev Called by token owner on his own or approved address,
	 *      an address approved earlier by token owner to
	 *      transfer some amount of tokens on its behalf
	 * @dev Throws on any error like
	 *      * insufficient token balance or
	 *      * incorrect `_to` address:
	 *          * zero address or
	 *          * same as `_from` address (self transfer)
	 *          * smart contract which doesn't support ERC20
	 *
	 * @param _from token owner which approved caller (transaction sender)
	 *      to transfer `_value` of tokens on its behalf
	 * @param _to an address to transfer tokens to,
	 *      must be either an external address or a smart contract,
	 *      compliant with the ERC20 standard
	 * @param _value amount of tokens to be transferred,, zero
	 *      value is allowed
	 * @return success true on success, throws otherwise
	 */
	function transferFrom(address _from, address _to, uint256 _value) external returns (bool success);

	/**
	 * @notice Approves address called `_spender` to transfer some amount
	 *      of tokens on behalf of the owner (transaction sender)
	 *
	 * @dev Transaction sender must not necessarily own any tokens to grant the permission
	 *
	 * @param _spender an address approved by the caller (token owner)
	 *      to spend some tokens on its behalf
	 * @param _value an amount of tokens spender `_spender` is allowed to
	 *      transfer on behalf of the token owner
	 * @return success true on success, throws otherwise
	 */
	function approve(address _spender, uint256 _value) external returns (bool success);

	/**
	 * @notice Returns the amount which _spender is still allowed to withdraw from _owner.
	 *
	 * @dev A function to check an amount of tokens owner approved
	 *      to transfer on its behalf by some other address called "spender"
	 *
	 * @param _owner an address which approves transferring some tokens on its behalf
	 * @param _spender an address approved to transfer some tokens on behalf
	 * @return remaining an amount of tokens approved address `_spender` can transfer on behalf
	 *      of token owner `_owner`
	 */
	function allowance(address _owner, address _spender) external view returns (uint256 remaining);
}

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

/**
 * @title Mintable ERC721 Extension
 *
 * @notice Defines mint capabilities for ERC721 tokens.
 *      This interface should be treated as a definition of what mintable means for ERC721
 *
 * @author Basil Gorin
 */
interface MintableERC721 {
	/**
	 * @notice Checks if specified token exists
	 *
	 * @dev Returns whether the specified token ID has an ownership
	 *      information associated with it
	 *
	 * @param _tokenId ID of the token to query existence for
	 * @return whether the token exists (true - exists, false - doesn't exist)
	 */
	function exists(uint256 _tokenId) external view returns(bool);

	/**
	 * @dev Creates new token with token ID specified
	 *      and assigns an ownership `_to` for this token
	 *
	 * @dev Unsafe: doesn't execute `onERC721Received` on the receiver.
	 *      Prefer the use of `saveMint` instead of `mint`.
	 *
	 * @dev Should have a restricted access handled by the implementation
	 *
	 * @param _to an address to mint token to
	 * @param _tokenId ID of the token to mint
	 */
	function mint(address _to, uint256 _tokenId) external;

	/**
	 * @dev Creates new token with token ID specified
	 *      and assigns an ownership `_to` for this token
	 *
	 * @dev Checks if `_to` is a smart contract (code size > 0). If so, it calls
	 *      `onERC721Received` on `_to` and throws if the return value is not
	 *      `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`.
	 *
	 * @dev Should have a restricted access handled by the implementation
	 *
	 * @param _to an address to mint token to
	 * @param _tokenId ID of the token to mint
	 */
	function safeMint(address _to, uint256 _tokenId) external;

	/**
	 * @dev Creates new token with token ID specified
	 *      and assigns an ownership `_to` for this token
	 *
	 * @dev Checks if `_to` is a smart contract (code size > 0). If so, it calls
	 *      `onERC721Received` on `_to` and throws if the return value is not
	 *      `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`.
	 *
	 * @dev Should have a restricted access handled by the implementation
	 *
	 * @param _to an address to mint token to
	 * @param _tokenId ID of the token to mint
	 * @param _data additional data with no specified format, sent in call to `_to`
	 */
	function safeMint(address _to, uint256 _tokenId, bytes memory _data) external;

}

/**
 * @title Batch Mintable ERC721 Extension
 *
 * @notice Defines batch minting capabilities for ERC721 tokens.
 *      This interface should be treated as a definition of what mintable means for ERC721
 *
 * @author Basil Gorin
 */
interface BatchMintable {
	/**
	 * @dev Creates new tokens starting with token ID specified
	 *      and assigns an ownership `_to` for these tokens
	 *
	 * @dev Token IDs to be minted: [_tokenId, _tokenId + n)
	 *
	 * @dev n must be greater or equal 2: `n > 1`
	 *
	 * @dev Unsafe: doesn't execute `onERC721Received` on the receiver.
	 *      Prefer the use of `saveMintBatch` instead of `mintBatch`.
	 *
	 * @dev Should have a restricted access handled by the implementation
	 *
	 * @param _to an address to mint tokens to
	 * @param _tokenId ID of the first token to mint
	 * @param n how many tokens to mint, sequentially increasing the _tokenId
	 */
	function mintBatch(address _to, uint256 _tokenId, uint256 n) external;

	/**
	 * @dev Creates new tokens starting with token ID specified
	 *      and assigns an ownership `_to` for these tokens
	 *
	 * @dev Token IDs to be minted: [_tokenId, _tokenId + n)
	 *
	 * @dev n must be greater or equal 2: `n > 1`
	 *
	 * @dev Checks if `_to` is a smart contract (code size > 0). If so, it calls
	 *      `onERC721Received` on `_to` and throws if the return value is not
	 *      `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`.
	 *
	 * @dev Should have a restricted access handled by the implementation
	 *
	 * @param _to an address to mint token to
	 * @param _tokenId ID of the token to mint
	 * @param n how many tokens to mint, sequentially increasing the _tokenId
	 */
	function safeMintBatch(address _to, uint256 _tokenId, uint256 n) external;

	/**
	 * @dev Creates new tokens starting with token ID specified
	 *      and assigns an ownership `_to` for these tokens
	 *
	 * @dev Token IDs to be minted: [_tokenId, _tokenId + n)
	 *
	 * @dev n must be greater or equal 2: `n > 1`
	 *
	 * @dev Checks if `_to` is a smart contract (code size > 0). If so, it calls
	 *      `onERC721Received` on `_to` and throws if the return value is not
	 *      `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`.
	 *
	 * @dev Should have a restricted access handled by the implementation
	 *
	 * @param _to an address to mint token to
	 * @param _tokenId ID of the token to mint
	 * @param n how many tokens to mint, sequentially increasing the _tokenId
	 * @param _data additional data with no specified format, sent in call to `_to`
	 */
	function safeMintBatch(address _to, uint256 _tokenId, uint256 n, bytes memory _data) external;
}

/**
 * @title Burnable ERC721 Extension
 *
 * @notice Defines burn capabilities for ERC721 tokens.
 *      This interface should be treated as a definition of what burnable means for ERC721
 *
 * @author Basil Gorin
 */
interface BurnableERC721 {
	/**
	 * @notice Destroys the token with token ID specified
	 *
	 * @dev Should be accessible publicly by token owners.
	 *      May have a restricted access handled by the implementation
	 *
	 * @param _tokenId ID of the token to burn
	 */
	function burn(uint256 _tokenId) external;
}

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

/**
 * @title Immutable X Mintable Specification
 *
 * @notice Interfaces supporting IMX integration:
 *      - ImmutableMintableERC20: @imtbl/imx-contracts/contracts/IMintable.sol
 *      - ImmutableMintableERC721: @imtbl/imx-contracts/contracts/IMintable.sol
 *
 * @dev See https://docs.x.immutable.com/docs/minting-assets-1
 * @dev See https://docs.x.immutable.com/docs/partner-nft-minting-setup
 *
 * @author Basil Gorin
 */

/**
 * @dev IMX Mintable interface, enables Layer 2 minting in IMX,
 *      see https://docs.x.immutable.com/docs/minting-assets-1
 *
 * @dev See @imtbl/imx-contracts/contracts/IMintable.sol
 */
interface ImmutableMintableERC20 {
	/**
	 * @dev Mints ERC20 tokens
	 *
	 * @param to address to mint tokens to
	 * @param amount amount of tokens to mint
	 * @param mintingBlob [optional] data structure supplied
	 */
	function mintFor(address to, uint256 amount, bytes calldata mintingBlob) external;
}

/**
 * @dev IMX Mintable interface, enables Layer 2 minting in IMX,
 *      see https://docs.x.immutable.com/docs/minting-assets-1
 *      see https://docs.x.immutable.com/docs/asset-minting
 *
 * @dev See @imtbl/imx-contracts/contracts/IMintable.sol
 */
interface ImmutableMintableERC721 {
	/**
	 * @dev Mints an NFT
	 *
	 * @param to address to mint NFT to
	 * @param quantity rudimentary (ERC20 amount of tokens to mint) equal to one,
	 *      implementation MUST revert if it not equal to one
	 * @param mintingBlob blob containing the ID of the NFT and its metadata as
	 *      `{tokenId}:{metadata}` string, where `tokenId` is encoded as decimal string,
	 *      and metadata can be anything, but most likely is also encoded as decimal string
	 */
	function mintFor(address to, uint256 quantity, bytes calldata mintingBlob) external;
}

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

import "../interfaces/ERC20Spec.sol";
import "@openzeppelin/contracts/utils/Address.sol";

/**
 * @title SafeERC20 by OpenZeppelin
 *
 * @dev Wrappers around ERC20 operations that throw on failure
 *      (when the token contract returns false).
 *      Tokens that return no value (and instead revert or throw on failure)
 *      are also supported, non-reverting calls are assumed to be successful.
 * @dev To use this library you can add a `using SafeERC20 for ERC20;` statement to your contract,
 *      which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 *
 * @author OpenZeppelin
 */
library SafeERC20 {
	// using Address.functionCall for addresses
	using Address for address;

	/**
	 * @dev ERC20.transfer wrapper
	 *
	 * @param token ERC20 instance
	 * @param to ERC20.transfer to
	 * @param value ERC20.transfer value
	 */
	function safeTransfer(ERC20 token, address to, uint256 value) internal {
		// delegate to `_callOptionalReturn`
		_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
	}

	/**
	 * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
	 * on the return value: the return value is optional (but if data is returned, it must not be false).
	 * @param token The token targeted by the call.
	 * @param data The call data (encoded using abi.encode or one of its variants).
	 */
	function _callOptionalReturn(ERC20 token, bytes memory data) private {
		// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
		// we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
		// the target address contains contract code and also asserts for success in the low-level call.

		// execute function call and get the return data
		bytes memory retData = address(token).functionCall(data, "ERC20 low-level call failed");
		// return data is optional
		if(retData.length > 0) {
			require(abi.decode(retData, (bool)), "ERC20 transfer failed");
		}
	}
}

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

import "../interfaces/EIP2981Spec.sol";
import "./UpgradeableERC721.sol";

/**
 * @title Royal ER721
 *
 * @dev Supports EIP-2981 royalties on NFT secondary sales
 *      Supports OpenSea contract metadata royalties
 *      Introduces fake "owner" to support OpenSea collections
 *
 * @author Basil Gorin
 */
abstract contract RoyalERC721 is EIP2981, UpgradeableERC721 {
	/**
	 * @dev OpenSea expects NFTs to be "Ownable", that is having an "owner",
	 *      we introduce a fake "owner" here with no authority
	 */
	address public owner;

	/**
	 * @notice Address to receive EIP-2981 royalties from secondary sales
	 *         see https://eips.ethereum.org/EIPS/eip-2981
	 */
	address public royaltyReceiver;

	/**
	 * @notice Percentage of token sale price to be used for EIP-2981 royalties from secondary sales
	 *         see https://eips.ethereum.org/EIPS/eip-2981
	 *
	 * @dev Has 2 decimal precision. E.g. a value of 500 would result in a 5% royalty fee
	 */
	uint16 public royaltyPercentage; // default OpenSea value is 750

	/**
	 * @notice Contract level metadata to define collection name, description, and royalty fees.
	 *         see https://docs.opensea.io/docs/contract-level-metadata
	 *
	 * @dev Should be set by URI manager, empty by default
	 */
	string public contractURI;

	/**
	 * @dev Empty reserved space in storage. The size of the __gap array is calculated so that
	 *      the amount of storage used by a contract always adds up to the 50.
	 *      See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
	 *
	 * @dev Note: `owner`, `royaltyReceiver`, `royaltyPercentage`, and `contractURI` occupy
	 *      only 3 storage slots (not 4) since `royaltyReceiver` and `royaltyPercentage` fit
	 *      into a single storage slot (160 + 16 bits)
	 */
	uint256[47] private __gap;

	/**
	 * @notice Royalty manager is responsible for managing the EIP2981 royalty info
	 *
	 * @dev Role ROLE_ROYALTY_MANAGER allows updating the royalty information
	 *      (executing `setRoyaltyInfo` function)
	 */
	uint32 public constant ROLE_ROYALTY_MANAGER = 0x0010_0000;

	/**
	 * @notice Owner manager is responsible for setting/updating an "owner" field
	 *
	 * @dev Role ROLE_OWNER_MANAGER allows updating the "owner" field
	 *      (executing `setOwner` function)
	 */
	uint32 public constant ROLE_OWNER_MANAGER = 0x0020_0000;

	/**
	 * @dev Fired in setContractURI()
	 *
	 * @param _by an address which executed update
	 * @param _value new contractURI value
	 */
	event ContractURIUpdated(address indexed _by, string _value);

	/**
	 * @dev Fired in setRoyaltyInfo()
	 *
	 * @param _by an address which executed update
	 * @param _receiver new royaltyReceiver value
	 * @param _percentage new royaltyPercentage value
	 */
	event RoyaltyInfoUpdated(
		address indexed _by,
		address indexed _receiver,
		uint16 _percentage
	);

	/**
	 * @dev Fired in setOwner()
	 *
	 * @param _by an address which set the new "owner"
	 * @param _oldVal previous "owner" address
	 * @param _newVal new "owner" address
	 */
	event OwnerUpdated(address indexed _by, address indexed _oldVal, address indexed _newVal);

	/**
	 * @dev Fired in setOwner() - OpenZeppelin Ownable compliant event
	 *
	 * @param previousOwner previous "owner" address
	 * @param newOwner new "owner" address
	 */
	event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

	/**
	 * @dev "Constructor replacement" for upgradeable, must be execute immediately after deployment
	 *      see https://docs.openzeppelin.com/upgrades-plugins/1.x/writing-upgradeable#initializers
	 *
	 * @param _name token name (ERC721Metadata)
	 * @param _symbol token symbol (ERC721Metadata)
	 * @param _owner smart contract owner having full privileges
	 */
	function _postConstruct(string memory _name, string memory _symbol, address _owner) internal virtual override initializer {
		// execute all parent initializers in cascade
		UpgradeableERC721._postConstruct(_name, _symbol, _owner);

		// initialize the "owner" as a deployer account
		owner = msg.sender;

		// contractURI is as an empty string by default (zero-length array)
		// contractURI = "";
	}

	/**
	 * @dev Restricted access function which updates the contract URI
	 *
	 * @dev Requires executor to have ROLE_URI_MANAGER permission
	 *
	 * @param _contractURI new contract URI to set
	 */
	function setContractURI(string memory _contractURI) public virtual {
		// verify the access permission
		require(isSenderInRole(ROLE_URI_MANAGER), "access denied");

		// update the contract URI
		contractURI = _contractURI;

		// emit an event
		emit ContractURIUpdated(msg.sender, _contractURI);
	}

	/**
	 * @notice EIP-2981 function to calculate royalties for sales in secondary marketplaces.
	 *         see https://eips.ethereum.org/EIPS/eip-2981
	 *
	 * @inheritdoc EIP2981
	 */
	function royaltyInfo(
		uint256,
		uint256 _salePrice
	) public view virtual override returns (
		address receiver,
		uint256 royaltyAmount
	) {
		// simply calculate the values and return the result
		return (royaltyReceiver, _salePrice * royaltyPercentage / 100_00);
	}

	/**
	 * @dev Restricted access function which updates the royalty info
	 *
	 * @dev Requires executor to have ROLE_ROYALTY_MANAGER permission
	 *
	 * @param _royaltyReceiver new royalty receiver to set
	 * @param _royaltyPercentage new royalty percentage to set
	 */
	function setRoyaltyInfo(address _royaltyReceiver, uint16 _royaltyPercentage) public virtual {
		// verify the access permission
		require(isSenderInRole(ROLE_ROYALTY_MANAGER), "access denied");

		// verify royalty percentage is zero if receiver is also zero
		require(_royaltyReceiver != address(0) || _royaltyPercentage == 0, "invalid receiver");
		// verify royalty percentage doesn't exceed 100%
		require(_royaltyPercentage <= 100_00, "royalty percentage exceeds 100%");

		// update the values
		royaltyReceiver = _royaltyReceiver;
		royaltyPercentage = _royaltyPercentage;

		// emit an event
		emit RoyaltyInfoUpdated(msg.sender, _royaltyReceiver, _royaltyPercentage);
	}

	/**
	 * @notice Checks if the address supplied is an "owner" of the smart contract
	 *      Note: an "owner" doesn't have any authority on the smart contract and is "nominal"
	 *
	 * @return true if the caller is the current owner.
	 */
	function isOwner(address _addr) public view virtual returns (bool) {
		// just evaluate and return the result
		return _addr == owner;
	}

	/**
	 * @dev Restricted access function to set smart contract "owner"
	 *      Note: an "owner" set doesn't have any authority, and cannot even update "owner"
	 *
	 * @dev Requires executor to have ROLE_OWNER_MANAGER permission
	 *
	 * @param _owner new "owner" of the smart contract
	 */
	function transferOwnership(address _owner) public virtual {
		// verify the access permission
		require(isSenderInRole(ROLE_OWNER_MANAGER), "access denied");

		// emit an event first - to log both old and new values
		emit OwnerUpdated(msg.sender, owner, _owner);

		// emit zeppelin ownable-compliant ownership transfer event
		emit OwnershipTransferred(owner, _owner);

		// update "owner"
		owner = _owner;
	}

	/**
	 * @inheritdoc IERC165
	 */
	function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, UpgradeableERC721) returns (bool) {
		// construct the interface support from EIP-2981 and super interfaces
		return interfaceId == type(EIP2981).interfaceId || super.supportsInterface(interfaceId);
	}
}

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

import "../interfaces/ERC20Spec.sol";
import "../interfaces/ERC721SpecExt.sol";
import "../lib/SafeERC20.sol";
import "../utils/UpgradeableAccessControl.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721EnumerableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721URIStorageUpgradeable.sol";

/**
 * @title Upgradeable ERC721 Implementation
 *
 * @notice Zeppelin based ERC721 implementation, supporting token enumeration
 *      (ERC721EnumerableUpgradeable) and flexible token URI management (ERC721URIStorageUpgradeable)
 *
 * // TODO: consider allowing to override each individual token URI
 *
 * @dev Based on Zeppelin ERC721EnumerableUpgradeable and ERC721URIStorageUpgradeable with some modifications
 *      to tokenURI function
 *
 * @author Basil Gorin
 */
abstract contract UpgradeableERC721 is MintableERC721, BurnableERC721, ERC721EnumerableUpgradeable, ERC721URIStorageUpgradeable, UpgradeableAccessControl {
	// using ERC20.transfer wrapper from OpenZeppelin adopted SafeERC20
	using SafeERC20 for ERC20;

	/**
	 * @dev Base URI is used to construct ERC721Metadata.tokenURI as
	 *      `base URI + token ID` if token URI is not set (not present in `_tokenURIs` mapping)
	 *
	 * @dev For example, if base URI is https://api.com/token/, then token #1
	 *      will have an URI https://api.com/token/1
	 *
	 * @dev If token URI is set with `setTokenURI()` it will be returned as is via `tokenURI()`
	 */
	string public baseURI;

	/**
	 * @dev Empty reserved space in storage. The size of the __gap array is calculated so that
	 *      the amount of storage used by a contract always adds up to the 50.
	 *      See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
	 */
	uint256[49] private __gap;

	/**
	 * @notice Enables ERC721 transfers of the tokens
	 *      (transfer by the token owner himself)
	 * @dev Feature FEATURE_TRANSFERS must be enabled in order for
	 *      `transferFrom()` function to succeed when executed by token owner
	 */
	uint32 public constant FEATURE_TRANSFERS = 0x0000_0001;

	/**
	 * @notice Enables ERC721 transfers on behalf
	 *      (transfer by someone else on behalf of token owner)
	 * @dev Feature FEATURE_TRANSFERS_ON_BEHALF must be enabled in order for
	 *      `transferFrom()` function to succeed whe executed by approved operator
	 * @dev Token owner must call `approve()` or `setApprovalForAll()`
	 *      first to authorize the transfer on behalf
	 */
	uint32 public constant FEATURE_TRANSFERS_ON_BEHALF = 0x0000_0002;

	/**
	 * @notice Enables token owners to burn their own tokens
	 *
	 * @dev Feature FEATURE_OWN_BURNS must be enabled in order for
	 *      `burn()` function to succeed when called by token owner
	 */
	uint32 public constant FEATURE_OWN_BURNS = 0x0000_0008;

	/**
	 * @notice Enables approved operators to burn tokens on behalf of their owners
	 *
	 * @dev Feature FEATURE_BURNS_ON_BEHALF must be enabled in order for
	 *      `burn()` function to succeed when called by approved operator
	 */
	uint32 public constant FEATURE_BURNS_ON_BEHALF = 0x0000_0010;

	/**
	 * @notice Token creator is responsible for creating (minting)
	 *      tokens to an arbitrary address
	 * @dev Role ROLE_TOKEN_CREATOR allows minting tokens
	 *      (calling `mint` function)
	 */
	uint32 public constant ROLE_TOKEN_CREATOR = 0x0001_0000;

	/**
	 * @notice Token destroyer is responsible for destroying (burning)
	 *      tokens owned by an arbitrary address
	 * @dev Role ROLE_TOKEN_DESTROYER allows burning tokens
	 *      (calling `burn` function)
	 */
	uint32 public constant ROLE_TOKEN_DESTROYER = 0x0002_0000;

	/**
	 * @notice URI manager is responsible for managing base URI
	 *      part of the token URI ERC721Metadata interface
	 *
	 * @dev Role ROLE_URI_MANAGER allows updating the base URI
	 *      (executing `setBaseURI` function)
	 */
	uint32 public constant ROLE_URI_MANAGER = 0x0004_0000;

	/**
	 * @notice People do mistakes and may send ERC20 tokens by mistake; since
	 *      NFT smart contract is not designed to accept and hold any ERC20 tokens,
	 *      it allows the rescue manager to "rescue" such lost tokens
	 *
	 * @notice Rescue manager is responsible for "rescuing" ERC20 tokens accidentally
	 *      sent to the smart contract
	 *
	 * @dev Role ROLE_RESCUE_MANAGER allows withdrawing any ERC20 tokens stored
	 *      on the smart contract balance
	 */
	uint32 public constant ROLE_RESCUE_MANAGER = 0x0008_0000;

	/**
	 * @dev Fired in _mint() and all the dependent functions like mint(), safeMint()
	 *
	 * @param _by an address which executed update
	 * @param _to an address token was minted to
	 * @param _tokenId token ID minted
	 */
	event Minted(address indexed _by, address indexed _to, uint256 indexed _tokenId);

	/**
	 * @dev Fired in _burn() and all the dependent functions like burn()
	 *
	 * @param _by an address which executed update
	 * @param _from an address token was burnt from
	 * @param _tokenId token ID burnt
	 */
	event Burnt(address indexed _by, address indexed _from, uint256 indexed _tokenId);

	/**
	 * @dev Fired in setBaseURI()
	 *
	 * @param _by an address which executed update
	 * @param oldVal old _baseURI value
	 * @param newVal new _baseURI value
	 */
	event BaseURIUpdated(address indexed _by, string oldVal, string newVal);

	/**
	 * @dev Fired in setTokenURI()
	 *
	 * @param _by an address which executed update
	 * @param tokenId token ID which URI was updated
	 * @param oldVal old _baseURI value
	 * @param newVal new _baseURI value
	 */
	event TokenURIUpdated(address indexed _by, uint256 tokenId, string oldVal, string newVal);

	/**
	 * @dev "Constructor replacement" for upgradeable, must be execute immediately after deployment
	 *      see https://docs.openzeppelin.com/upgrades-plugins/1.x/writing-upgradeable#initializers
	 *
	 * @param _name token name (ERC721Metadata)
	 * @param _symbol token symbol (ERC721Metadata)
	 * @param _owner smart contract owner having full privileges
	 */
	function _postConstruct(string memory _name, string memory _symbol, address _owner) internal virtual initializer {
		// execute all parent initializers in cascade
		__ERC721_init(_name, _symbol);
		__ERC721Enumerable_init_unchained();
		__ERC721URIStorage_init_unchained();
		UpgradeableAccessControl._postConstruct(_owner);
	}

	/**
	 * @inheritdoc IERC165Upgradeable
	 */
	function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721Upgradeable, ERC721EnumerableUpgradeable) returns (bool) {
		// calculate based on own and inherited interfaces
		return ERC721EnumerableUpgradeable.supportsInterface(interfaceId)
			|| interfaceId == type(MintableERC721).interfaceId
			|| interfaceId == type(BurnableERC721).interfaceId;
	}

	/**
	 * @dev Restricted access function which updates base URI used to construct
	 *      ERC721Metadata.tokenURI
	 *
	 * @dev Requires executor to have ROLE_URI_MANAGER permission
	 *
	 * @param __baseURI new base URI to set
	 */
	function setBaseURI(string memory __baseURI) public virtual {
		// verify the access permission
		require(isSenderInRole(ROLE_URI_MANAGER), "access denied");

		// emit an event first - to log both old and new values
		emit BaseURIUpdated(msg.sender, baseURI, __baseURI);

		// and update base URI
		baseURI = __baseURI;
	}

	/**
	 * @inheritdoc ERC721Upgradeable
	 */
	function _baseURI() internal view virtual override returns (string memory) {
		// just return stored public value to support Zeppelin impl
		return baseURI;
	}

	/**
	 * @dev Sets the token URI for the token defined by its ID
	 *
	 * @param _tokenId an ID of the token to set URI for
	 * @param _tokenURI token URI to set
	 */
	function setTokenURI(uint256 _tokenId, string memory _tokenURI) public virtual {
		// verify the access permission
		require(isSenderInRole(ROLE_URI_MANAGER), "access denied");

		// we do not verify token existence: we want to be able to
		// preallocate token URIs before tokens are actually minted

		// emit an event first - to log both old and new values
		emit TokenURIUpdated(msg.sender, _tokenId, "zeppelin", _tokenURI);

		// and update token URI - delegate to ERC721URIStorage
		_setTokenURI(_tokenId, _tokenURI);
	}

	/**
	 * @inheritdoc ERC721URIStorageUpgradeable
	 */
	function _setTokenURI(uint256 _tokenId, string memory _tokenURI) internal virtual override {
		// delegate to ERC721URIStorage impl
		return super._setTokenURI(_tokenId, _tokenURI);
	}

	/**
	 * @inheritdoc ERC721Upgradeable
	 */
	function tokenURI(uint256 _tokenId) public view virtual override(ERC721Upgradeable, ERC721URIStorageUpgradeable) returns (string memory) {
		// delegate to ERC721URIStorage impl
		return ERC721URIStorageUpgradeable.tokenURI(_tokenId);
	}

	/**
	 * @notice Checks if specified token exists
	 *
	 * @dev Returns whether the specified token ID has an ownership
	 *      information associated with it
	 * @param _tokenId ID of the token to query existence for
	 * @return whether the token exists (true - exists, false - doesn't exist)
	 */
	function exists(uint256 _tokenId) public view virtual override returns (bool) {
		// delegate to super implementation
		return _exists(_tokenId);
	}

	/**
	 * @dev Creates new token with token ID specified
	 *      and assigns an ownership `_to` for this token
	 *
	 * @dev Unsafe: doesn't execute `onERC721Received` on the receiver.
	 *      Prefer the use of `saveMint` instead of `mint`.
	 *
	 * @dev Requires executor to have `ROLE_TOKEN_CREATOR` permission
	 *
	 * @param _to an address to mint token to
	 * @param _tokenId ID of the token to mint
	 */
	function mint(address _to, uint256 _tokenId) public virtual override {
		// mint token - delegate to `_mint`
		_mint(_to, _tokenId);
	}

	/**
	 * @dev Creates new token with token ID specified
	 *      and assigns an ownership `_to` for this token
	 *
	 * @dev Checks if `_to` is a smart contract (code size > 0). If so, it calls
	 *      `onERC721Received` on `_to` and throws if the return value is not
	 *      `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`.
	 *
	 * @dev Requires executor to have `ROLE_TOKEN_CREATOR` permission
	 *
	 * @param _to an address to mint token to
	 * @param _tokenId ID of the token to mint
	 * @param _data additional data with no specified format, sent in call to `_to`
	 */
	function safeMint(address _to, uint256 _tokenId, bytes memory _data) public virtual override {
		// mint token safely - delegate to `_safeMint`
		_safeMint(_to, _tokenId, _data);
	}

	/**
	 * @dev Creates new token with token ID specified
	 *      and assigns an ownership `_to` for this token
	 *
	 * @dev Checks if `_to` is a smart contract (code size > 0). If so, it calls
	 *      `onERC721Received` on `_to` and throws if the return value is not
	 *      `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`.
	 *
	 * @dev Requires executor to have `ROLE_TOKEN_CREATOR` permission
	 *
	 * @param _to an address to mint token to
	 * @param _tokenId ID of the token to mint
	 */
	function safeMint(address _to, uint256 _tokenId) public virtual override {
		// mint token safely - delegate to `_safeMint`
		_safeMint(_to, _tokenId);
	}

	/**
	 * @dev Destroys the token with token ID specified
	 *
	 * @dev Requires executor to have `ROLE_TOKEN_DESTROYER` permission
	 *      or FEATURE_OWN_BURNS/FEATURE_BURNS_ON_BEHALF features to be enabled
	 *
	 * @dev Can be disabled by the contract creator forever by disabling
	 *      FEATURE_OWN_BURNS/FEATURE_BURNS_ON_BEHALF features and then revoking
	 *      its own roles to burn tokens and to enable burning features
	 *
	 * @param _tokenId ID of the token to burn
	 */
	function burn(uint256 _tokenId) public virtual override {
		// burn token - delegate to `_burn`
		_burn(_tokenId);
	}

	/**
	 * @inheritdoc ERC721Upgradeable
	 */
	function _mint(address _to, uint256 _tokenId) internal virtual override {
		// check if caller has sufficient permissions to mint tokens
		require(isSenderInRole(ROLE_TOKEN_CREATOR), "access denied");

		// delegate to super implementation
		super._mint(_to, _tokenId);

		// emit an additional event to better track who performed the operation
		emit Minted(msg.sender, _to, _tokenId);
	}

	/**
	 * @inheritdoc ERC721Upgradeable
	 */
	function _burn(uint256 _tokenId) internal virtual override(ERC721Upgradeable, ERC721URIStorageUpgradeable) {
		// read token owner data
		// verifies token exists under the hood
		address _from = ownerOf(_tokenId);

		// check if caller has sufficient permissions to burn tokens
		// and if not - check for possibility to burn own tokens or to burn on behalf
		if(!isSenderInRole(ROLE_TOKEN_DESTROYER)) {
			// if `_from` is equal to sender, require own burns feature to be enabled
			// otherwise require burns on behalf feature to be enabled
			require(_from == msg.sender && isFeatureEnabled(FEATURE_OWN_BURNS)
			     || _from != msg.sender && isFeatureEnabled(FEATURE_BURNS_ON_BEHALF),
			        _from == msg.sender? "burns are disabled": "burns on behalf are disabled");

			// verify sender is either token owner, or approved by the token owner to burn tokens
			require(msg.sender == _from
			     || msg.sender == getApproved(_tokenId)
			     || isApprovedForAll(_from, msg.sender), "access denied");
		}

		// delegate to the super implementation with URI burning
		ERC721URIStorageUpgradeable._burn(_tokenId);

		// emit an additional event to better track who performed the operation
		emit Burnt(msg.sender, _from, _tokenId);
	}

	/**
	 * @inheritdoc ERC721Upgradeable
	 */
	function _beforeTokenTransfer(
		address _from,
		address _to,
		uint256 _tokenId,
		uint256 _batchSize
	) internal virtual override(ERC721Upgradeable, ERC721EnumerableUpgradeable) {
		// for transfers only - verify if transfers are enabled
		require(_from == address(0) || _to == address(0) // won't affect minting/burning
		     || _from == msg.sender && isFeatureEnabled(FEATURE_TRANSFERS)
		     || _from != msg.sender && isFeatureEnabled(FEATURE_TRANSFERS_ON_BEHALF),
		        _from == msg.sender? "transfers are disabled": "transfers on behalf are disabled");

		// delegate to ERC721Enumerable impl
		ERC721EnumerableUpgradeable._beforeTokenTransfer(_from, _to, _tokenId, _batchSize);
	}

	/**
	 * @dev Restricted access function to rescue accidentally sent ERC20 tokens,
	 *      the tokens are rescued via `transfer` function call on the
	 *      contract address specified and with the parameters specified:
	 *      `_contract.transfer(_to, _value)`
	 *
	 * @dev Requires executor to have `ROLE_RESCUE_MANAGER` permission
	 *
	 * @param _contract smart contract address to execute `transfer` function on
	 * @param _to to address in `transfer(_to, _value)`
	 * @param _value value to transfer in `transfer(_to, _value)`
	 */
	function rescueErc20(address _contract, address _to, uint256 _value) public {
		// verify the access permission
		require(isSenderInRole(ROLE_RESCUE_MANAGER), "access denied");

		// perform the transfer as requested, without any checks
		ERC20(_contract).safeTransfer(_to, _value);
	}
}

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

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

/**
 * @title Upgradeable Access Control List // ERC1967Proxy
 *
 * @notice Access control smart contract provides an API to check
 *      if a specific operation is permitted globally and/or
 *      if a particular user has a permission to execute it.
 *
 * @notice It deals with two main entities: features and roles.
 *
 * @notice Features are designed to be used to enable/disable public functions
 *      of the smart contract (used by a wide audience).
 * @notice User roles are designed to control the access to restricted functions
 *      of the smart contract (used by a limited set of maintainers).
 *
 * @notice Terms "role", "permissions" and "set of permissions" have equal meaning
 *      in the documentation text and may be used interchangeably.
 * @notice Terms "permission", "single permission" implies only one permission bit set.
 *
 * @notice Access manager is a special role which allows to grant/revoke other roles.
 *      Access managers can only grant/revoke permissions which they have themselves.
 *      As an example, access manager with no other roles set can only grant/revoke its own
 *      access manager permission and nothing else.
 *
 * @notice Access manager permission should be treated carefully, as a super admin permission:
 *      Access manager with even no other permission can interfere with another account by
 *      granting own access manager permission to it and effectively creating more powerful
 *      permission set than its own.
 *
 * @dev Both current and OpenZeppelin AccessControl implementations feature a similar API
 *      to check/know "who is allowed to do this thing".
 * @dev Zeppelin implementation is more flexible:
 *      - it allows setting unlimited number of roles, while current is limited to 256 different roles
 *      - it allows setting an admin for each role, while current allows having only one global admin
 * @dev Current implementation is more lightweight:
 *      - it uses only 1 bit per role, while Zeppelin uses 256 bits
 *      - it allows setting up to 256 roles at once, in a single transaction, while Zeppelin allows
 *        setting only one role in a single transaction
 *
 * @dev This smart contract is designed to be inherited by other
 *      smart contracts which require access control management capabilities.
 *
 * @dev Access manager permission has a bit 255 set.
 *      This bit must not be used by inheriting contracts for any other permissions/features.
 *
 * @dev This is an upgradeable version of the ACL, based on Zeppelin implementation for ERC1967,
 *      see https://docs.openzeppelin.com/contracts/4.x/upgradeable
 *      see https://docs.openzeppelin.com/contracts/4.x/api/proxy#UUPSUpgradeable
 *      see https://forum.openzeppelin.com/t/uups-proxies-tutorial-solidity-javascript/7786
 *
 * @author Basil Gorin
 */
// TODO: add version history: 2018-2021
abstract contract UpgradeableAccessControl is UUPSUpgradeable {
	/**
	 * @notice Privileged addresses with defined roles/permissions
	 * @notice In the context of ERC20/ERC721 tokens these can be permissions to
	 *      allow minting or burning tokens, transferring on behalf and so on
	 *
	 * @dev Maps user address to the permissions bitmask (role), where each bit
	 *      represents a permission
	 * @dev Bitmask 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
	 *      represents all possible permissions
	 * @dev 'This' address mapping represents global features of the smart contract
	 */
	mapping(address => uint256) public userRoles;

	/**
	 * @dev Empty reserved space in storage. The size of the __gap array is calculated so that
	 *      the amount of storage used by a contract always adds up to the 50.
	 *      See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
	 */
	uint256[49] private __gap;

	/**
	 * @notice Access manager is responsible for assigning the roles to users,
	 *      enabling/disabling global features of the smart contract
	 * @notice Access manager can add, remove and update user roles,
	 *      remove and update global features
	 *
	 * @dev Role ROLE_ACCESS_MANAGER allows modifying user roles and global features
	 * @dev Role ROLE_ACCESS_MANAGER has single bit at position 255 enabled
	 */
	uint256 public constant ROLE_ACCESS_MANAGER = 0x8000000000000000000000000000000000000000000000000000000000000000;

	/**
	 * @notice Upgrade manager is responsible for smart contract upgrades,
	 *      see https://docs.openzeppelin.com/contracts/4.x/api/proxy#UUPSUpgradeable
	 *      see https://docs.openzeppelin.com/contracts/4.x/upgradeable
	 *
	 * @dev Role ROLE_UPGRADE_MANAGER allows passing the _authorizeUpgrade() check
	 * @dev Role ROLE_UPGRADE_MANAGER has single bit at position 254 enabled
	 */
	uint256 public constant ROLE_UPGRADE_MANAGER = 0x4000000000000000000000000000000000000000000000000000000000000000;

	/**
	 * @dev Bitmask representing all the possible permissions (super admin role)
	 * @dev Has all the bits are enabled (2^256 - 1 value)
	 */
	uint256 private constant FULL_PRIVILEGES_MASK = type(uint256).max; // before 0.8.0: uint256(-1) overflows to 0xFFFF...

	/**
	 * @dev Fired in updateRole() and updateFeatures()
	 *
	 * @param _by operator which called the function
	 * @param _to address which was granted/revoked permissions
	 * @param _requested permissions requested
	 * @param _actual permissions effectively set
	 */
	event RoleUpdated(address indexed _by, address indexed _to, uint256 _requested, uint256 _actual);

	/**
	 * @dev UUPS initializer, sets the contract owner to have full privileges
	 *
	 * @dev Can be executed only in constructor during deployment,
	 *      reverts when executed in already deployed contract
	 *
	 * @dev IMPORTANT:
	 *      this function MUST be executed during proxy deployment (in proxy constructor),
	 *      otherwise it renders useless and cannot be executed at all,
	 *      resulting in no admin control over the proxy and no possibility to do future upgrades
	 *
	 * @param _owner smart contract owner having full privileges
	 */
	function _postConstruct(address _owner) internal virtual initializer {
		// ensure this function is execute only in constructor
		require(!AddressUpgradeable.isContract(address(this)), "invalid context");

		// grant owner full privileges
		userRoles[_owner] = FULL_PRIVILEGES_MASK;

		// fire an event
		emit RoleUpdated(msg.sender, _owner, FULL_PRIVILEGES_MASK, FULL_PRIVILEGES_MASK);
	}

	/**
	 * @notice Returns an address of the implementation smart contract,
	 *      see ERC1967Upgrade._getImplementation()
	 *
	 * @return the current implementation address
	 */
	function getImplementation() public view virtual returns (address) {
		// delegate to `ERC1967Upgrade._getImplementation()`
		return _getImplementation();
	}

	/**
	 * @notice Retrieves globally set of features enabled
	 *
	 * @dev Effectively reads userRoles role for the contract itself
	 *
	 * @return 256-bit bitmask of the features enabled
	 */
	function features() public view returns (uint256) {
		// features are stored in 'this' address  mapping of `userRoles` structure
		return userRoles[address(this)];
	}

	/**
	 * @notice Updates set of the globally enabled features (`features`),
	 *      taking into account sender's permissions
	 *
	 * @dev Requires transaction sender to have `ROLE_ACCESS_MANAGER` permission
	 * @dev Function is left for backward compatibility with older versions
	 *
	 * @param _mask bitmask representing a set of features to enable/disable
	 */
	function updateFeatures(uint256 _mask) public {
		// delegate call to `updateRole`
		updateRole(address(this), _mask);
	}

	/**
	 * @notice Updates set of permissions (role) for a given user,
	 *      taking into account sender's permissions.
	 *
	 * @dev Setting role to zero is equivalent to removing an all permissions
	 * @dev Setting role to `FULL_PRIVILEGES_MASK` is equivalent to
	 *      copying senders' permissions (role) to the user
	 * @dev Requires transaction sender to have `ROLE_ACCESS_MANAGER` permission
	 *
	 * @param operator address of a user to alter permissions for or zero
	 *      to alter global features of the smart contract
	 * @param role bitmask representing a set of permissions to
	 *      enable/disable for a user specified
	 */
	function updateRole(address operator, uint256 role) public {
		// caller must have a permission to update user roles
		require(isSenderInRole(ROLE_ACCESS_MANAGER), "access denied");

		// evaluate the role and reassign it
		userRoles[operator] = evaluateBy(msg.sender, userRoles[operator], role);

		// fire an event
		emit RoleUpdated(msg.sender, operator, role, userRoles[operator]);
	}

	/**
	 * @notice Determines the permission bitmask an operator can set on the
	 *      target permission set
	 * @notice Used to calculate the permission bitmask to be set when requested
	 *     in `updateRole` and `updateFeatures` functions
	 *
	 * @dev Calculated based on:
	 *      1) operator's own permission set read from userRoles[operator]
	 *      2) target permission set - what is already set on the target
	 *      3) desired permission set - what do we want set target to
	 *
	 * @dev Corner cases:
	 *      1) Operator is super admin and its permission set is `FULL_PRIVILEGES_MASK`:
	 *        `desired` bitset is returned regardless of the `target` permission set value
	 *        (what operator sets is what they get)
	 *      2) Operator with no permissions (zero bitset):
	 *        `target` bitset is returned regardless of the `desired` value
	 *        (operator has no authority and cannot modify anything)
	 *
	 * @dev Example:
	 *      Consider an operator with the permissions bitmask     00001111
	 *      is about to modify the target permission set          01010101
	 *      Operator wants to set that permission set to          00110011
	 *      Based on their role, an operator has the permissions
	 *      to update only lowest 4 bits on the target, meaning that
	 *      high 4 bits of the target set in this example is left
	 *      unchanged and low 4 bits get changed as desired:      01010011
	 *
	 * @param operator address of the contract operator which is about to set the permissions
	 * @param target input set of permissions to operator is going to modify
	 * @param desired desired set of permissions operator would like to set
	 * @return resulting set of permissions given operator will set
	 */
	function evaluateBy(address operator, uint256 target, uint256 desired) public view returns (uint256) {
		// read operator's permissions
		uint256 p = userRoles[operator];

		// taking into account operator's permissions,
		// 1) enable the permissions desired on the `target`
		target |= p & desired;
		// 2) disable the permissions desired on the `target`
		target &= FULL_PRIVILEGES_MASK ^ (p & (FULL_PRIVILEGES_MASK ^ desired));

		// return calculated result
		return target;
	}

	/**
	 * @notice Checks if requested set of features is enabled globally on the contract
	 *
	 * @param required set of features to check against
	 * @return true if all the features requested are enabled, false otherwise
	 */
	function isFeatureEnabled(uint256 required) public view returns (bool) {
		// delegate call to `__hasRole`, passing `features` property
		return __hasRole(features(), required);
	}

	/**
	 * @notice Checks if transaction sender `msg.sender` has all the permissions required
	 *
	 * @param required set of permissions (role) to check against
	 * @return true if all the permissions requested are enabled, false otherwise
	 */
	function isSenderInRole(uint256 required) public view returns (bool) {
		// delegate call to `isOperatorInRole`, passing transaction sender
		return isOperatorInRole(msg.sender, required);
	}

	/**
	 * @notice Checks if operator has all the permissions (role) required
	 *
	 * @param operator address of the user to check role for
	 * @param required set of permissions (role) to check
	 * @return true if all the permissions requested are enabled, false otherwise
	 */
	function isOperatorInRole(address operator, uint256 required) public view returns (bool) {
		// delegate call to `__hasRole`, passing operator's permissions (role)
		return __hasRole(userRoles[operator], required);
	}

	/**
	 * @dev Checks if role `actual` contains all the permissions required `required`
	 *
	 * @param actual existent role
	 * @param required required role
	 * @return true if actual has required role (all permissions), false otherwise
	 */
	function __hasRole(uint256 actual, uint256 required) internal pure returns (bool) {
		// check the bitmask for the role required and return the result
		return actual & required == required;
	}

	/**
	 * @inheritdoc UUPSUpgradeable
	 */
	function _authorizeUpgrade(address) internal virtual override {
		// caller must have a permission to upgrade the contract
		require(isSenderInRole(ROLE_UPGRADE_MANAGER), "access denied");
	}
}

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

Contract Security Audit

Contract ABI

API
[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"previousAdmin","type":"address"},{"indexed":false,"internalType":"address","name":"newAdmin","type":"address"}],"name":"AdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_by","type":"address"},{"indexed":false,"internalType":"string","name":"oldVal","type":"string"},{"indexed":false,"internalType":"string","name":"newVal","type":"string"}],"name":"BaseURIUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"beacon","type":"address"}],"name":"BeaconUpgraded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_by","type":"address"},{"indexed":true,"internalType":"address","name":"_from","type":"address"},{"indexed":true,"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"Burnt","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_by","type":"address"},{"indexed":false,"internalType":"string","name":"_value","type":"string"}],"name":"ContractURIUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_by","type":"address"},{"indexed":true,"internalType":"address","name":"_to","type":"address"},{"indexed":true,"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"Minted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_by","type":"address"},{"indexed":true,"internalType":"address","name":"_oldVal","type":"address"},{"indexed":true,"internalType":"address","name":"_newVal","type":"address"}],"name":"OwnerUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_by","type":"address"},{"indexed":true,"internalType":"address","name":"_to","type":"address"},{"indexed":false,"internalType":"uint256","name":"_requested","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_actual","type":"uint256"}],"name":"RoleUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_by","type":"address"},{"indexed":true,"internalType":"address","name":"_receiver","type":"address"},{"indexed":false,"internalType":"uint16","name":"_percentage","type":"uint16"}],"name":"RoyaltyInfoUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_by","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"string","name":"oldVal","type":"string"},{"indexed":false,"internalType":"string","name":"newVal","type":"string"}],"name":"TokenURIUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"inputs":[],"name":"FEATURE_BURNS_ON_BEHALF","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"FEATURE_OWN_BURNS","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"FEATURE_TRANSFERS","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"FEATURE_TRANSFERS_ON_BEHALF","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ROLE_ACCESS_MANAGER","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ROLE_OWNER_MANAGER","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ROLE_RESCUE_MANAGER","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ROLE_ROYALTY_MANAGER","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ROLE_TOKEN_CREATOR","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ROLE_TOKEN_DESTROYER","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ROLE_UPGRADE_MANAGER","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ROLE_URI_MANAGER","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"baseURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"contractURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"uint256","name":"target","type":"uint256"},{"internalType":"uint256","name":"desired","type":"uint256"}],"name":"evaluateBy","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"exists","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"features","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getImplementation","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"required","type":"uint256"}],"name":"isFeatureEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"uint256","name":"required","type":"uint256"}],"name":"isOperatorInRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_addr","type":"address"}],"name":"isOwner","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"required","type":"uint256"}],"name":"isSenderInRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"mint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_quantity","type":"uint256"},{"internalType":"bytes","name":"_mintingBlob","type":"bytes"}],"name":"mintFor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"}],"name":"postConstruct","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"proxiableUUID","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_contract","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"rescueErc20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"_salePrice","type":"uint256"}],"name":"royaltyInfo","outputs":[{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"royaltyAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"royaltyPercentage","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"royaltyReceiver","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"safeMint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"safeMint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"__baseURI","type":"string"}],"name":"setBaseURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_contractURI","type":"string"}],"name":"setContractURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_royaltyReceiver","type":"address"},{"internalType":"uint16","name":"_royaltyPercentage","type":"uint16"}],"name":"setRoyaltyInfo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"string","name":"_tokenURI","type":"string"}],"name":"setTokenURI","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":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenOfOwnerByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_mask","type":"uint256"}],"name":"updateFeatures","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"uint256","name":"role","type":"uint256"}],"name":"updateRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"}],"name":"upgradeTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upgradeToAndCall","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"userRoles","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]

60a06040523060805234801561001457600080fd5b5060805161447461004c60003960008181610f3c01528181610f7c0152818161103301528181611073015261119d01526144746000f3fe6080604052600436106103975760003560e01c806374d5e100116101dc578063ae682e2e11610102578063d5bb7f67116100a0578063f2fde38b1161006f578063f2fde38b14610a8e578063f63c2f8214610aae578063f822d5aa14610ac3578063fcc2c07814610ae357600080fd5b8063d5bb7f6714610a22578063e62cac7614610a42578063e8a3d48514610a59578063e985e9c514610a6e57600080fd5b8063c0d6568d116100dc578063c0d6568d146109b6578063c688d693146109cb578063c87b56dd146109eb578063cc2da7ff14610a0b57600080fd5b8063ae682e2e14610967578063b29a2f441461097f578063b88d4fde1461099657600080fd5b8063938e3d7b1161017a578063a22cb46511610149578063a22cb465146108fa578063aaf10f421461091a578063ae5b102e1461092f578063ae60bda41461094f57600080fd5b8063938e3d7b1461088457806395d89b41146108a45780639fbc8713146108b9578063a1448194146108da57600080fd5b80638a71bb2d116101b65780638a71bb2d146108015780638d4e57e6146108375780638da5cb5b1461084e5780638f6fba8c1461086f57600080fd5b806374d5e100146107935780638832e6e3146107c15780638a2b9608146107e157600080fd5b80632f745c59116102c15780634f6ccce71161025f5780636c0360eb1161022e5780636c0360eb1461071e57806370a082311461073357806372504a2414610753578063725f36261461077357600080fd5b80634f6ccce7146106a957806352d1902d146106c957806355f804b3146106de5780636352211e146106fe57600080fd5b806342842e0e1161029b57806342842e0e1461063657806342966c68146106565780634f1ef286146106765780634f558e791461068957600080fd5b80632f745c59146105d65780633659cfe6146105f657806340c10f191461061657600080fd5b806319ee6e3f116103395780632a55205a116103085780632a55205a1461052d5780632b5214161461056c5780632d17f8bc1461058f5780632f54bf6e146105a657600080fd5b806319ee6e3f146104b85780631a0b04ea146104d857806323b872dd146104ed578063243feb991461050d57600080fd5b8063095ea7b311610375578063095ea7b31461042b57806314b7b4e11461044d578063162094c41461047957806318160ddd1461049957600080fd5b806301ffc9a71461039c57806306fdde03146103d1578063081812fc146103f3575b600080fd5b3480156103a857600080fd5b506103bc6103b7366004613958565b610b03565b60405190151581526020015b60405180910390f35b3480156103dd57600080fd5b506103e6610b2e565b6040516103c891906139cd565b3480156103ff57600080fd5b5061041361040e3660046139e0565b610bc0565b6040516001600160a01b0390911681526020016103c8565b34801561043757600080fd5b5061044b610446366004613a15565b610be7565b005b34801561045957600080fd5b506104646204000081565b60405163ffffffff90911681526020016103c8565b34801561048557600080fd5b5061044b610494366004613ae2565b610d02565b3480156104a557600080fd5b506099545b6040519081526020016103c8565b3480156104c457600080fd5b5061044b6104d3366004613b29565b610d7b565b3480156104e457600080fd5b50610464600881565b3480156104f957600080fd5b5061044b610508366004613bb0565b610deb565b34801561051957600080fd5b5061044b610528366004613bb0565b610e1c565b34801561053957600080fd5b5061054d610548366004613bec565b610e58565b604080516001600160a01b0390931683526020830191909152016103c8565b34801561057857600080fd5b5030600090815261015f60205260409020546104aa565b34801561059b57600080fd5b506104646208000081565b3480156105b257600080fd5b506103bc6105c1366004613c0e565b6101c3546001600160a01b0391821691161490565b3480156105e257600080fd5b506104aa6105f1366004613a15565b610e9b565b34801561060257600080fd5b5061044b610611366004613c0e565b610f31565b34801561062257600080fd5b5061044b610631366004613a15565b610ffa565b34801561064257600080fd5b5061044b610651366004613bb0565b611004565b34801561066257600080fd5b5061044b6106713660046139e0565b61101f565b61044b610684366004613c29565b611028565b34801561069557600080fd5b506103bc6106a43660046139e0565b6110de565b3480156106b557600080fd5b506104aa6106c43660046139e0565b6110fd565b3480156106d557600080fd5b506104aa611190565b3480156106ea57600080fd5b5061044b6106f9366004613c61565b611243565b34801561070a57600080fd5b506104136107193660046139e0565b6112c4565b34801561072a57600080fd5b506103e6611324565b34801561073f57600080fd5b506104aa61074e366004613c0e565b6113b3565b34801561075f57600080fd5b5061044b61076e366004613c96565b611439565b34801561077f57600080fd5b506103bc61078e3660046139e0565b61157b565b34801561079f57600080fd5b506104aa6107ae366004613c0e565b61015f6020526000908152604090205481565b3480156107cd57600080fd5b5061044b6107dc366004613cd4565b611595565b3480156107ed57600080fd5b5061044b6107fc366004613d2b565b6115a0565b34801561080d57600080fd5b506101c45461082490600160a01b900461ffff1681565b60405161ffff90911681526020016103c8565b34801561084357600080fd5b506104646201000081565b34801561085a57600080fd5b506101c354610413906001600160a01b031681565b34801561087b57600080fd5b50610464600281565b34801561089057600080fd5b5061044b61089f366004613c61565b61165c565b3480156108b057600080fd5b506103e66116dd565b3480156108c557600080fd5b506101c454610413906001600160a01b031681565b3480156108e657600080fd5b5061044b6108f5366004613a15565b6116ec565b34801561090657600080fd5b5061044b610915366004613d93565b6116f6565b34801561092657600080fd5b50610413611701565b34801561093b57600080fd5b5061044b61094a366004613a15565b611710565b34801561095b57600080fd5b506104aa600160fe1b81565b34801561097357600080fd5b506104aa600160ff1b81565b34801561098b57600080fd5b506104646210000081565b3480156109a257600080fd5b5061044b6109b1366004613dbf565b6117b9565b3480156109c257600080fd5b50610464600181565b3480156109d757600080fd5b506103bc6109e6366004613a15565b6117f1565b3480156109f757600080fd5b506103e6610a063660046139e0565b611817565b348015610a1757600080fd5b506104646220000081565b348015610a2e57600080fd5b5061044b610a3d3660046139e0565b611822565b348015610a4e57600080fd5b506104646202000081565b348015610a6557600080fd5b506103e661182c565b348015610a7a57600080fd5b506103bc610a89366004613e27565b61183a565b348015610a9a57600080fd5b5061044b610aa9366004613c0e565b611868565b348015610aba57600080fd5b50610464601081565b348015610acf57600080fd5b506104aa610ade366004613e5a565b61192b565b348015610aef57600080fd5b506103bc610afe3660046139e0565b611957565b60006001600160e01b0319821663152a902d60e11b1480610b285750610b2882611963565b92915050565b606060658054610b3d90613e8d565b80601f0160208091040260200160405190810160405280929190818152602001828054610b6990613e8d565b8015610bb65780601f10610b8b57610100808354040283529160200191610bb6565b820191906000526020600020905b815481529060010190602001808311610b9957829003601f168201915b5050505050905090565b6000610bcb826119a9565b506000908152606960205260409020546001600160a01b031690565b6000610bf2826112c4565b9050806001600160a01b0316836001600160a01b03161415610c655760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084015b60405180910390fd5b336001600160a01b0382161480610c815750610c81813361183a565b610cf35760405162461bcd60e51b815260206004820152603d60248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60448201527f6b656e206f776e6572206f7220617070726f76656420666f7220616c6c0000006064820152608401610c5c565b610cfd8383611a08565b505050565b610d0e62040000611957565b610d2a5760405162461bcd60e51b8152600401610c5c90613ec8565b336001600160a01b03167f7989fff0ffb34805e8b3574b890ed6157f85a384c69b9a0c04991b24cabb82598383604051610d65929190613eef565b60405180910390a2610d778282611a76565b5050565b82600114610dcb5760405162461bcd60e51b815260206004820152601d60248201527f7175616e74697479206d75737420626520657175616c20746f206f6e650000006044820152606401610c5c565b6000610dd78383611a80565b509050610de48582610ffa565b5050505050565b610df53382611c39565b610e115760405162461bcd60e51b8152600401610c5c90613f27565b610cfd838383611c98565b610e2862080000611957565b610e445760405162461bcd60e51b8152600401610c5c90613ec8565b610cfd6001600160a01b0384168383611e09565b6101c45460009081906001600160a01b0381169061271090610e8590600160a01b900461ffff1686613f8a565b610e8f9190613fa9565b915091505b9250929050565b6000610ea6836113b3565b8210610f085760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b6064820152608401610c5c565b506001600160a01b03919091166000908152609760209081526040808320938352929052205490565b306001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161415610f7a5760405162461bcd60e51b8152600401610c5c90613fcb565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316610fac611e5b565b6001600160a01b031614610fd25760405162461bcd60e51b8152600401610c5c90614017565b610fdb81611e77565b60408051600080825260208201909252610ff791839190611ea0565b50565b610d77828261200b565b610cfd838383604051806020016040528060008152506117b9565b610ff781612079565b306001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614156110715760405162461bcd60e51b8152600401610c5c90613fcb565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166110a3611e5b565b6001600160a01b0316146110c95760405162461bcd60e51b8152600401610c5c90614017565b6110d282611e77565b610d7782826001611ea0565b6000818152606760205260408120546001600160a01b03161515610b28565b600061110860995490565b821061116b5760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b6064820152608401610c5c565b6099828154811061117e5761117e614063565b90600052602060002001549050919050565b6000306001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146112305760405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c60448201527f6c6564207468726f7567682064656c656761746563616c6c00000000000000006064820152608401610c5c565b506000805160206143d883398151915290565b61124f62040000611957565b61126b5760405162461bcd60e51b8152600401610c5c90613ec8565b336001600160a01b03167fac455070f26733cc10c09e4389a74bf73bdb676d730ee31215c31d20daa88005610191836040516112a8929190614079565b60405180910390a28051610d7790610191906020840190613873565b6000818152606760205260408120546001600160a01b031680610b285760405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b6044820152606401610c5c565b610191805461133290613e8d565b80601f016020809104026020016040519081016040528092919081815260200182805461135e90613e8d565b80156113ab5780601f10611380576101008083540402835291602001916113ab565b820191906000526020600020905b81548152906001019060200180831161138e57829003601f168201915b505050505081565b60006001600160a01b03821661141d5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a2061646472657373207a65726f206973206e6f7420612076616044820152683634b21037bbb732b960b91b6064820152608401610c5c565b506001600160a01b031660009081526068602052604090205490565b61144562100000611957565b6114615760405162461bcd60e51b8152600401610c5c90613ec8565b6001600160a01b03821615158061147a575061ffff8116155b6114b95760405162461bcd60e51b815260206004820152601060248201526f34b73b30b634b2103932b1b2b4bb32b960811b6044820152606401610c5c565b6127108161ffff16111561150f5760405162461bcd60e51b815260206004820152601f60248201527f726f79616c74792070657263656e7461676520657863656564732031303025006044820152606401610c5c565b6101c480546001600160a01b0384166001600160b01b03199091168117600160a01b61ffff8516908102919091179092556040519182529033907f9ca088b6b695032bcd5d1fa450e8fa2773391294f09e3710ace940c4ae8cffac906020015b60405180910390a35050565b30600090815261015f602052604081205482168214610b28565b610cfd83838361220e565b600054610100900460ff16158080156115c05750600054600160ff909116105b806115da5750303b1580156115da575060005460ff166001145b6115f65760405162461bcd60e51b8152600401610c5c9061412c565b6000805460ff191660011790558015611619576000805461ff0019166101001790555b611624838333612241565b8015610cfd576000805461ff0019169055604051600181526000805160206143f88339815191529060200160405180910390a1505050565b61166862040000611957565b6116845760405162461bcd60e51b8152600401610c5c90613ec8565b8051611698906101c5906020840190613873565b50336001600160a01b03167f1ca91f64ead03abb06ea28975dfbf18044ac06f9fa1cb62a54ccc905df1028ed826040516116d291906139cd565b60405180910390a250565b606060668054610b3d90613e8d565b610d778282612312565b610d7733838361232c565b600061170b611e5b565b905090565b61171d600160ff1b611957565b6117395760405162461bcd60e51b8152600401610c5c90613ec8565b6001600160a01b038216600090815261015f602052604090205461175f9033908361192b565b6001600160a01b038316600081815261015f60205260409081902083905551909133917f5a10526456f5116c0b7b80582c217d666243fd51b6a2d92c8011e601c2462e5f9161156f91869190918252602082015260400190565b6117c33383611c39565b6117df5760405162461bcd60e51b8152600401610c5c90613f27565b6117eb848484846123fb565b50505050565b6001600160a01b038216600090815261015f6020526040812054821682145b9392505050565b6060610b288261242e565b610ff73082611710565b6101c5805461133290613e8d565b6001600160a01b039182166000908152606a6020908152604080832093909416825291909152205460ff1690565b61187462200000611957565b6118905760405162461bcd60e51b8152600401610c5c90613ec8565b6101c3546040516001600160a01b0380841692169033907fb9312e2100469bd44e3f762c248f4dcc8d7788906fabf34f79db45920c37e26990600090a46101c3546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a36101c380546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b0392909216600090815261015f60205260409020546000198084188216189216171690565b6000610b2833836117f1565b600061196e8261252a565b8061198957506001600160e01b031982166326e2e61760e01b145b80610b2857506001600160e01b03198216630852cd8d60e31b1492915050565b6000818152606760205260409020546001600160a01b0316610ff75760405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b6044820152606401610c5c565b600081815260696020526040902080546001600160a01b0319166001600160a01b0384169081179091558190611a3d826112c4565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b610d77828261254f565b600060606000611ade85858080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201829052506040805180820190915260018152601d60f91b6020820152935091506125e99050565b90506000811215611b285760405162461bcd60e51b815260206004820152601460248201527314d95c185c985d1bdc881b5d5cdd08195e1a5cdd60621b6044820152606401610c5c565b6000611b8286600187611b3b828761417a565b92611b4893929190614191565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061268192505050565b905060006003611b92848861417a565b611b9c919061417a565b905080611bc057816040518060200160405280600081525094509450505050610e94565b3660008888611bd08760026141bb565b90611bdc60018c61417a565b92611be993929190614191565b9150915083828281818080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250959f929e50919c50505050505050505050505050565b600080611c45836112c4565b9050806001600160a01b0316846001600160a01b03161480611c6c5750611c6c818561183a565b80611c905750836001600160a01b0316611c8584610bc0565b6001600160a01b0316145b949350505050565b826001600160a01b0316611cab826112c4565b6001600160a01b031614611cd15760405162461bcd60e51b8152600401610c5c906141d3565b6001600160a01b038216611d335760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610c5c565b611d408383836001612759565b826001600160a01b0316611d53826112c4565b6001600160a01b031614611d795760405162461bcd60e51b8152600401610c5c906141d3565b600081815260696020908152604080832080546001600160a01b03199081169091556001600160a01b0387811680865260688552838620805460001901905590871680865283862080546001019055868652606790945282852080549092168417909155905184937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052610cfd908490612863565b6000805160206143d8833981519152546001600160a01b031690565b611e84600160fe1b611957565b610ff75760405162461bcd60e51b8152600401610c5c90613ec8565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff1615611ed357610cfd8361291a565b826001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015611f2d575060408051601f3d908101601f19168201909252611f2a91810190614218565b60015b611f905760405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201526d6f6e206973206e6f74205555505360901b6064820152608401610c5c565b6000805160206143d88339815191528114611fff5760405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b6064820152608401610c5c565b50610cfd8383836129b6565b61201762010000611957565b6120335760405162461bcd60e51b8152600401610c5c90613ec8565b61203d82826129db565b60405181906001600160a01b0384169033907f9d228d69b5fdb8d273a2336f8fb8612d039631024ea9bf09c424a9503aa078f090600090a45050565b6000612084826112c4565b905061209262020000611957565b6121c9576001600160a01b038116331480156120b357506120b3600861157b565b806120d757506001600160a01b03811633148015906120d757506120d7601061157b565b6001600160a01b0382163314612122576040518060400160405280601c81526020017f6275726e73206f6e20626568616c66206172652064697361626c65640000000081525061214e565b60405180604001604052806012815260200171189d5c9b9cc8185c9948191a5cd8589b195960721b8152505b9061216c5760405162461bcd60e51b8152600401610c5c91906139cd565b50336001600160a01b038216148061219d575061218882610bc0565b6001600160a01b0316336001600160a01b0316145b806121ad57506121ad813361183a565b6121c95760405162461bcd60e51b8152600401610c5c90613ec8565b6121d282612b74565b60405182906001600160a01b0383169033907fe8a89cc6e5096f9d9f43de82c077c1f4cfe707c0e0c2032176c68813b9ae6a5c90600090a45050565b612218838361200b565b6122256000848484612bb4565b610cfd5760405162461bcd60e51b8152600401610c5c90614231565b600054610100900460ff16158080156122615750600054600160ff909116105b8061227b5750303b15801561227b575060005460ff166001145b6122975760405162461bcd60e51b8152600401610c5c9061412c565b6000805460ff1916600117905580156122ba576000805461ff0019166101001790555b6122c5848484612cb2565b6101c380546001600160a01b0319163317905580156117eb576000805461ff0019169055604051600181526000805160206143f8833981519152906020015b60405180910390a150505050565b610d7782826040518060200160405280600081525061220e565b816001600160a01b0316836001600160a01b0316141561238e5760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610c5c565b6001600160a01b038381166000818152606a6020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b612406848484611c98565b61241284848484612bb4565b6117eb5760405162461bcd60e51b8152600401610c5c90614231565b6060612439826119a9565b600082815260c960205260408120805461245290613e8d565b80601f016020809104026020016040519081016040528092919081815260200182805461247e90613e8d565b80156124cb5780601f106124a0576101008083540402835291602001916124cb565b820191906000526020600020905b8154815290600101906020018083116124ae57829003601f168201915b5050505050905060006124dc612d7e565b90508051600014156124ef575092915050565b815115612521578082604051602001612509929190614283565b60405160208183030381529060405292505050919050565b611c9084612d8e565b60006001600160e01b0319821663780e9d6360e01b1480610b285750610b2882612df4565b6000828152606760205260409020546001600160a01b03166125ca5760405162461bcd60e51b815260206004820152602e60248201527f45524337323155524953746f726167653a2055524920736574206f66206e6f6e60448201526d32bc34b9ba32b73a103a37b5b2b760911b6064820152608401610c5c565b600082815260c9602090815260409091208251610cfd92840190613873565b815160009083906001146125ff576125ff6142b2565b825b8551811015612674578160008151811061261d5761261d614063565b602001015160f81c60f81b6001600160f81b03191686828151811061264457612644614063565b01602001516001600160f81b03191614156126625791506118109050565b8061266c816142c8565b915050612601565b5060001995945050505050565b600080805b83518110156127525760008482815181106126a3576126a3614063565b016020015160f81c9050603081108015906126bf575060398111155b156126eb576126cf60308261417a565b6126da84600a613f8a565b6126e491906141bb565b925061273f565b60405162461bcd60e51b815260206004820152602360248201527f696e76616c696420696e7075742c206f6e6c79206e756d6265727320616c6c6f6044820152621dd95960ea1b6064820152608401610c5c565b508061274a816142c8565b915050612686565b5092915050565b6001600160a01b038416158061277657506001600160a01b038316155b8061279957506001600160a01b038416331480156127995750612799600161157b565b806127bd57506001600160a01b03841633148015906127bd57506127bd600261157b565b6001600160a01b0385163314612808576040518060400160405280602081526020017f7472616e7366657273206f6e20626568616c66206172652064697361626c6564815250612838565b604051806040016040528060168152602001751d1c985b9cd9995c9cc8185c9948191a5cd8589b195960521b8152505b906128565760405162461bcd60e51b8152600401610c5c91906139cd565b506117eb84848484612e44565b60006128b8826040518060400160405280601b81526020017f4552433230206c6f772d6c6576656c2063616c6c206661696c65640000000000815250856001600160a01b0316612f7d9092919063ffffffff16565b805190915015610cfd57808060200190518101906128d691906142e3565b610cfd5760405162461bcd60e51b8152602060048201526015602482015274115490cc8c081d1c985b9cd9995c8819985a5b1959605a1b6044820152606401610c5c565b6001600160a01b0381163b6129875760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608401610c5c565b6000805160206143d883398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b6129bf83612f8c565b6000825111806129cc5750805b15610cfd576117eb8383612fcc565b6001600160a01b038216612a315760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610c5c565b6000818152606760205260409020546001600160a01b031615612a965760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610c5c565b612aa4600083836001612759565b6000818152606760205260409020546001600160a01b031615612b095760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610c5c565b6001600160a01b038216600081815260686020908152604080832080546001019055848352606790915280822080546001600160a01b0319168417905551839291907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b612b7d816130c0565b600081815260c9602052604090208054612b9690613e8d565b159050610ff757600081815260c960205260408120610ff7916138f7565b60006001600160a01b0384163b15612ca757604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290612bf8903390899088908890600401614300565b6020604051808303816000875af1925050508015612c33575060408051601f3d908101601f19168201909252612c309181019061433d565b60015b612c8d573d808015612c61576040519150601f19603f3d011682016040523d82523d6000602084013e612c66565b606091505b508051612c855760405162461bcd60e51b8152600401610c5c90614231565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611c90565b506001949350505050565b600054610100900460ff1615808015612cd25750600054600160ff909116105b80612cec5750303b158015612cec575060005460ff166001145b612d085760405162461bcd60e51b8152600401610c5c9061412c565b6000805460ff191660011790558015612d2b576000805461ff0019166101001790555b612d358484613163565b612d3d613194565b612d45613194565b612d4e826131bd565b80156117eb576000805461ff0019169055604051600181526000805160206143f883398151915290602001612304565b60606101918054610b3d90613e8d565b6060612d99826119a9565b6000612da3612d7e565b90506000815111612dc35760405180602001604052806000815250611810565b80612dcd84613308565b604051602001612dde929190614283565b6040516020818303038152906040529392505050565b60006001600160e01b031982166380ac58cd60e01b1480612e2557506001600160e01b03198216635b5e139f60e01b145b80610b2857506301ffc9a760e01b6001600160e01b0319831614610b28565b612e50848484846133a5565b6001811115612ebf5760405162461bcd60e51b815260206004820152603560248201527f455243373231456e756d657261626c653a20636f6e7365637574697665207472604482015274185b9cd9995c9cc81b9bdd081cdd5c1c1bdc9d1959605a1b6064820152608401610c5c565b816001600160a01b038516612f1b57612f1681609980546000838152609a60205260408120829055600182018355919091527f72a152ddfb8e864297c917af52ea6c1c68aead0fee1a62673fcc7e0c94979d000155565b612f3e565b836001600160a01b0316856001600160a01b031614612f3e57612f3e858261342d565b6001600160a01b038416612f5a57612f55816134ca565b610de4565b846001600160a01b0316846001600160a01b031614610de457610de48482613579565b6060611c9084846000856135bd565b612f958161291a565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606001600160a01b0383163b6130345760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608401610c5c565b600080846001600160a01b03168460405161304f919061435a565b600060405180830381855af49150503d806000811461308a576040519150601f19603f3d011682016040523d82523d6000602084013e61308f565b606091505b50915091506130b7828260405180606001604052806027815260200161441860279139613698565b95945050505050565b60006130cb826112c4565b90506130db816000846001612759565b6130e4826112c4565b600083815260696020908152604080832080546001600160a01b03199081169091556001600160a01b0385168085526068845282852080546000190190558785526067909352818420805490911690555192935084927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b600054610100900460ff1661318a5760405162461bcd60e51b8152600401610c5c90614376565b610d7782826136b1565b600054610100900460ff166131bb5760405162461bcd60e51b8152600401610c5c90614376565b565b600054610100900460ff16158080156131dd5750600054600160ff909116105b806131f75750303b1580156131f7575060005460ff166001145b6132135760405162461bcd60e51b8152600401610c5c9061412c565b6000805460ff191660011790558015613236576000805461ff0019166101001790555b303b156132775760405162461bcd60e51b815260206004820152600f60248201526e1a5b9d985b1a590818dbdb9d195e1d608a1b6044820152606401610c5c565b6001600160a01b038216600081815261015f60209081526040918290206000199081905582518181529182015233917f5a10526456f5116c0b7b80582c217d666243fd51b6a2d92c8011e601c2462e5f910160405180910390a38015610d77576000805461ff0019169055604051600181526000805160206143f88339815191529060200160405180910390a15050565b60606000613315836136ff565b600101905060008167ffffffffffffffff81111561333557613335613a3f565b6040519080825280601f01601f19166020018201604052801561335f576020820181803683370190505b5090508181016020015b600019016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a85049450846133985761339d565b613369565b509392505050565b60018111156117eb576001600160a01b038416156133eb576001600160a01b038416600090815260686020526040812080548392906133e590849061417a565b90915550505b6001600160a01b038316156117eb576001600160a01b038316600090815260686020526040812080548392906134229084906141bb565b909155505050505050565b6000600161343a846113b3565b613444919061417a565b600083815260986020526040902054909150808214613497576001600160a01b03841660009081526097602090815260408083208584528252808320548484528184208190558352609890915290208190555b5060009182526098602090815260408084208490556001600160a01b039094168352609781528383209183525290812055565b6099546000906134dc9060019061417a565b6000838152609a60205260408120546099805493945090928490811061350457613504614063565b90600052602060002001549050806099838154811061352557613525614063565b6000918252602080832090910192909255828152609a9091526040808220849055858252812055609980548061355d5761355d6143c1565b6001900381819060005260206000200160009055905550505050565b6000613584836113b3565b6001600160a01b039093166000908152609760209081526040808320868452825280832085905593825260989052919091209190915550565b60608247101561361e5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610c5c565b600080866001600160a01b0316858760405161363a919061435a565b60006040518083038185875af1925050503d8060008114613677576040519150601f19603f3d011682016040523d82523d6000602084013e61367c565b606091505b509150915061368d878383876137d7565b979650505050505050565b606083156136a7575081611810565b6118108383613849565b600054610100900460ff166136d85760405162461bcd60e51b8152600401610c5c90614376565b81516136eb906065906020850190613873565b508051610cfd906066906020840190613873565b60008072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b831061373e5772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6d04ee2d6d415b85acef8100000000831061376a576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc10000831061378857662386f26fc10000830492506010015b6305f5e10083106137a0576305f5e100830492506008015b61271083106137b457612710830492506004015b606483106137c6576064830492506002015b600a8310610b285760010192915050565b6060831561384357825161383c576001600160a01b0385163b61383c5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610c5c565b5081611c90565b611c9083835b8151156138595781518083602001fd5b8060405162461bcd60e51b8152600401610c5c91906139cd565b82805461387f90613e8d565b90600052602060002090601f0160209004810192826138a157600085556138e7565b82601f106138ba57805160ff19168380011785556138e7565b828001600101855582156138e7579182015b828111156138e75782518255916020019190600101906138cc565b506138f392915061392d565b5090565b50805461390390613e8d565b6000825580601f10613913575050565b601f016020900490600052602060002090810190610ff791905b5b808211156138f3576000815560010161392e565b6001600160e01b031981168114610ff757600080fd5b60006020828403121561396a57600080fd5b813561181081613942565b60005b83811015613990578181015183820152602001613978565b838111156117eb5750506000910152565b600081518084526139b9816020860160208601613975565b601f01601f19169290920160200192915050565b60208152600061181060208301846139a1565b6000602082840312156139f257600080fd5b5035919050565b80356001600160a01b0381168114613a1057600080fd5b919050565b60008060408385031215613a2857600080fd5b613a31836139f9565b946020939093013593505050565b634e487b7160e01b600052604160045260246000fd5b600082601f830112613a6657600080fd5b813567ffffffffffffffff80821115613a8157613a81613a3f565b604051601f8301601f19908116603f01168101908282118183101715613aa957613aa9613a3f565b81604052838152866020858801011115613ac257600080fd5b836020870160208301376000602085830101528094505050505092915050565b60008060408385031215613af557600080fd5b82359150602083013567ffffffffffffffff811115613b1357600080fd5b613b1f85828601613a55565b9150509250929050565b60008060008060608587031215613b3f57600080fd5b613b48856139f9565b935060208501359250604085013567ffffffffffffffff80821115613b6c57600080fd5b818701915087601f830112613b8057600080fd5b813581811115613b8f57600080fd5b886020828501011115613ba157600080fd5b95989497505060200194505050565b600080600060608486031215613bc557600080fd5b613bce846139f9565b9250613bdc602085016139f9565b9150604084013590509250925092565b60008060408385031215613bff57600080fd5b50508035926020909101359150565b600060208284031215613c2057600080fd5b611810826139f9565b60008060408385031215613c3c57600080fd5b613c45836139f9565b9150602083013567ffffffffffffffff811115613b1357600080fd5b600060208284031215613c7357600080fd5b813567ffffffffffffffff811115613c8a57600080fd5b611c9084828501613a55565b60008060408385031215613ca957600080fd5b613cb2836139f9565b9150602083013561ffff81168114613cc957600080fd5b809150509250929050565b600080600060608486031215613ce957600080fd5b613cf2846139f9565b925060208401359150604084013567ffffffffffffffff811115613d1557600080fd5b613d2186828701613a55565b9150509250925092565b60008060408385031215613d3e57600080fd5b823567ffffffffffffffff80821115613d5657600080fd5b613d6286838701613a55565b93506020850135915080821115613d7857600080fd5b50613b1f85828601613a55565b8015158114610ff757600080fd5b60008060408385031215613da657600080fd5b613daf836139f9565b91506020830135613cc981613d85565b60008060008060808587031215613dd557600080fd5b613dde856139f9565b9350613dec602086016139f9565b925060408501359150606085013567ffffffffffffffff811115613e0f57600080fd5b613e1b87828801613a55565b91505092959194509250565b60008060408385031215613e3a57600080fd5b613e43836139f9565b9150613e51602084016139f9565b90509250929050565b600080600060608486031215613e6f57600080fd5b613e78846139f9565b95602085013595506040909401359392505050565b600181811c90821680613ea157607f821691505b60208210811415613ec257634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252600d908201526c1858d8d95cdcc819195b9a5959609a1b604082015260600190565b8281526060602082015260086060820152673d32b83832b634b760c11b608082015260a060408201526000611c9060a08301846139a1565b6020808252602d908201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560408201526c1c881bdc88185c1c1c9bdd9959609a1b606082015260800190565b634e487b7160e01b600052601160045260246000fd5b6000816000190483118215151615613fa457613fa4613f74565b500290565b600082613fc657634e487b7160e01b600052601260045260246000fd5b500490565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b19195b1959d85d1958d85b1b60a21b606082015260800190565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b6163746976652070726f787960a01b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b60408152600080845481600182811c91508083168061409957607f831692505b60208084108214156140b957634e487b7160e01b86526022600452602486fd5b60408801849052606088018280156140d857600181146140e957614114565b60ff19871682528282019750614114565b60008c81526020902060005b8781101561410e578154848201529086019084016140f5565b83019850505b50508786038189015250505050506130b781856139a1565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b60008282101561418c5761418c613f74565b500390565b600080858511156141a157600080fd5b838611156141ae57600080fd5b5050820193919092039150565b600082198211156141ce576141ce613f74565b500190565b60208082526025908201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060408201526437bbb732b960d91b606082015260800190565b60006020828403121561422a57600080fd5b5051919050565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b60008351614295818460208801613975565b8351908301906142a9818360208801613975565b01949350505050565b634e487b7160e01b600052600160045260246000fd5b60006000198214156142dc576142dc613f74565b5060010190565b6000602082840312156142f557600080fd5b815161181081613d85565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090614333908301846139a1565b9695505050505050565b60006020828403121561434f57600080fd5b815161181081613942565b6000825161436c818460208701613975565b9190910192915050565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b634e487b7160e01b600052603160045260246000fdfe360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212208c1f08599e092076142026adc04d27dd707e2da069840baf7172034b9de1150f64736f6c634300080b0033

Deployed Bytecode

0x6080604052600436106103975760003560e01c806374d5e100116101dc578063ae682e2e11610102578063d5bb7f67116100a0578063f2fde38b1161006f578063f2fde38b14610a8e578063f63c2f8214610aae578063f822d5aa14610ac3578063fcc2c07814610ae357600080fd5b8063d5bb7f6714610a22578063e62cac7614610a42578063e8a3d48514610a59578063e985e9c514610a6e57600080fd5b8063c0d6568d116100dc578063c0d6568d146109b6578063c688d693146109cb578063c87b56dd146109eb578063cc2da7ff14610a0b57600080fd5b8063ae682e2e14610967578063b29a2f441461097f578063b88d4fde1461099657600080fd5b8063938e3d7b1161017a578063a22cb46511610149578063a22cb465146108fa578063aaf10f421461091a578063ae5b102e1461092f578063ae60bda41461094f57600080fd5b8063938e3d7b1461088457806395d89b41146108a45780639fbc8713146108b9578063a1448194146108da57600080fd5b80638a71bb2d116101b65780638a71bb2d146108015780638d4e57e6146108375780638da5cb5b1461084e5780638f6fba8c1461086f57600080fd5b806374d5e100146107935780638832e6e3146107c15780638a2b9608146107e157600080fd5b80632f745c59116102c15780634f6ccce71161025f5780636c0360eb1161022e5780636c0360eb1461071e57806370a082311461073357806372504a2414610753578063725f36261461077357600080fd5b80634f6ccce7146106a957806352d1902d146106c957806355f804b3146106de5780636352211e146106fe57600080fd5b806342842e0e1161029b57806342842e0e1461063657806342966c68146106565780634f1ef286146106765780634f558e791461068957600080fd5b80632f745c59146105d65780633659cfe6146105f657806340c10f191461061657600080fd5b806319ee6e3f116103395780632a55205a116103085780632a55205a1461052d5780632b5214161461056c5780632d17f8bc1461058f5780632f54bf6e146105a657600080fd5b806319ee6e3f146104b85780631a0b04ea146104d857806323b872dd146104ed578063243feb991461050d57600080fd5b8063095ea7b311610375578063095ea7b31461042b57806314b7b4e11461044d578063162094c41461047957806318160ddd1461049957600080fd5b806301ffc9a71461039c57806306fdde03146103d1578063081812fc146103f3575b600080fd5b3480156103a857600080fd5b506103bc6103b7366004613958565b610b03565b60405190151581526020015b60405180910390f35b3480156103dd57600080fd5b506103e6610b2e565b6040516103c891906139cd565b3480156103ff57600080fd5b5061041361040e3660046139e0565b610bc0565b6040516001600160a01b0390911681526020016103c8565b34801561043757600080fd5b5061044b610446366004613a15565b610be7565b005b34801561045957600080fd5b506104646204000081565b60405163ffffffff90911681526020016103c8565b34801561048557600080fd5b5061044b610494366004613ae2565b610d02565b3480156104a557600080fd5b506099545b6040519081526020016103c8565b3480156104c457600080fd5b5061044b6104d3366004613b29565b610d7b565b3480156104e457600080fd5b50610464600881565b3480156104f957600080fd5b5061044b610508366004613bb0565b610deb565b34801561051957600080fd5b5061044b610528366004613bb0565b610e1c565b34801561053957600080fd5b5061054d610548366004613bec565b610e58565b604080516001600160a01b0390931683526020830191909152016103c8565b34801561057857600080fd5b5030600090815261015f60205260409020546104aa565b34801561059b57600080fd5b506104646208000081565b3480156105b257600080fd5b506103bc6105c1366004613c0e565b6101c3546001600160a01b0391821691161490565b3480156105e257600080fd5b506104aa6105f1366004613a15565b610e9b565b34801561060257600080fd5b5061044b610611366004613c0e565b610f31565b34801561062257600080fd5b5061044b610631366004613a15565b610ffa565b34801561064257600080fd5b5061044b610651366004613bb0565b611004565b34801561066257600080fd5b5061044b6106713660046139e0565b61101f565b61044b610684366004613c29565b611028565b34801561069557600080fd5b506103bc6106a43660046139e0565b6110de565b3480156106b557600080fd5b506104aa6106c43660046139e0565b6110fd565b3480156106d557600080fd5b506104aa611190565b3480156106ea57600080fd5b5061044b6106f9366004613c61565b611243565b34801561070a57600080fd5b506104136107193660046139e0565b6112c4565b34801561072a57600080fd5b506103e6611324565b34801561073f57600080fd5b506104aa61074e366004613c0e565b6113b3565b34801561075f57600080fd5b5061044b61076e366004613c96565b611439565b34801561077f57600080fd5b506103bc61078e3660046139e0565b61157b565b34801561079f57600080fd5b506104aa6107ae366004613c0e565b61015f6020526000908152604090205481565b3480156107cd57600080fd5b5061044b6107dc366004613cd4565b611595565b3480156107ed57600080fd5b5061044b6107fc366004613d2b565b6115a0565b34801561080d57600080fd5b506101c45461082490600160a01b900461ffff1681565b60405161ffff90911681526020016103c8565b34801561084357600080fd5b506104646201000081565b34801561085a57600080fd5b506101c354610413906001600160a01b031681565b34801561087b57600080fd5b50610464600281565b34801561089057600080fd5b5061044b61089f366004613c61565b61165c565b3480156108b057600080fd5b506103e66116dd565b3480156108c557600080fd5b506101c454610413906001600160a01b031681565b3480156108e657600080fd5b5061044b6108f5366004613a15565b6116ec565b34801561090657600080fd5b5061044b610915366004613d93565b6116f6565b34801561092657600080fd5b50610413611701565b34801561093b57600080fd5b5061044b61094a366004613a15565b611710565b34801561095b57600080fd5b506104aa600160fe1b81565b34801561097357600080fd5b506104aa600160ff1b81565b34801561098b57600080fd5b506104646210000081565b3480156109a257600080fd5b5061044b6109b1366004613dbf565b6117b9565b3480156109c257600080fd5b50610464600181565b3480156109d757600080fd5b506103bc6109e6366004613a15565b6117f1565b3480156109f757600080fd5b506103e6610a063660046139e0565b611817565b348015610a1757600080fd5b506104646220000081565b348015610a2e57600080fd5b5061044b610a3d3660046139e0565b611822565b348015610a4e57600080fd5b506104646202000081565b348015610a6557600080fd5b506103e661182c565b348015610a7a57600080fd5b506103bc610a89366004613e27565b61183a565b348015610a9a57600080fd5b5061044b610aa9366004613c0e565b611868565b348015610aba57600080fd5b50610464601081565b348015610acf57600080fd5b506104aa610ade366004613e5a565b61192b565b348015610aef57600080fd5b506103bc610afe3660046139e0565b611957565b60006001600160e01b0319821663152a902d60e11b1480610b285750610b2882611963565b92915050565b606060658054610b3d90613e8d565b80601f0160208091040260200160405190810160405280929190818152602001828054610b6990613e8d565b8015610bb65780601f10610b8b57610100808354040283529160200191610bb6565b820191906000526020600020905b815481529060010190602001808311610b9957829003601f168201915b5050505050905090565b6000610bcb826119a9565b506000908152606960205260409020546001600160a01b031690565b6000610bf2826112c4565b9050806001600160a01b0316836001600160a01b03161415610c655760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084015b60405180910390fd5b336001600160a01b0382161480610c815750610c81813361183a565b610cf35760405162461bcd60e51b815260206004820152603d60248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60448201527f6b656e206f776e6572206f7220617070726f76656420666f7220616c6c0000006064820152608401610c5c565b610cfd8383611a08565b505050565b610d0e62040000611957565b610d2a5760405162461bcd60e51b8152600401610c5c90613ec8565b336001600160a01b03167f7989fff0ffb34805e8b3574b890ed6157f85a384c69b9a0c04991b24cabb82598383604051610d65929190613eef565b60405180910390a2610d778282611a76565b5050565b82600114610dcb5760405162461bcd60e51b815260206004820152601d60248201527f7175616e74697479206d75737420626520657175616c20746f206f6e650000006044820152606401610c5c565b6000610dd78383611a80565b509050610de48582610ffa565b5050505050565b610df53382611c39565b610e115760405162461bcd60e51b8152600401610c5c90613f27565b610cfd838383611c98565b610e2862080000611957565b610e445760405162461bcd60e51b8152600401610c5c90613ec8565b610cfd6001600160a01b0384168383611e09565b6101c45460009081906001600160a01b0381169061271090610e8590600160a01b900461ffff1686613f8a565b610e8f9190613fa9565b915091505b9250929050565b6000610ea6836113b3565b8210610f085760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b6064820152608401610c5c565b506001600160a01b03919091166000908152609760209081526040808320938352929052205490565b306001600160a01b037f000000000000000000000000598df66beb0ea6bb59bedf40b18c0e361041d15b161415610f7a5760405162461bcd60e51b8152600401610c5c90613fcb565b7f000000000000000000000000598df66beb0ea6bb59bedf40b18c0e361041d15b6001600160a01b0316610fac611e5b565b6001600160a01b031614610fd25760405162461bcd60e51b8152600401610c5c90614017565b610fdb81611e77565b60408051600080825260208201909252610ff791839190611ea0565b50565b610d77828261200b565b610cfd838383604051806020016040528060008152506117b9565b610ff781612079565b306001600160a01b037f000000000000000000000000598df66beb0ea6bb59bedf40b18c0e361041d15b1614156110715760405162461bcd60e51b8152600401610c5c90613fcb565b7f000000000000000000000000598df66beb0ea6bb59bedf40b18c0e361041d15b6001600160a01b03166110a3611e5b565b6001600160a01b0316146110c95760405162461bcd60e51b8152600401610c5c90614017565b6110d282611e77565b610d7782826001611ea0565b6000818152606760205260408120546001600160a01b03161515610b28565b600061110860995490565b821061116b5760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b6064820152608401610c5c565b6099828154811061117e5761117e614063565b90600052602060002001549050919050565b6000306001600160a01b037f000000000000000000000000598df66beb0ea6bb59bedf40b18c0e361041d15b16146112305760405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c60448201527f6c6564207468726f7567682064656c656761746563616c6c00000000000000006064820152608401610c5c565b506000805160206143d883398151915290565b61124f62040000611957565b61126b5760405162461bcd60e51b8152600401610c5c90613ec8565b336001600160a01b03167fac455070f26733cc10c09e4389a74bf73bdb676d730ee31215c31d20daa88005610191836040516112a8929190614079565b60405180910390a28051610d7790610191906020840190613873565b6000818152606760205260408120546001600160a01b031680610b285760405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b6044820152606401610c5c565b610191805461133290613e8d565b80601f016020809104026020016040519081016040528092919081815260200182805461135e90613e8d565b80156113ab5780601f10611380576101008083540402835291602001916113ab565b820191906000526020600020905b81548152906001019060200180831161138e57829003601f168201915b505050505081565b60006001600160a01b03821661141d5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a2061646472657373207a65726f206973206e6f7420612076616044820152683634b21037bbb732b960b91b6064820152608401610c5c565b506001600160a01b031660009081526068602052604090205490565b61144562100000611957565b6114615760405162461bcd60e51b8152600401610c5c90613ec8565b6001600160a01b03821615158061147a575061ffff8116155b6114b95760405162461bcd60e51b815260206004820152601060248201526f34b73b30b634b2103932b1b2b4bb32b960811b6044820152606401610c5c565b6127108161ffff16111561150f5760405162461bcd60e51b815260206004820152601f60248201527f726f79616c74792070657263656e7461676520657863656564732031303025006044820152606401610c5c565b6101c480546001600160a01b0384166001600160b01b03199091168117600160a01b61ffff8516908102919091179092556040519182529033907f9ca088b6b695032bcd5d1fa450e8fa2773391294f09e3710ace940c4ae8cffac906020015b60405180910390a35050565b30600090815261015f602052604081205482168214610b28565b610cfd83838361220e565b600054610100900460ff16158080156115c05750600054600160ff909116105b806115da5750303b1580156115da575060005460ff166001145b6115f65760405162461bcd60e51b8152600401610c5c9061412c565b6000805460ff191660011790558015611619576000805461ff0019166101001790555b611624838333612241565b8015610cfd576000805461ff0019169055604051600181526000805160206143f88339815191529060200160405180910390a1505050565b61166862040000611957565b6116845760405162461bcd60e51b8152600401610c5c90613ec8565b8051611698906101c5906020840190613873565b50336001600160a01b03167f1ca91f64ead03abb06ea28975dfbf18044ac06f9fa1cb62a54ccc905df1028ed826040516116d291906139cd565b60405180910390a250565b606060668054610b3d90613e8d565b610d778282612312565b610d7733838361232c565b600061170b611e5b565b905090565b61171d600160ff1b611957565b6117395760405162461bcd60e51b8152600401610c5c90613ec8565b6001600160a01b038216600090815261015f602052604090205461175f9033908361192b565b6001600160a01b038316600081815261015f60205260409081902083905551909133917f5a10526456f5116c0b7b80582c217d666243fd51b6a2d92c8011e601c2462e5f9161156f91869190918252602082015260400190565b6117c33383611c39565b6117df5760405162461bcd60e51b8152600401610c5c90613f27565b6117eb848484846123fb565b50505050565b6001600160a01b038216600090815261015f6020526040812054821682145b9392505050565b6060610b288261242e565b610ff73082611710565b6101c5805461133290613e8d565b6001600160a01b039182166000908152606a6020908152604080832093909416825291909152205460ff1690565b61187462200000611957565b6118905760405162461bcd60e51b8152600401610c5c90613ec8565b6101c3546040516001600160a01b0380841692169033907fb9312e2100469bd44e3f762c248f4dcc8d7788906fabf34f79db45920c37e26990600090a46101c3546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a36101c380546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b0392909216600090815261015f60205260409020546000198084188216189216171690565b6000610b2833836117f1565b600061196e8261252a565b8061198957506001600160e01b031982166326e2e61760e01b145b80610b2857506001600160e01b03198216630852cd8d60e31b1492915050565b6000818152606760205260409020546001600160a01b0316610ff75760405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b6044820152606401610c5c565b600081815260696020526040902080546001600160a01b0319166001600160a01b0384169081179091558190611a3d826112c4565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b610d77828261254f565b600060606000611ade85858080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201829052506040805180820190915260018152601d60f91b6020820152935091506125e99050565b90506000811215611b285760405162461bcd60e51b815260206004820152601460248201527314d95c185c985d1bdc881b5d5cdd08195e1a5cdd60621b6044820152606401610c5c565b6000611b8286600187611b3b828761417a565b92611b4893929190614191565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061268192505050565b905060006003611b92848861417a565b611b9c919061417a565b905080611bc057816040518060200160405280600081525094509450505050610e94565b3660008888611bd08760026141bb565b90611bdc60018c61417a565b92611be993929190614191565b9150915083828281818080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250959f929e50919c50505050505050505050505050565b600080611c45836112c4565b9050806001600160a01b0316846001600160a01b03161480611c6c5750611c6c818561183a565b80611c905750836001600160a01b0316611c8584610bc0565b6001600160a01b0316145b949350505050565b826001600160a01b0316611cab826112c4565b6001600160a01b031614611cd15760405162461bcd60e51b8152600401610c5c906141d3565b6001600160a01b038216611d335760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610c5c565b611d408383836001612759565b826001600160a01b0316611d53826112c4565b6001600160a01b031614611d795760405162461bcd60e51b8152600401610c5c906141d3565b600081815260696020908152604080832080546001600160a01b03199081169091556001600160a01b0387811680865260688552838620805460001901905590871680865283862080546001019055868652606790945282852080549092168417909155905184937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052610cfd908490612863565b6000805160206143d8833981519152546001600160a01b031690565b611e84600160fe1b611957565b610ff75760405162461bcd60e51b8152600401610c5c90613ec8565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff1615611ed357610cfd8361291a565b826001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015611f2d575060408051601f3d908101601f19168201909252611f2a91810190614218565b60015b611f905760405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201526d6f6e206973206e6f74205555505360901b6064820152608401610c5c565b6000805160206143d88339815191528114611fff5760405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b6064820152608401610c5c565b50610cfd8383836129b6565b61201762010000611957565b6120335760405162461bcd60e51b8152600401610c5c90613ec8565b61203d82826129db565b60405181906001600160a01b0384169033907f9d228d69b5fdb8d273a2336f8fb8612d039631024ea9bf09c424a9503aa078f090600090a45050565b6000612084826112c4565b905061209262020000611957565b6121c9576001600160a01b038116331480156120b357506120b3600861157b565b806120d757506001600160a01b03811633148015906120d757506120d7601061157b565b6001600160a01b0382163314612122576040518060400160405280601c81526020017f6275726e73206f6e20626568616c66206172652064697361626c65640000000081525061214e565b60405180604001604052806012815260200171189d5c9b9cc8185c9948191a5cd8589b195960721b8152505b9061216c5760405162461bcd60e51b8152600401610c5c91906139cd565b50336001600160a01b038216148061219d575061218882610bc0565b6001600160a01b0316336001600160a01b0316145b806121ad57506121ad813361183a565b6121c95760405162461bcd60e51b8152600401610c5c90613ec8565b6121d282612b74565b60405182906001600160a01b0383169033907fe8a89cc6e5096f9d9f43de82c077c1f4cfe707c0e0c2032176c68813b9ae6a5c90600090a45050565b612218838361200b565b6122256000848484612bb4565b610cfd5760405162461bcd60e51b8152600401610c5c90614231565b600054610100900460ff16158080156122615750600054600160ff909116105b8061227b5750303b15801561227b575060005460ff166001145b6122975760405162461bcd60e51b8152600401610c5c9061412c565b6000805460ff1916600117905580156122ba576000805461ff0019166101001790555b6122c5848484612cb2565b6101c380546001600160a01b0319163317905580156117eb576000805461ff0019169055604051600181526000805160206143f8833981519152906020015b60405180910390a150505050565b610d7782826040518060200160405280600081525061220e565b816001600160a01b0316836001600160a01b0316141561238e5760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610c5c565b6001600160a01b038381166000818152606a6020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b612406848484611c98565b61241284848484612bb4565b6117eb5760405162461bcd60e51b8152600401610c5c90614231565b6060612439826119a9565b600082815260c960205260408120805461245290613e8d565b80601f016020809104026020016040519081016040528092919081815260200182805461247e90613e8d565b80156124cb5780601f106124a0576101008083540402835291602001916124cb565b820191906000526020600020905b8154815290600101906020018083116124ae57829003601f168201915b5050505050905060006124dc612d7e565b90508051600014156124ef575092915050565b815115612521578082604051602001612509929190614283565b60405160208183030381529060405292505050919050565b611c9084612d8e565b60006001600160e01b0319821663780e9d6360e01b1480610b285750610b2882612df4565b6000828152606760205260409020546001600160a01b03166125ca5760405162461bcd60e51b815260206004820152602e60248201527f45524337323155524953746f726167653a2055524920736574206f66206e6f6e60448201526d32bc34b9ba32b73a103a37b5b2b760911b6064820152608401610c5c565b600082815260c9602090815260409091208251610cfd92840190613873565b815160009083906001146125ff576125ff6142b2565b825b8551811015612674578160008151811061261d5761261d614063565b602001015160f81c60f81b6001600160f81b03191686828151811061264457612644614063565b01602001516001600160f81b03191614156126625791506118109050565b8061266c816142c8565b915050612601565b5060001995945050505050565b600080805b83518110156127525760008482815181106126a3576126a3614063565b016020015160f81c9050603081108015906126bf575060398111155b156126eb576126cf60308261417a565b6126da84600a613f8a565b6126e491906141bb565b925061273f565b60405162461bcd60e51b815260206004820152602360248201527f696e76616c696420696e7075742c206f6e6c79206e756d6265727320616c6c6f6044820152621dd95960ea1b6064820152608401610c5c565b508061274a816142c8565b915050612686565b5092915050565b6001600160a01b038416158061277657506001600160a01b038316155b8061279957506001600160a01b038416331480156127995750612799600161157b565b806127bd57506001600160a01b03841633148015906127bd57506127bd600261157b565b6001600160a01b0385163314612808576040518060400160405280602081526020017f7472616e7366657273206f6e20626568616c66206172652064697361626c6564815250612838565b604051806040016040528060168152602001751d1c985b9cd9995c9cc8185c9948191a5cd8589b195960521b8152505b906128565760405162461bcd60e51b8152600401610c5c91906139cd565b506117eb84848484612e44565b60006128b8826040518060400160405280601b81526020017f4552433230206c6f772d6c6576656c2063616c6c206661696c65640000000000815250856001600160a01b0316612f7d9092919063ffffffff16565b805190915015610cfd57808060200190518101906128d691906142e3565b610cfd5760405162461bcd60e51b8152602060048201526015602482015274115490cc8c081d1c985b9cd9995c8819985a5b1959605a1b6044820152606401610c5c565b6001600160a01b0381163b6129875760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608401610c5c565b6000805160206143d883398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b6129bf83612f8c565b6000825111806129cc5750805b15610cfd576117eb8383612fcc565b6001600160a01b038216612a315760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610c5c565b6000818152606760205260409020546001600160a01b031615612a965760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610c5c565b612aa4600083836001612759565b6000818152606760205260409020546001600160a01b031615612b095760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610c5c565b6001600160a01b038216600081815260686020908152604080832080546001019055848352606790915280822080546001600160a01b0319168417905551839291907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b612b7d816130c0565b600081815260c9602052604090208054612b9690613e8d565b159050610ff757600081815260c960205260408120610ff7916138f7565b60006001600160a01b0384163b15612ca757604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290612bf8903390899088908890600401614300565b6020604051808303816000875af1925050508015612c33575060408051601f3d908101601f19168201909252612c309181019061433d565b60015b612c8d573d808015612c61576040519150601f19603f3d011682016040523d82523d6000602084013e612c66565b606091505b508051612c855760405162461bcd60e51b8152600401610c5c90614231565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611c90565b506001949350505050565b600054610100900460ff1615808015612cd25750600054600160ff909116105b80612cec5750303b158015612cec575060005460ff166001145b612d085760405162461bcd60e51b8152600401610c5c9061412c565b6000805460ff191660011790558015612d2b576000805461ff0019166101001790555b612d358484613163565b612d3d613194565b612d45613194565b612d4e826131bd565b80156117eb576000805461ff0019169055604051600181526000805160206143f883398151915290602001612304565b60606101918054610b3d90613e8d565b6060612d99826119a9565b6000612da3612d7e565b90506000815111612dc35760405180602001604052806000815250611810565b80612dcd84613308565b604051602001612dde929190614283565b6040516020818303038152906040529392505050565b60006001600160e01b031982166380ac58cd60e01b1480612e2557506001600160e01b03198216635b5e139f60e01b145b80610b2857506301ffc9a760e01b6001600160e01b0319831614610b28565b612e50848484846133a5565b6001811115612ebf5760405162461bcd60e51b815260206004820152603560248201527f455243373231456e756d657261626c653a20636f6e7365637574697665207472604482015274185b9cd9995c9cc81b9bdd081cdd5c1c1bdc9d1959605a1b6064820152608401610c5c565b816001600160a01b038516612f1b57612f1681609980546000838152609a60205260408120829055600182018355919091527f72a152ddfb8e864297c917af52ea6c1c68aead0fee1a62673fcc7e0c94979d000155565b612f3e565b836001600160a01b0316856001600160a01b031614612f3e57612f3e858261342d565b6001600160a01b038416612f5a57612f55816134ca565b610de4565b846001600160a01b0316846001600160a01b031614610de457610de48482613579565b6060611c9084846000856135bd565b612f958161291a565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606001600160a01b0383163b6130345760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608401610c5c565b600080846001600160a01b03168460405161304f919061435a565b600060405180830381855af49150503d806000811461308a576040519150601f19603f3d011682016040523d82523d6000602084013e61308f565b606091505b50915091506130b7828260405180606001604052806027815260200161441860279139613698565b95945050505050565b60006130cb826112c4565b90506130db816000846001612759565b6130e4826112c4565b600083815260696020908152604080832080546001600160a01b03199081169091556001600160a01b0385168085526068845282852080546000190190558785526067909352818420805490911690555192935084927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b600054610100900460ff1661318a5760405162461bcd60e51b8152600401610c5c90614376565b610d7782826136b1565b600054610100900460ff166131bb5760405162461bcd60e51b8152600401610c5c90614376565b565b600054610100900460ff16158080156131dd5750600054600160ff909116105b806131f75750303b1580156131f7575060005460ff166001145b6132135760405162461bcd60e51b8152600401610c5c9061412c565b6000805460ff191660011790558015613236576000805461ff0019166101001790555b303b156132775760405162461bcd60e51b815260206004820152600f60248201526e1a5b9d985b1a590818dbdb9d195e1d608a1b6044820152606401610c5c565b6001600160a01b038216600081815261015f60209081526040918290206000199081905582518181529182015233917f5a10526456f5116c0b7b80582c217d666243fd51b6a2d92c8011e601c2462e5f910160405180910390a38015610d77576000805461ff0019169055604051600181526000805160206143f88339815191529060200160405180910390a15050565b60606000613315836136ff565b600101905060008167ffffffffffffffff81111561333557613335613a3f565b6040519080825280601f01601f19166020018201604052801561335f576020820181803683370190505b5090508181016020015b600019016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a85049450846133985761339d565b613369565b509392505050565b60018111156117eb576001600160a01b038416156133eb576001600160a01b038416600090815260686020526040812080548392906133e590849061417a565b90915550505b6001600160a01b038316156117eb576001600160a01b038316600090815260686020526040812080548392906134229084906141bb565b909155505050505050565b6000600161343a846113b3565b613444919061417a565b600083815260986020526040902054909150808214613497576001600160a01b03841660009081526097602090815260408083208584528252808320548484528184208190558352609890915290208190555b5060009182526098602090815260408084208490556001600160a01b039094168352609781528383209183525290812055565b6099546000906134dc9060019061417a565b6000838152609a60205260408120546099805493945090928490811061350457613504614063565b90600052602060002001549050806099838154811061352557613525614063565b6000918252602080832090910192909255828152609a9091526040808220849055858252812055609980548061355d5761355d6143c1565b6001900381819060005260206000200160009055905550505050565b6000613584836113b3565b6001600160a01b039093166000908152609760209081526040808320868452825280832085905593825260989052919091209190915550565b60608247101561361e5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610c5c565b600080866001600160a01b0316858760405161363a919061435a565b60006040518083038185875af1925050503d8060008114613677576040519150601f19603f3d011682016040523d82523d6000602084013e61367c565b606091505b509150915061368d878383876137d7565b979650505050505050565b606083156136a7575081611810565b6118108383613849565b600054610100900460ff166136d85760405162461bcd60e51b8152600401610c5c90614376565b81516136eb906065906020850190613873565b508051610cfd906066906020840190613873565b60008072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b831061373e5772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6d04ee2d6d415b85acef8100000000831061376a576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc10000831061378857662386f26fc10000830492506010015b6305f5e10083106137a0576305f5e100830492506008015b61271083106137b457612710830492506004015b606483106137c6576064830492506002015b600a8310610b285760010192915050565b6060831561384357825161383c576001600160a01b0385163b61383c5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610c5c565b5081611c90565b611c9083835b8151156138595781518083602001fd5b8060405162461bcd60e51b8152600401610c5c91906139cd565b82805461387f90613e8d565b90600052602060002090601f0160209004810192826138a157600085556138e7565b82601f106138ba57805160ff19168380011785556138e7565b828001600101855582156138e7579182015b828111156138e75782518255916020019190600101906138cc565b506138f392915061392d565b5090565b50805461390390613e8d565b6000825580601f10613913575050565b601f016020900490600052602060002090810190610ff791905b5b808211156138f3576000815560010161392e565b6001600160e01b031981168114610ff757600080fd5b60006020828403121561396a57600080fd5b813561181081613942565b60005b83811015613990578181015183820152602001613978565b838111156117eb5750506000910152565b600081518084526139b9816020860160208601613975565b601f01601f19169290920160200192915050565b60208152600061181060208301846139a1565b6000602082840312156139f257600080fd5b5035919050565b80356001600160a01b0381168114613a1057600080fd5b919050565b60008060408385031215613a2857600080fd5b613a31836139f9565b946020939093013593505050565b634e487b7160e01b600052604160045260246000fd5b600082601f830112613a6657600080fd5b813567ffffffffffffffff80821115613a8157613a81613a3f565b604051601f8301601f19908116603f01168101908282118183101715613aa957613aa9613a3f565b81604052838152866020858801011115613ac257600080fd5b836020870160208301376000602085830101528094505050505092915050565b60008060408385031215613af557600080fd5b82359150602083013567ffffffffffffffff811115613b1357600080fd5b613b1f85828601613a55565b9150509250929050565b60008060008060608587031215613b3f57600080fd5b613b48856139f9565b935060208501359250604085013567ffffffffffffffff80821115613b6c57600080fd5b818701915087601f830112613b8057600080fd5b813581811115613b8f57600080fd5b886020828501011115613ba157600080fd5b95989497505060200194505050565b600080600060608486031215613bc557600080fd5b613bce846139f9565b9250613bdc602085016139f9565b9150604084013590509250925092565b60008060408385031215613bff57600080fd5b50508035926020909101359150565b600060208284031215613c2057600080fd5b611810826139f9565b60008060408385031215613c3c57600080fd5b613c45836139f9565b9150602083013567ffffffffffffffff811115613b1357600080fd5b600060208284031215613c7357600080fd5b813567ffffffffffffffff811115613c8a57600080fd5b611c9084828501613a55565b60008060408385031215613ca957600080fd5b613cb2836139f9565b9150602083013561ffff81168114613cc957600080fd5b809150509250929050565b600080600060608486031215613ce957600080fd5b613cf2846139f9565b925060208401359150604084013567ffffffffffffffff811115613d1557600080fd5b613d2186828701613a55565b9150509250925092565b60008060408385031215613d3e57600080fd5b823567ffffffffffffffff80821115613d5657600080fd5b613d6286838701613a55565b93506020850135915080821115613d7857600080fd5b50613b1f85828601613a55565b8015158114610ff757600080fd5b60008060408385031215613da657600080fd5b613daf836139f9565b91506020830135613cc981613d85565b60008060008060808587031215613dd557600080fd5b613dde856139f9565b9350613dec602086016139f9565b925060408501359150606085013567ffffffffffffffff811115613e0f57600080fd5b613e1b87828801613a55565b91505092959194509250565b60008060408385031215613e3a57600080fd5b613e43836139f9565b9150613e51602084016139f9565b90509250929050565b600080600060608486031215613e6f57600080fd5b613e78846139f9565b95602085013595506040909401359392505050565b600181811c90821680613ea157607f821691505b60208210811415613ec257634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252600d908201526c1858d8d95cdcc819195b9a5959609a1b604082015260600190565b8281526060602082015260086060820152673d32b83832b634b760c11b608082015260a060408201526000611c9060a08301846139a1565b6020808252602d908201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560408201526c1c881bdc88185c1c1c9bdd9959609a1b606082015260800190565b634e487b7160e01b600052601160045260246000fd5b6000816000190483118215151615613fa457613fa4613f74565b500290565b600082613fc657634e487b7160e01b600052601260045260246000fd5b500490565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b19195b1959d85d1958d85b1b60a21b606082015260800190565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b6163746976652070726f787960a01b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b60408152600080845481600182811c91508083168061409957607f831692505b60208084108214156140b957634e487b7160e01b86526022600452602486fd5b60408801849052606088018280156140d857600181146140e957614114565b60ff19871682528282019750614114565b60008c81526020902060005b8781101561410e578154848201529086019084016140f5565b83019850505b50508786038189015250505050506130b781856139a1565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b60008282101561418c5761418c613f74565b500390565b600080858511156141a157600080fd5b838611156141ae57600080fd5b5050820193919092039150565b600082198211156141ce576141ce613f74565b500190565b60208082526025908201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060408201526437bbb732b960d91b606082015260800190565b60006020828403121561422a57600080fd5b5051919050565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b60008351614295818460208801613975565b8351908301906142a9818360208801613975565b01949350505050565b634e487b7160e01b600052600160045260246000fd5b60006000198214156142dc576142dc613f74565b5060010190565b6000602082840312156142f557600080fd5b815161181081613d85565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090614333908301846139a1565b9695505050505050565b60006020828403121561434f57600080fd5b815161181081613942565b6000825161436c818460208701613975565b9190910192915050565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b634e487b7160e01b600052603160045260246000fdfe360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212208c1f08599e092076142026adc04d27dd707e2da069840baf7172034b9de1150f64736f6c634300080b0033

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

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.