ETH Price: $3,907.08 (+6.46%)

Token

TerrapinUniverseVillains (TUV)
 

Overview

Max Total Supply

952 TUV

Holders

279

Market

Volume (24H)

N/A

Min Price (24H)

N/A

Max Price (24H)

N/A
Filtered by Token Holder
m3x1d0.eth
Balance
1 TUV
0xbAc5c05FEacef303D742BA8e32365bC37C51dC2C
Loading...
Loading
Loading...
Loading
Loading...
Loading

Click here to update the token information / general information
# Exchange Pair Price  24H Volume % Volume

Contract Source Code Verified (Exact Match)

Contract Name:
TerrapinUniverseVillains

Compiler Version
v0.8.9+commit.e5eed63a

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion, MIT license
File 1 of 21 : TerrapinUniverseVillains.sol
//SPDX-License-Identifier: MIT

/*
 ***************************************************************************************************************************
 *                                                                                                                         *
 * ___________                                     .__           ____ ___        .__                                       *
 * \__    ___/____ _______ _______ _____   ______  |__|  ____   |    |   \ ____  |__|___  __  ____ _______  ______  ____   *
 *   |    | _/ __ \\_  __ \\_  __ \\__  \  \____ \ |  | /    \  |    |   //    \ |  |\  \/ /_/ __ \\_  __ \/  ___/_/ __ \  *
 *   |    | \  ___/ |  | \/ |  | \/ / __ \_|  |_> >|  ||   |  \ |    |  /|   |  \|  | \   / \  ___/ |  | \/\___ \ \  ___/  *
 *   |____|  \___  >|__|    |__|   (____  /|   __/ |__||___|  / |______/ |___|  /|__|  \_/   \___  >|__|  /____  > \___  > *
 *               \/                     \/ |__|             \/                \/                 \/            \/      \/  *
 *                                                                                                                         *
 ***************************************************************************************************************************
 */

pragma solidity ^0.8.9;

import "./interfaces/TerrapinUniverse.sol";

/**
 * @title Terrapin Universe Villains
 *
 * @notice ERC-721 NFT Token Contract
 *
 * @author 0x1687572416fdd591bcc710fa07cee94a76eea201681884b1d5cc528cba584815
 */
contract TerrapinUniverseVillains is TerrapinUniverse {
    constructor(
        TerrapinGenesis terrapinGenesis_,
        TerrapinUniverseCardPack terrapinUniverseVillainsCardPack_,
        string memory baseURI_,
        address[] memory operators
    )
        TerrapinUniverse(
            "TerrapinUniverseVillains",
            "TUV",
            terrapinGenesis_,
            terrapinUniverseVillainsCardPack_,
            baseURI_,
            operators
        )
    {}
}

File 2 of 21 : AccessControl.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/AccessControl.sol)

pragma solidity ^0.8.0;

import "./IAccessControl.sol";
import "../utils/Context.sol";
import "../utils/Strings.sol";
import "../utils/introspection/ERC165.sol";

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

    mapping(bytes32 => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

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

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

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

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

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

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

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

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

        _revokeRole(role, account);
    }

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

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

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

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

File 3 of 21 : IAccessControl.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

File 4 of 21 : Ownable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)

pragma solidity ^0.8.0;

import "../utils/Context.sol";

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

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

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        _transferOwnership(_msgSender());
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
        _;
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}

File 5 of 21 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)

pragma solidity ^0.8.0;

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuard {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant _NOT_ENTERED = 1;
    uint256 private constant _ENTERED = 2;

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        // On the first call to nonReentrant, _notEntered will be true
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

        // Any calls to nonReentrant after this point will fail
        _status = _ENTERED;

        _;

        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = _NOT_ENTERED;
    }
}

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

pragma solidity ^0.8.0;

/**
 * @dev Collection of functions related to the address type
 */
library 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
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

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

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

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

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

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

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

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

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

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

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

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

    /**
     * @dev 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) {
        require(isContract(target), "Address: delegate call to non-contract");

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

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

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

File 7 of 21 : Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;

/**
 * @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 Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
}

File 8 of 21 : Strings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

File 9 of 21 : ECDSA.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/cryptography/ECDSA.sol)

pragma solidity ^0.8.0;

import "../Strings.sol";

/**
 * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
 *
 * These functions can be used to verify that a message was signed by the holder
 * of the private keys of a given address.
 */
library ECDSA {
    enum RecoverError {
        NoError,
        InvalidSignature,
        InvalidSignatureLength,
        InvalidSignatureS,
        InvalidSignatureV
    }

    function _throwError(RecoverError error) private pure {
        if (error == RecoverError.NoError) {
            return; // no error: do nothing
        } else if (error == RecoverError.InvalidSignature) {
            revert("ECDSA: invalid signature");
        } else if (error == RecoverError.InvalidSignatureLength) {
            revert("ECDSA: invalid signature length");
        } else if (error == RecoverError.InvalidSignatureS) {
            revert("ECDSA: invalid signature 's' value");
        } else if (error == RecoverError.InvalidSignatureV) {
            revert("ECDSA: invalid signature 'v' value");
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature` or error string. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     *
     * Documentation for signature generation:
     * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
     * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
     *
     * _Available since v4.3._
     */
    function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
        // Check the signature length
        // - case 65: r,s,v signature (standard)
        // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._
        if (signature.length == 65) {
            bytes32 r;
            bytes32 s;
            uint8 v;
            // ecrecover takes the signature parameters, and the only way to get them
            // currently is to use assembly.
            assembly {
                r := mload(add(signature, 0x20))
                s := mload(add(signature, 0x40))
                v := byte(0, mload(add(signature, 0x60)))
            }
            return tryRecover(hash, v, r, s);
        } else if (signature.length == 64) {
            bytes32 r;
            bytes32 vs;
            // ecrecover takes the signature parameters, and the only way to get them
            // currently is to use assembly.
            assembly {
                r := mload(add(signature, 0x20))
                vs := mload(add(signature, 0x40))
            }
            return tryRecover(hash, r, vs);
        } else {
            return (address(0), RecoverError.InvalidSignatureLength);
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature`. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     */
    function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, signature);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
     *
     * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
     *
     * _Available since v4.3._
     */
    function tryRecover(
        bytes32 hash,
        bytes32 r,
        bytes32 vs
    ) internal pure returns (address, RecoverError) {
        bytes32 s;
        uint8 v;
        assembly {
            s := and(vs, 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
            v := add(shr(255, vs), 27)
        }
        return tryRecover(hash, v, r, s);
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
     *
     * _Available since v4.2._
     */
    function recover(
        bytes32 hash,
        bytes32 r,
        bytes32 vs
    ) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, r, vs);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `v`,
     * `r` and `s` signature fields separately.
     *
     * _Available since v4.3._
     */
    function tryRecover(
        bytes32 hash,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal pure returns (address, RecoverError) {
        // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
        // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
        // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
        // signatures from current libraries generate a unique signature with an s-value in the lower half order.
        //
        // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
        // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
        // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
        // these malleable signatures as well.
        if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
            return (address(0), RecoverError.InvalidSignatureS);
        }
        if (v != 27 && v != 28) {
            return (address(0), RecoverError.InvalidSignatureV);
        }

        // If the signature is valid (and not malleable), return the signer address
        address signer = ecrecover(hash, v, r, s);
        if (signer == address(0)) {
            return (address(0), RecoverError.InvalidSignature);
        }

        return (signer, RecoverError.NoError);
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `v`,
     * `r` and `s` signature fields separately.
     */
    function recover(
        bytes32 hash,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, v, r, s);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Returns an Ethereum Signed Message, created from a `hash`. This
     * produces hash corresponding to the one signed with the
     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
     * JSON-RPC method as part of EIP-191.
     *
     * See {recover}.
     */
    function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
        // 32 is the length in bytes of hash,
        // enforced by the type signature above
        return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
    }

    /**
     * @dev Returns an Ethereum Signed Message, created from `s`. This
     * produces hash corresponding to the one signed with the
     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
     * JSON-RPC method as part of EIP-191.
     *
     * See {recover}.
     */
    function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s));
    }

    /**
     * @dev Returns an Ethereum Signed Typed Data, created from a
     * `domainSeparator` and a `structHash`. This produces hash corresponding
     * to the one signed with the
     * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
     * JSON-RPC method as part of EIP-712.
     *
     * See {recover}.
     */
    function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
    }
}

File 10 of 21 : draft-EIP712.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/cryptography/draft-EIP712.sol)

pragma solidity ^0.8.0;

import "./ECDSA.sol";

/**
 * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.
 *
 * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible,
 * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding
 * they need in their contracts using a combination of `abi.encode` and `keccak256`.
 *
 * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding
 * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA
 * ({_hashTypedDataV4}).
 *
 * The implementation of the domain separator was designed to be as efficient as possible while still properly updating
 * the chain id to protect against replay attacks on an eventual fork of the chain.
 *
 * NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method
 * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].
 *
 * _Available since v3.4._
 */
abstract contract EIP712 {
    /* solhint-disable var-name-mixedcase */
    // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to
    // invalidate the cached domain separator if the chain id changes.
    bytes32 private immutable _CACHED_DOMAIN_SEPARATOR;
    uint256 private immutable _CACHED_CHAIN_ID;
    address private immutable _CACHED_THIS;

    bytes32 private immutable _HASHED_NAME;
    bytes32 private immutable _HASHED_VERSION;
    bytes32 private immutable _TYPE_HASH;

    /* solhint-enable var-name-mixedcase */

    /**
     * @dev Initializes the domain separator and parameter caches.
     *
     * The meaning of `name` and `version` is specified in
     * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:
     *
     * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.
     * - `version`: the current major version of the signing domain.
     *
     * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart
     * contract upgrade].
     */
    constructor(string memory name, string memory version) {
        bytes32 hashedName = keccak256(bytes(name));
        bytes32 hashedVersion = keccak256(bytes(version));
        bytes32 typeHash = keccak256(
            "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"
        );
        _HASHED_NAME = hashedName;
        _HASHED_VERSION = hashedVersion;
        _CACHED_CHAIN_ID = block.chainid;
        _CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(typeHash, hashedName, hashedVersion);
        _CACHED_THIS = address(this);
        _TYPE_HASH = typeHash;
    }

    /**
     * @dev Returns the domain separator for the current chain.
     */
    function _domainSeparatorV4() internal view returns (bytes32) {
        if (address(this) == _CACHED_THIS && block.chainid == _CACHED_CHAIN_ID) {
            return _CACHED_DOMAIN_SEPARATOR;
        } else {
            return _buildDomainSeparator(_TYPE_HASH, _HASHED_NAME, _HASHED_VERSION);
        }
    }

    function _buildDomainSeparator(
        bytes32 typeHash,
        bytes32 nameHash,
        bytes32 versionHash
    ) private view returns (bytes32) {
        return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this)));
    }

    /**
     * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this
     * function returns the hash of the fully encoded EIP712 message for this domain.
     *
     * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:
     *
     * ```solidity
     * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(
     *     keccak256("Mail(address to,string contents)"),
     *     mailTo,
     *     keccak256(bytes(mailContents))
     * )));
     * address signer = ECDSA.recover(digest, signature);
     * ```
     */
    function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {
        return ECDSA.toTypedDataHash(_domainSeparatorV4(), structHash);
    }
}

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

pragma solidity ^0.8.0;

import "./IERC165.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 ERC165 is IERC165 {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}

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

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

File 13 of 21 : Math.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/math/Math.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

            return true;
        } else {
            return false;
        }
    }

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

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

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

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

    // Bytes32Set

    struct Bytes32Set {
        Set _inner;
    }

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

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

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

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

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

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

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

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

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

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

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

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

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

        assembly {
            result := store
        }

        return result;
    }

    // UintSet

    struct UintSet {
        Set _inner;
    }

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

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

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

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

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

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

        assembly {
            result := store
        }

        return result;
    }
}

File 15 of 21 : TerrapinGenesis.sol
//SPDX-License-Identifier: MIT

/*
 ************************************************************************************************************************
 *                                                                                                                      *
 * ___________                                     .__            ________                                 .__          *
 * \__    ___/____ _______ _______ _____   ______  |__|  ____    /  _____/   ____    ____    ____    ______|__|  ______ *
 *   |    | _/ __ \\_  __ \\_  __ \\__  \  \____ \ |  | /    \  /   \  ___ _/ __ \  /    \ _/ __ \  /  ___/|  | /  ___/ *
 *   |    | \  ___/ |  | \/ |  | \/ / __ \_|  |_> >|  ||   |  \ \    \_\  \\  ___/ |   |  \\  ___/  \___ \ |  | \___ \  *
 *   |____|  \___  >|__|    |__|   (____  /|   __/ |__||___|  /  \______  / \___  >|___|  / \___  >/____  >|__|/____  > *
 *               \/                     \/ |__|             \/          \/      \/      \/      \/      \/          \/  *
 *                                                                                                                      *
 ************************************************************************************************************************
 */

pragma solidity ^0.8.9;

import "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/utils/cryptography/draft-EIP712.sol";
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import "erc721a/contracts/extensions/ERC721AQueryable.sol";

error MintNotActive();
error MaxSupplyExceeded();
error InvalidSignature();
error AccountPreviouslyMinted();
error InvalidValue();
error ValueUnchanged();

contract OSOwnableDelegateProxy {}

contract OSProxyRegistry {
    mapping(address => OSOwnableDelegateProxy) public proxies;
}

/**
 * @title Terrapin Genesis
 *
 * @notice ERC-721 NFT Token Contract.
 *
 * @author 0x1687572416fdd591bcc710fa07cee94a76eea201681884b1d5cc528cba584815
 */
contract TerrapinGenesis is Ownable, AccessControl, EIP712, ERC721AQueryable {
    using Address for address payable;
    using ECDSA for bytes32;

    bytes32 public constant OPERATOR_ROLE = keccak256("OPERATOR_ROLE");
    bytes32 public constant MINT_SIGNER_ROLE = keccak256("MINT_SIGNER_ROLE");
    bytes32 public constant WHITELIST_TYPEHASH =
        keccak256("Whitelist(address account)");
    uint256 public constant maxSupply = 333;

    bool public mintActive;
    string public baseURI;

    OSProxyRegistry internal _osProxyRegistry;

    event MintActiveUpdated(bool mintActive);
    event BaseURIUpdated(string oldBaseURI, string baseURI);

    constructor(
        string memory baseURI_,
        address osProxyRegistryAddress,
        address[] memory operators,
        address[] memory mintSigners
    ) EIP712("TerrapinGenesis", "1") ERC721A("TerrapinGenesis", "TG") {
        baseURI = baseURI_;
        _osProxyRegistry = OSProxyRegistry(osProxyRegistryAddress);

        _grantRole(DEFAULT_ADMIN_ROLE, _msgSender());
        for (uint256 index = 0; index < operators.length; ++index) {
            _grantRole(OPERATOR_ROLE, operators[index]);
        }
        for (uint256 index = 0; index < mintSigners.length; ++index) {
            _grantRole(MINT_SIGNER_ROLE, mintSigners[index]);
        }
    }

    /**
     * @dev Mint function, only whitelisted accounts allowed. With a valid
     * signature from an account with a MINT_SIGNER_ROLE role, accounts may mint
     * up to 1 token.
     */
    function mint(bytes calldata sig) external {
        if (mintActive != true) revert MintNotActive();
        if (numberMinted(_msgSender()) > 0) revert AccountPreviouslyMinted();
        if ((_totalMinted() + 1) > maxSupply) revert MaxSupplyExceeded();

        bytes32 digest = _hashTypedDataV4(
            keccak256(abi.encode(WHITELIST_TYPEHASH, _msgSender()))
        );
        address signer = ECDSA.recover(digest, sig);
        if (hasRole(MINT_SIGNER_ROLE, signer) != true)
            revert InvalidSignature();

        _safeMint(_msgSender(), 1);
    }

    /**
     * @dev Special Mint function. For miscellaneous purposes, e.g. raffles.
     */
    function mintSpecial(address[] calldata addresses)
        external
        onlyRole(OPERATOR_ROLE)
    {
        if (_totalMinted() + addresses.length > maxSupply)
            revert MaxSupplyExceeded();

        for (uint256 index = 0; index < addresses.length; ++index) {
            _safeMint(addresses[index], 1);
        }
    }

    /**
     * @dev Reserve Mint function.
     */
    function mintReserve(address to, uint256 quantity)
        external
        onlyRole(OPERATOR_ROLE)
    {
        if (_totalMinted() + quantity > maxSupply) revert MaxSupplyExceeded();

        _safeMint(to, quantity);
    }

    function setMintActive(bool mintActive_) external onlyRole(OPERATOR_ROLE) {
        if (mintActive == mintActive_) revert ValueUnchanged();

        mintActive = mintActive_;

        emit MintActiveUpdated(mintActive);
    }

    function setBaseURI(string memory baseURI_)
        external
        onlyRole(OPERATOR_ROLE)
    {
        if (
            keccak256(abi.encodePacked(baseURI_)) ==
            keccak256(abi.encodePacked(_baseURI()))
        ) revert ValueUnchanged();

        string memory oldBaseURI = _baseURI();
        baseURI = baseURI_;

        emit BaseURIUpdated(oldBaseURI, baseURI_);
    }

    function withdraw() external onlyRole(DEFAULT_ADMIN_ROLE) {
        payable(_msgSender()).sendValue(address(this).balance);
    }

    /**
     * @dev Number of tokens minted.
     */
    function totalMinted() external view returns (uint256) {
        return _totalMinted();
    }

    /**
     * @dev Returns number of tokens `account` has minted.
     */
    function numberMinted(address account) public view returns (uint256) {
        return _numberMinted(account);
    }

    function isApprovedForAll(address owner_, address operator)
        public
        view
        override
        returns (bool)
    {
        if (super.isApprovedForAll(owner_, operator)) {
            return true;
        }

        if (
            address(_osProxyRegistry) != address(0) &&
            address(_osProxyRegistry.proxies(owner_)) == operator
        ) {
            return true;
        }

        return false;
    }

    function supportsInterface(bytes4 interfaceId)
        public
        view
        override(AccessControl, ERC721A)
        returns (bool)
    {
        return
            ERC721A.supportsInterface(interfaceId) ||
            AccessControl.supportsInterface(interfaceId);
    }

    function _baseURI() internal view override returns (string memory) {
        return baseURI;
    }

    function _startTokenId() internal pure override returns (uint256) {
        return 1;
    }
}

File 16 of 21 : TerrapinUniverse.sol
//SPDX-License-Identifier: MIT

/*
 ***************************************************************************************************************************
 *                                                                                                                         *
 * ___________                                     .__           ____ ___        .__                                       *
 * \__    ___/____ _______ _______ _____   ______  |__|  ____   |    |   \ ____  |__|___  __  ____ _______  ______  ____   *
 *   |    | _/ __ \\_  __ \\_  __ \\__  \  \____ \ |  | /    \  |    |   //    \ |  |\  \/ /_/ __ \\_  __ \/  ___/_/ __ \  *
 *   |    | \  ___/ |  | \/ |  | \/ / __ \_|  |_> >|  ||   |  \ |    |  /|   |  \|  | \   / \  ___/ |  | \/\___ \ \  ___/  *
 *   |____|  \___  >|__|    |__|   (____  /|   __/ |__||___|  / |______/ |___|  /|__|  \_/   \___  >|__|  /____  > \___  > *
 *               \/                     \/ |__|             \/                \/                 \/            \/      \/  *
 *                                                                                                                         *
 ***************************************************************************************************************************
 */

pragma solidity ^0.8.9;

import {TerrapinGenesis, MintNotActive, MaxSupplyExceeded, InvalidSignature, AccountPreviouslyMinted, InvalidValue, ValueUnchanged} from "../TerrapinGenesis.sol";
import "./TerrapinUniverseCardPack.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import "erc721a/contracts/extensions/ERC721AQueryable.sol";

/**
 * @title Terrapin Universe
 *
 * @notice ERC-721 NFT Token Contract.
 *
 * @author 0x1687572416fdd591bcc710fa07cee94a76eea201681884b1d5cc528cba584815
 */
abstract contract TerrapinUniverse is
    Ownable,
    AccessControl,
    ReentrancyGuard,
    ERC721AQueryable
{
    using Address for address payable;
    using EnumerableSet for EnumerableSet.UintSet;

    bytes32 public constant OPERATOR_ROLE = keccak256("OPERATOR_ROLE");
    uint256 public constant maxSupply = 2000;
    uint256 public constant START_TOKEN_ID = 1;
    uint256 public constant STAKE_START_THRESHOLD_DAYS = 3;
    address public constant NULL_ADDRESS = address(0);
    address public constant OS_CONDUIT_ADDRESS =
        0x1E0049783F008A0085193E00003D00cd54003c71;
    TerrapinGenesis public immutable terrapinGenesis;

    uint256[] public LEVEL_EXP_DAYS = [0, 14, 44, 134, 254];
    TerrapinUniverseCardPack public terrapinUniverseCardPack;

    bool public mintActive;
    string public baseURI;
    mapping(uint256 => uint256) public tokenIdToCardPackTokenId;
    mapping(uint256 => uint256) public tokenIdToRawLevelAtLastTransfer;

    EnumerableSet.UintSet internal _usedCardPackTokenIds;

    event MintActiveUpdated(bool mintActive);
    event BaseURIUpdated(string oldBaseURI, string baseURI);
    event CardPackUpdated(
        address oldTerrapinUniverseCardPack,
        address terrapinUniverseCardPack
    );

    error InvalidCardPackTokenIds();
    error InvalidTerrapinUniverseCardPackAddress();

    constructor(
        string memory name_,
        string memory symbol_,
        TerrapinGenesis terrapinGenesis_,
        TerrapinUniverseCardPack terrapinUniverseCardPack_,
        string memory baseURI_,
        address[] memory operators
    ) ERC721A(name_, symbol_) {
        terrapinGenesis = terrapinGenesis_;
        terrapinUniverseCardPack = terrapinUniverseCardPack_;
        baseURI = baseURI_;

        _grantRole(DEFAULT_ADMIN_ROLE, _msgSender());
        for (uint256 index = 0; index < operators.length; ++index) {
            _grantRole(OPERATOR_ROLE, operators[index]);
        }
    }

    /**
     * @notice Redeem function, open to Terrapin Universe Card Pack holders.
     * Each card pack nets the message sender 1 Terrapin Universe token.
     * Card Pack tokens are BURNED and removed from owners wallet.
     *
     * For generating `cardPackTokenIds`, see
     * {TerrapinUniverse-eligibleCardPackTokenIdsOf}.
     */
    function redeem(uint256[] calldata cardPackTokenIds) external {
        redeemTo(_msgSender(), cardPackTokenIds);
    }

    function setMintActive(bool mintActive_) external onlyRole(OPERATOR_ROLE) {
        if (mintActive == mintActive_) revert ValueUnchanged();

        mintActive = mintActive_;

        emit MintActiveUpdated(mintActive);
    }

    function setBaseURI(string calldata baseURI_)
        external
        onlyRole(OPERATOR_ROLE)
    {
        if (
            keccak256(abi.encodePacked(baseURI_)) ==
            keccak256(abi.encodePacked(_baseURI()))
        ) revert ValueUnchanged();

        string memory oldBaseURI = _baseURI();
        baseURI = baseURI_;

        emit BaseURIUpdated(oldBaseURI, baseURI_);
    }

    function setCardPack(TerrapinUniverseCardPack terrapinUniverseCardPack_)
        external
        onlyRole(OPERATOR_ROLE)
    {
        if (terrapinUniverseCardPack == terrapinUniverseCardPack_)
            revert ValueUnchanged();

        TerrapinUniverseCardPack oldTerrapinUniverseCardPack = terrapinUniverseCardPack;
        terrapinUniverseCardPack = terrapinUniverseCardPack_;

        emit CardPackUpdated(
            address(oldTerrapinUniverseCardPack),
            address(terrapinUniverseCardPack)
        );
    }

    function withdraw() external onlyRole(DEFAULT_ADMIN_ROLE) {
        payable(_msgSender()).sendValue(address(this).balance);
    }

    function totalMinted() external view returns (uint256) {
        return _totalMinted();
    }

    function numberMinted(address account) external view returns (uint256) {
        return _numberMinted(account);
    }

    function usedCardPackTokenIds() external view returns (uint256[] memory) {
        return _usedCardPackTokenIds.values();
    }

    function levelOf(uint256 tokenId) external view returns (uint256) {
        return _levelOf(tokenId, true);
    }

    function rawLevelOf(uint256 tokenId) external view returns (uint256) {
        return _levelOf(tokenId, false);
    }

    function tokenDetailOf(uint256 tokenId)
        external
        view
        returns (
            TokenOwnership memory,
            uint256,
            uint256
        )
    {
        TokenOwnership memory ownership = _ownershipOf(tokenId);
        uint256 level = _levelOf(tokenId, true);
        uint256 rawLevel = _levelOf(tokenId, false);

        return (ownership, level, rawLevel);
    }

    function eligibleCardPackTokenIdsOf(address account)
        external
        view
        returns (uint256[] memory)
    {
        if (address(terrapinUniverseCardPack) == NULL_ADDRESS)
            revert InvalidTerrapinUniverseCardPackAddress();

        uint256[] memory tokenIds = terrapinUniverseCardPack.tokensOfOwner(
            account
        );
        uint256[] memory eligibleTokenIdsWithPadding = new uint256[](
            tokenIds.length
        );

        uint256 numberOfEligibleTokenIds = 0;
        for (
            uint256 tokenIdIndex = 0;
            tokenIdIndex < eligibleTokenIdsWithPadding.length;
            ++tokenIdIndex
        ) {
            uint256 tokenId = tokenIds[tokenIdIndex];

            bool hasNotBeenRedeemed = _usedCardPackTokenIds.contains(tokenId) !=
                true;

            if (hasNotBeenRedeemed) {
                eligibleTokenIdsWithPadding[numberOfEligibleTokenIds] = tokenId;
                ++numberOfEligibleTokenIds;
            }
        }

        uint256[] memory eligibleTokenIds = new uint256[](
            numberOfEligibleTokenIds
        );
        for (uint256 index = 0; index < numberOfEligibleTokenIds; ++index) {
            eligibleTokenIds[index] = eligibleTokenIdsWithPadding[index];
        }

        return eligibleTokenIds;
    }

    function redeemTo(address to, uint256[] calldata cardPackTokenIds)
        public
        nonReentrant
    {
        if (mintActive != true) revert MintNotActive();
        if (address(terrapinUniverseCardPack) == NULL_ADDRESS)
            revert InvalidTerrapinUniverseCardPackAddress();
        if (_canMintAdditional(cardPackTokenIds.length) != true)
            revert MaxSupplyExceeded();
        if (
            _areCardPackTokenIdsEligible(cardPackTokenIds, _msgSender()) != true
        ) revert InvalidCardPackTokenIds();

        _redeem(to, cardPackTokenIds);
    }

    function isCardPackTokenIdUsed(uint256 tokenId) public view returns (bool) {
        return _usedCardPackTokenIds.contains(tokenId);
    }

    function isApprovedForAll(address owner_, address operator)
        public
        view
        override
        returns (bool)
    {
        if (super.isApprovedForAll(owner_, operator)) {
            return true;
        }

        if (operator == OS_CONDUIT_ADDRESS) {
            return true;
        }

        return false;
    }

    function supportsInterface(bytes4 interfaceId)
        public
        view
        override(AccessControl, ERC721A)
        returns (bool)
    {
        return
            super.supportsInterface(interfaceId) ||
            AccessControl.supportsInterface(interfaceId);
    }

    function _redeem(address to, uint256[] calldata cardPackTokenIds) internal {
        for (uint256 index = 0; index < cardPackTokenIds.length; ++index) {
            uint256 cardPackTokenId = cardPackTokenIds[index];
            uint256 thisTokenId = _nextTokenId() + index;

            tokenIdToCardPackTokenId[thisTokenId] = cardPackTokenId;
            _usedCardPackTokenIds.add(cardPackTokenId);
        }

        terrapinUniverseCardPack.burn(cardPackTokenIds);
        _safeMint(to, cardPackTokenIds.length);
    }

    function _beforeTokenTransfers(
        address from,
        address,
        uint256 startTokenId,
        uint256 quantity
    ) internal override {
        for (uint256 index = 0; index < quantity; ++index) {
            uint256 tokenId = startTokenId + index;

            if (from != address(0x0)) {
                tokenIdToRawLevelAtLastTransfer[tokenId] = _levelOf(
                    tokenId,
                    false
                );
            }
        }
    }

    function _baseURI() internal view override returns (string memory) {
        return baseURI;
    }

    function _canMintAdditional(uint256 count) internal view returns (bool) {
        return (_totalMinted() + count) <= maxSupply;
    }

    function _startTokenId() internal pure override returns (uint256) {
        return START_TOKEN_ID;
    }

    function _levelOf(uint256 tokenId, bool applyGen1OwnershipBoost)
        internal
        view
        returns (uint256)
    {
        uint256 level = tokenIdToRawLevelAtLastTransfer[tokenId];
        if (level >= LEVEL_EXP_DAYS.length) {
            return level;
        }

        TokenOwnership memory ownership = _ownershipOf(tokenId);
        uint256 numberOfDaysOwnedByCurrentOwner = (block.timestamp -
            ownership.startTimestamp) / (1 days);

        if (numberOfDaysOwnedByCurrentOwner < STAKE_START_THRESHOLD_DAYS) {
            return level;
        }

        uint256 numGen1TokensOwned = terrapinGenesis.balanceOf(ownership.addr);
        uint256 multiplier = 1 +
            (applyGen1OwnershipBoost ? numGen1TokensOwned : 0);
        uint256 eligibleNumDaysExperience = LEVEL_EXP_DAYS[level] +
            numberOfDaysOwnedByCurrentOwner -
            STAKE_START_THRESHOLD_DAYS;
        uint256 experienceInDays = multiplier * eligibleNumDaysExperience;

        while (
            level < LEVEL_EXP_DAYS.length &&
            experienceInDays >= LEVEL_EXP_DAYS[level]
        ) {
            ++level;
        }

        return level;
    }

    function _areCardPackTokenIdsEligible(
        uint256[] calldata cardPackTokenIds,
        address account
    ) private view returns (bool) {
        if (address(terrapinUniverseCardPack) == NULL_ADDRESS)
            revert InvalidTerrapinUniverseCardPackAddress();

        bool eligible = true;

        bool[] memory duplicatesCheck = new bool[](
            terrapinUniverseCardPack.maxSupply()
        );

        for (
            uint256 index = 0;
            index < cardPackTokenIds.length && eligible;
            ++index
        ) {
            uint256 cardPackTokenId = cardPackTokenIds[index];
            uint256 duplicateCheckIndex = cardPackTokenId - _startTokenId();
            bool isContractOperatorOrTokenOwner = hasRole(
                OPERATOR_ROLE,
                account
            ) || terrapinUniverseCardPack.ownerOf(cardPackTokenId) == account;
            bool tokenIdIsUnused = isCardPackTokenIdUsed(cardPackTokenId) !=
                true;
            bool isNotDuplicate = duplicatesCheck[duplicateCheckIndex] == false;

            eligible =
                isContractOperatorOrTokenOwner &&
                tokenIdIsUnused &&
                isNotDuplicate;
            duplicatesCheck[duplicateCheckIndex] = true;
        }

        return eligible;
    }
}

File 17 of 21 : TerrapinUniverseCardPack.sol
//SPDX-License-Identifier: MIT

/*
 ***************************************************************************************************************************
 *                                                                                                                         *
 * ___________                                     .__           ____ ___        .__                                       *
 * \__    ___/____ _______ _______ _____   ______  |__|  ____   |    |   \ ____  |__|___  __  ____ _______  ______  ____   *
 *   |    | _/ __ \\_  __ \\_  __ \\__  \  \____ \ |  | /    \  |    |   //    \ |  |\  \/ /_/ __ \\_  __ \/  ___/_/ __ \  *
 *   |    | \  ___/ |  | \/ |  | \/ / __ \_|  |_> >|  ||   |  \ |    |  /|   |  \|  | \   / \  ___/ |  | \/\___ \ \  ___/  *
 *   |____|  \___  >|__|    |__|   (____  /|   __/ |__||___|  / |______/ |___|  /|__|  \_/   \___  >|__|  /____  > \___  > *
 *               \/                     \/ |__|             \/                \/                 \/            \/      \/  *
 *                                                                                                                         *
 ***************************************************************************************************************************
 */

pragma solidity ^0.8.9;

import {TerrapinGenesis, MintNotActive, MaxSupplyExceeded, InvalidSignature, AccountPreviouslyMinted, InvalidValue, ValueUnchanged} from "../TerrapinGenesis.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/utils/math/Math.sol";
import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import "erc721a/contracts/extensions/ERC721AQueryable.sol";

enum TokenOrigin {
    Unknown,
    Gen1,
    WL,
    HeroRedemption
}

/**
 * @title Terrapin Universe Card Pack
 *
 * @notice ERC-721 NFT Token Contract.
 *
 * @author 0x1687572416fdd591bcc710fa07cee94a76eea201681884b1d5cc528cba584815
 */
abstract contract TerrapinUniverseCardPack is
    Ownable,
    AccessControl,
    ReentrancyGuard,
    ERC721AQueryable
{
    using Address for address payable;
    using EnumerableSet for EnumerableSet.UintSet;

    bytes32 public constant OPERATOR_ROLE = keccak256("OPERATOR_ROLE");
    bytes32 public constant REDEEMER_ROLE = keccak256("REDEEMER_ROLE");
    uint256 public constant MINT_COUNT_PER_GEN1 = 2;
    uint256 public constant START_TOKEN_ID = 1;
    uint256 public constant maxSupply = 2000;
    address public constant NULL_ADDRESS = address(0);
    address public constant OS_CONDUIT_ADDRESS =
        0x1E0049783F008A0085193E00003D00cd54003c71;
    TerrapinGenesis public immutable terrapinGenesis;

    bool public mintActive;
    string public baseURI;

    EnumerableSet.UintSet internal _usedGen1TokenIds;

    event MintActiveUpdated(bool mintActive);
    event BaseURIUpdated(string oldBaseURI, string baseURI);

    error InvalidGen1TokenIds();
    error InvalidTokenId();
    error InvalidTerrapinGenesisAddress();

    constructor(
        string memory name_,
        string memory symbol_,
        TerrapinGenesis terrapinGenesis_,
        string memory baseURI_,
        address[] memory operators
    ) ERC721A(name_, symbol_) {
        terrapinGenesis = terrapinGenesis_;
        baseURI = baseURI_;

        _grantRole(DEFAULT_ADMIN_ROLE, _msgSender());
        for (uint256 index = 0; index < operators.length; ++index) {
            _grantRole(OPERATOR_ROLE, operators[index]);
        }
    }

    function burn(uint256[] calldata tokenIds)
        external
        onlyRole(REDEEMER_ROLE)
    {
        for (uint256 index = 0; index < tokenIds.length; ++index) {
            uint256 tokenId = tokenIds[index];

            _burn(tokenId, false);
        }
    }

    function setMintActive(bool mintActive_) external onlyRole(OPERATOR_ROLE) {
        if (mintActive == mintActive_) revert ValueUnchanged();

        mintActive = mintActive_;

        emit MintActiveUpdated(mintActive);
    }

    function setBaseURI(string calldata baseURI_)
        external
        onlyRole(OPERATOR_ROLE)
    {
        if (
            keccak256(abi.encodePacked(baseURI_)) ==
            keccak256(abi.encodePacked(_baseURI()))
        ) revert ValueUnchanged();

        string memory oldBaseURI = _baseURI();
        baseURI = baseURI_;

        emit BaseURIUpdated(oldBaseURI, baseURI_);
    }

    function withdraw() external onlyRole(DEFAULT_ADMIN_ROLE) {
        payable(_msgSender()).sendValue(address(this).balance);
    }

    function totalMinted() external view returns (uint256) {
        return _totalMinted();
    }

    function numberMinted(address account) external view returns (uint256) {
        return _numberMinted(account);
    }

    function usedGen1TokenIds() external view returns (uint256[] memory) {
        return _usedGen1TokenIds.values();
    }

    function originOf(uint256 tokenId)
        external
        view
        virtual
        returns (TokenOrigin);

    /**
     * @notice Used to calculate valid and unused gen1TokenIds for the
     * given `account` off-chain. The results of this function may be
     * safely passed to {mint}.
     */
    function eligibleGen1TokenIdsOf(address account)
        external
        view
        returns (uint256[] memory)
    {
        if (address(terrapinGenesis) == NULL_ADDRESS)
            revert InvalidTerrapinGenesisAddress();

        uint256[] memory tokenIds = terrapinGenesis.tokensOfOwner(account);
        uint256[] memory eligibleTokenIdsWithPadding = new uint256[](
            tokenIds.length
        );

        uint256 numberOfEligibleTokenIds = 0;
        for (
            uint256 tokenIdIndex = 0;
            tokenIdIndex < eligibleTokenIdsWithPadding.length;
            ++tokenIdIndex
        ) {
            uint256 tokenId = tokenIds[tokenIdIndex];
            if (isGen1TokenIdUsed(tokenId) != true) {
                eligibleTokenIdsWithPadding[numberOfEligibleTokenIds] = tokenId;
                ++numberOfEligibleTokenIds;
            }
        }

        uint256[] memory eligibleTokenIds = new uint256[](
            numberOfEligibleTokenIds
        );
        for (uint256 index = 0; index < numberOfEligibleTokenIds; ++index) {
            eligibleTokenIds[index] = eligibleTokenIdsWithPadding[index];
        }

        return eligibleTokenIds;
    }

    function isGen1TokenIdUsed(uint256 tokenId) public view returns (bool) {
        return _usedGen1TokenIds.contains(tokenId);
    }

    function isApprovedForAll(address owner_, address operator)
        public
        view
        override
        returns (bool)
    {
        if (super.isApprovedForAll(owner_, operator)) {
            return true;
        }

        if (operator == OS_CONDUIT_ADDRESS) {
            return true;
        }

        return false;
    }

    function supportsInterface(bytes4 interfaceId)
        public
        view
        override(AccessControl, ERC721A)
        returns (bool)
    {
        return
            super.supportsInterface(interfaceId) ||
            AccessControl.supportsInterface(interfaceId);
    }

    function _mintViaGen1(address to, uint256[] calldata tokenIds) internal {
        uint256 numberToMint = MINT_COUNT_PER_GEN1;
        for (
            uint256 mintIndex = 0;
            mintIndex < tokenIds.length && numberToMint == MINT_COUNT_PER_GEN1;
            ++mintIndex
        ) {
            numberToMint = _allowableMintAmount(MINT_COUNT_PER_GEN1);
            if (numberToMint > 0) {
                _usedGen1TokenIds.add(tokenIds[mintIndex]);
                _safeMint(to, numberToMint);
            }
        }
    }

    function _baseURI() internal view override returns (string memory) {
        return baseURI;
    }

    function _soldOut() internal view returns (bool) {
        return _totalMinted() >= maxSupply;
    }

    function _allowableMintAmount(uint256 targetAmount)
        internal
        view
        returns (uint256)
    {
        uint256 remainingMintableAmount = maxSupply - _totalMinted();
        return Math.min(targetAmount, remainingMintableAmount);
    }

    function _hasMintedTokenId(uint256 tokenId) internal view returns (bool) {
        return tokenId >= _startTokenId() && tokenId < _nextTokenId();
    }

    function _startTokenId() internal pure override returns (uint256) {
        return START_TOKEN_ID;
    }

    function _areGen1TokenIdsEligible(
        uint256[] calldata tokenIds,
        address account
    ) internal view returns (bool) {
        if (address(terrapinGenesis) == NULL_ADDRESS)
            revert InvalidTerrapinGenesisAddress();

        bool eligible = true;

        bool[] memory duplicatesCheck = new bool[](terrapinGenesis.maxSupply());

        for (uint256 index = 0; index < tokenIds.length && eligible; ++index) {
            uint256 tokenId = tokenIds[index];
            uint256 duplicateCheckIndex = tokenId - _startTokenId();
            bool isContractOperatorOrTokenOwner = hasRole(
                OPERATOR_ROLE,
                account
            ) || terrapinGenesis.ownerOf(tokenId) == account;
            bool tokenIdIsUnused = _usedGen1TokenIds.contains(tokenId) != true;
            bool isNotDuplicate = duplicatesCheck[duplicateCheckIndex] == false;

            eligible =
                isContractOperatorOrTokenOwner &&
                tokenIdIsUnused &&
                isNotDuplicate;
            duplicatesCheck[duplicateCheckIndex] = true;
        }

        return eligible;
    }
}

File 18 of 21 : ERC721A.sol
// SPDX-License-Identifier: MIT
// ERC721A Contracts v4.2.3
// Creator: Chiru Labs

pragma solidity ^0.8.4;

import './IERC721A.sol';

/**
 * @dev Interface of ERC721 token receiver.
 */
interface ERC721A__IERC721Receiver {
    function onERC721Received(
        address operator,
        address from,
        uint256 tokenId,
        bytes calldata data
    ) external returns (bytes4);
}

/**
 * @title ERC721A
 *
 * @dev Implementation of the [ERC721](https://eips.ethereum.org/EIPS/eip-721)
 * Non-Fungible Token Standard, including the Metadata extension.
 * Optimized for lower gas during batch mints.
 *
 * Token IDs are minted in sequential order (e.g. 0, 1, 2, 3, ...)
 * starting from `_startTokenId()`.
 *
 * Assumptions:
 *
 * - An owner cannot have more than 2**64 - 1 (max value of uint64) of supply.
 * - The maximum token ID cannot exceed 2**256 - 1 (max value of uint256).
 */
contract ERC721A is IERC721A {
    // Bypass for a `--via-ir` bug (https://github.com/chiru-labs/ERC721A/pull/364).
    struct TokenApprovalRef {
        address value;
    }

    // =============================================================
    //                           CONSTANTS
    // =============================================================

    // Mask of an entry in packed address data.
    uint256 private constant _BITMASK_ADDRESS_DATA_ENTRY = (1 << 64) - 1;

    // The bit position of `numberMinted` in packed address data.
    uint256 private constant _BITPOS_NUMBER_MINTED = 64;

    // The bit position of `numberBurned` in packed address data.
    uint256 private constant _BITPOS_NUMBER_BURNED = 128;

    // The bit position of `aux` in packed address data.
    uint256 private constant _BITPOS_AUX = 192;

    // Mask of all 256 bits in packed address data except the 64 bits for `aux`.
    uint256 private constant _BITMASK_AUX_COMPLEMENT = (1 << 192) - 1;

    // The bit position of `startTimestamp` in packed ownership.
    uint256 private constant _BITPOS_START_TIMESTAMP = 160;

    // The bit mask of the `burned` bit in packed ownership.
    uint256 private constant _BITMASK_BURNED = 1 << 224;

    // The bit position of the `nextInitialized` bit in packed ownership.
    uint256 private constant _BITPOS_NEXT_INITIALIZED = 225;

    // The bit mask of the `nextInitialized` bit in packed ownership.
    uint256 private constant _BITMASK_NEXT_INITIALIZED = 1 << 225;

    // The bit position of `extraData` in packed ownership.
    uint256 private constant _BITPOS_EXTRA_DATA = 232;

    // Mask of all 256 bits in a packed ownership except the 24 bits for `extraData`.
    uint256 private constant _BITMASK_EXTRA_DATA_COMPLEMENT = (1 << 232) - 1;

    // The mask of the lower 160 bits for addresses.
    uint256 private constant _BITMASK_ADDRESS = (1 << 160) - 1;

    // The maximum `quantity` that can be minted with {_mintERC2309}.
    // This limit is to prevent overflows on the address data entries.
    // For a limit of 5000, a total of 3.689e15 calls to {_mintERC2309}
    // is required to cause an overflow, which is unrealistic.
    uint256 private constant _MAX_MINT_ERC2309_QUANTITY_LIMIT = 5000;

    // The `Transfer` event signature is given by:
    // `keccak256(bytes("Transfer(address,address,uint256)"))`.
    bytes32 private constant _TRANSFER_EVENT_SIGNATURE =
        0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef;

    // =============================================================
    //                            STORAGE
    // =============================================================

    // The next token ID to be minted.
    uint256 private _currentIndex;

    // The number of tokens burned.
    uint256 private _burnCounter;

    // Token name
    string private _name;

    // Token symbol
    string private _symbol;

    // Mapping from token ID to ownership details
    // An empty struct value does not necessarily mean the token is unowned.
    // See {_packedOwnershipOf} implementation for details.
    //
    // Bits Layout:
    // - [0..159]   `addr`
    // - [160..223] `startTimestamp`
    // - [224]      `burned`
    // - [225]      `nextInitialized`
    // - [232..255] `extraData`
    mapping(uint256 => uint256) private _packedOwnerships;

    // Mapping owner address to address data.
    //
    // Bits Layout:
    // - [0..63]    `balance`
    // - [64..127]  `numberMinted`
    // - [128..191] `numberBurned`
    // - [192..255] `aux`
    mapping(address => uint256) private _packedAddressData;

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

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

    // =============================================================
    //                          CONSTRUCTOR
    // =============================================================

    constructor(string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
        _currentIndex = _startTokenId();
    }

    // =============================================================
    //                   TOKEN COUNTING OPERATIONS
    // =============================================================

    /**
     * @dev Returns the starting token ID.
     * To change the starting token ID, please override this function.
     */
    function _startTokenId() internal view virtual returns (uint256) {
        return 0;
    }

    /**
     * @dev Returns the next token ID to be minted.
     */
    function _nextTokenId() internal view virtual returns (uint256) {
        return _currentIndex;
    }

    /**
     * @dev Returns the total number of tokens in existence.
     * Burned tokens will reduce the count.
     * To get the total number of tokens minted, please see {_totalMinted}.
     */
    function totalSupply() public view virtual override returns (uint256) {
        // Counter underflow is impossible as _burnCounter cannot be incremented
        // more than `_currentIndex - _startTokenId()` times.
        unchecked {
            return _currentIndex - _burnCounter - _startTokenId();
        }
    }

    /**
     * @dev Returns the total amount of tokens minted in the contract.
     */
    function _totalMinted() internal view virtual returns (uint256) {
        // Counter underflow is impossible as `_currentIndex` does not decrement,
        // and it is initialized to `_startTokenId()`.
        unchecked {
            return _currentIndex - _startTokenId();
        }
    }

    /**
     * @dev Returns the total number of tokens burned.
     */
    function _totalBurned() internal view virtual returns (uint256) {
        return _burnCounter;
    }

    // =============================================================
    //                    ADDRESS DATA OPERATIONS
    // =============================================================

    /**
     * @dev Returns the number of tokens in `owner`'s account.
     */
    function balanceOf(address owner) public view virtual override returns (uint256) {
        if (owner == address(0)) revert BalanceQueryForZeroAddress();
        return _packedAddressData[owner] & _BITMASK_ADDRESS_DATA_ENTRY;
    }

    /**
     * Returns the number of tokens minted by `owner`.
     */
    function _numberMinted(address owner) internal view returns (uint256) {
        return (_packedAddressData[owner] >> _BITPOS_NUMBER_MINTED) & _BITMASK_ADDRESS_DATA_ENTRY;
    }

    /**
     * Returns the number of tokens burned by or on behalf of `owner`.
     */
    function _numberBurned(address owner) internal view returns (uint256) {
        return (_packedAddressData[owner] >> _BITPOS_NUMBER_BURNED) & _BITMASK_ADDRESS_DATA_ENTRY;
    }

    /**
     * Returns the auxiliary data for `owner`. (e.g. number of whitelist mint slots used).
     */
    function _getAux(address owner) internal view returns (uint64) {
        return uint64(_packedAddressData[owner] >> _BITPOS_AUX);
    }

    /**
     * Sets the auxiliary data for `owner`. (e.g. number of whitelist mint slots used).
     * If there are multiple variables, please pack them into a uint64.
     */
    function _setAux(address owner, uint64 aux) internal virtual {
        uint256 packed = _packedAddressData[owner];
        uint256 auxCasted;
        // Cast `aux` with assembly to avoid redundant masking.
        assembly {
            auxCasted := aux
        }
        packed = (packed & _BITMASK_AUX_COMPLEMENT) | (auxCasted << _BITPOS_AUX);
        _packedAddressData[owner] = packed;
    }

    // =============================================================
    //                            IERC165
    // =============================================================

    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified)
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30000 gas.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        // The interface IDs are constants representing the first 4 bytes
        // of the XOR of all function selectors in the interface.
        // See: [ERC165](https://eips.ethereum.org/EIPS/eip-165)
        // (e.g. `bytes4(i.functionA.selector ^ i.functionB.selector ^ ...)`)
        return
            interfaceId == 0x01ffc9a7 || // ERC165 interface ID for ERC165.
            interfaceId == 0x80ac58cd || // ERC165 interface ID for ERC721.
            interfaceId == 0x5b5e139f; // ERC165 interface ID for ERC721Metadata.
    }

    // =============================================================
    //                        IERC721Metadata
    // =============================================================

    /**
     * @dev Returns the token collection name.
     */
    function name() public view virtual override returns (string memory) {
        return _name;
    }

    /**
     * @dev Returns the token collection symbol.
     */
    function symbol() public view virtual override returns (string memory) {
        return _symbol;
    }

    /**
     * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
     */
    function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
        if (!_exists(tokenId)) revert URIQueryForNonexistentToken();

        string memory baseURI = _baseURI();
        return bytes(baseURI).length != 0 ? string(abi.encodePacked(baseURI, _toString(tokenId))) : '';
    }

    /**
     * @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, it can be overridden in child contracts.
     */
    function _baseURI() internal view virtual returns (string memory) {
        return '';
    }

    // =============================================================
    //                     OWNERSHIPS OPERATIONS
    // =============================================================

    /**
     * @dev Returns the owner of the `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function ownerOf(uint256 tokenId) public view virtual override returns (address) {
        return address(uint160(_packedOwnershipOf(tokenId)));
    }

    /**
     * @dev Gas spent here starts off proportional to the maximum mint batch size.
     * It gradually moves to O(1) as tokens get transferred around over time.
     */
    function _ownershipOf(uint256 tokenId) internal view virtual returns (TokenOwnership memory) {
        return _unpackedOwnership(_packedOwnershipOf(tokenId));
    }

    /**
     * @dev Returns the unpacked `TokenOwnership` struct at `index`.
     */
    function _ownershipAt(uint256 index) internal view virtual returns (TokenOwnership memory) {
        return _unpackedOwnership(_packedOwnerships[index]);
    }

    /**
     * @dev Initializes the ownership slot minted at `index` for efficiency purposes.
     */
    function _initializeOwnershipAt(uint256 index) internal virtual {
        if (_packedOwnerships[index] == 0) {
            _packedOwnerships[index] = _packedOwnershipOf(index);
        }
    }

    /**
     * Returns the packed ownership data of `tokenId`.
     */
    function _packedOwnershipOf(uint256 tokenId) private view returns (uint256) {
        uint256 curr = tokenId;

        unchecked {
            if (_startTokenId() <= curr)
                if (curr < _currentIndex) {
                    uint256 packed = _packedOwnerships[curr];
                    // If not burned.
                    if (packed & _BITMASK_BURNED == 0) {
                        // Invariant:
                        // There will always be an initialized ownership slot
                        // (i.e. `ownership.addr != address(0) && ownership.burned == false`)
                        // before an unintialized ownership slot
                        // (i.e. `ownership.addr == address(0) && ownership.burned == false`)
                        // Hence, `curr` will not underflow.
                        //
                        // We can directly compare the packed value.
                        // If the address is zero, packed will be zero.
                        while (packed == 0) {
                            packed = _packedOwnerships[--curr];
                        }
                        return packed;
                    }
                }
        }
        revert OwnerQueryForNonexistentToken();
    }

    /**
     * @dev Returns the unpacked `TokenOwnership` struct from `packed`.
     */
    function _unpackedOwnership(uint256 packed) private pure returns (TokenOwnership memory ownership) {
        ownership.addr = address(uint160(packed));
        ownership.startTimestamp = uint64(packed >> _BITPOS_START_TIMESTAMP);
        ownership.burned = packed & _BITMASK_BURNED != 0;
        ownership.extraData = uint24(packed >> _BITPOS_EXTRA_DATA);
    }

    /**
     * @dev Packs ownership data into a single uint256.
     */
    function _packOwnershipData(address owner, uint256 flags) private view returns (uint256 result) {
        assembly {
            // Mask `owner` to the lower 160 bits, in case the upper bits somehow aren't clean.
            owner := and(owner, _BITMASK_ADDRESS)
            // `owner | (block.timestamp << _BITPOS_START_TIMESTAMP) | flags`.
            result := or(owner, or(shl(_BITPOS_START_TIMESTAMP, timestamp()), flags))
        }
    }

    /**
     * @dev Returns the `nextInitialized` flag set if `quantity` equals 1.
     */
    function _nextInitializedFlag(uint256 quantity) private pure returns (uint256 result) {
        // For branchless setting of the `nextInitialized` flag.
        assembly {
            // `(quantity == 1) << _BITPOS_NEXT_INITIALIZED`.
            result := shl(_BITPOS_NEXT_INITIALIZED, eq(quantity, 1))
        }
    }

    // =============================================================
    //                      APPROVAL OPERATIONS
    // =============================================================

    /**
     * @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) public payable virtual override {
        address owner = ownerOf(tokenId);

        if (_msgSenderERC721A() != owner)
            if (!isApprovedForAll(owner, _msgSenderERC721A())) {
                revert ApprovalCallerNotOwnerNorApproved();
            }

        _tokenApprovals[tokenId].value = to;
        emit Approval(owner, to, tokenId);
    }

    /**
     * @dev Returns the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) public view virtual override returns (address) {
        if (!_exists(tokenId)) revert ApprovalQueryForNonexistentToken();

        return _tokenApprovals[tokenId].value;
    }

    /**
     * @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) public virtual override {
        _operatorApprovals[_msgSenderERC721A()][operator] = approved;
        emit ApprovalForAll(_msgSenderERC721A(), operator, approved);
    }

    /**
     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
     *
     * See {setApprovalForAll}.
     */
    function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
        return _operatorApprovals[owner][operator];
    }

    /**
     * @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. See {_mint}.
     */
    function _exists(uint256 tokenId) internal view virtual returns (bool) {
        return
            _startTokenId() <= tokenId &&
            tokenId < _currentIndex && // If within bounds,
            _packedOwnerships[tokenId] & _BITMASK_BURNED == 0; // and not burned.
    }

    /**
     * @dev Returns whether `msgSender` is equal to `approvedAddress` or `owner`.
     */
    function _isSenderApprovedOrOwner(
        address approvedAddress,
        address owner,
        address msgSender
    ) private pure returns (bool result) {
        assembly {
            // Mask `owner` to the lower 160 bits, in case the upper bits somehow aren't clean.
            owner := and(owner, _BITMASK_ADDRESS)
            // Mask `msgSender` to the lower 160 bits, in case the upper bits somehow aren't clean.
            msgSender := and(msgSender, _BITMASK_ADDRESS)
            // `msgSender == owner || msgSender == approvedAddress`.
            result := or(eq(msgSender, owner), eq(msgSender, approvedAddress))
        }
    }

    /**
     * @dev Returns the storage slot and value for the approved address of `tokenId`.
     */
    function _getApprovedSlotAndAddress(uint256 tokenId)
        private
        view
        returns (uint256 approvedAddressSlot, address approvedAddress)
    {
        TokenApprovalRef storage tokenApproval = _tokenApprovals[tokenId];
        // The following is equivalent to `approvedAddress = _tokenApprovals[tokenId].value`.
        assembly {
            approvedAddressSlot := tokenApproval.slot
            approvedAddress := sload(approvedAddressSlot)
        }
    }

    // =============================================================
    //                      TRANSFER OPERATIONS
    // =============================================================

    /**
     * @dev Transfers `tokenId` from `from` to `to`.
     *
     * 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
    ) public payable virtual override {
        uint256 prevOwnershipPacked = _packedOwnershipOf(tokenId);

        if (address(uint160(prevOwnershipPacked)) != from) revert TransferFromIncorrectOwner();

        (uint256 approvedAddressSlot, address approvedAddress) = _getApprovedSlotAndAddress(tokenId);

        // The nested ifs save around 20+ gas over a compound boolean condition.
        if (!_isSenderApprovedOrOwner(approvedAddress, from, _msgSenderERC721A()))
            if (!isApprovedForAll(from, _msgSenderERC721A())) revert TransferCallerNotOwnerNorApproved();

        if (to == address(0)) revert TransferToZeroAddress();

        _beforeTokenTransfers(from, to, tokenId, 1);

        // Clear approvals from the previous owner.
        assembly {
            if approvedAddress {
                // This is equivalent to `delete _tokenApprovals[tokenId]`.
                sstore(approvedAddressSlot, 0)
            }
        }

        // Underflow of the sender's balance is impossible because we check for
        // ownership above and the recipient's balance can't realistically overflow.
        // Counter overflow is incredibly unrealistic as `tokenId` would have to be 2**256.
        unchecked {
            // We can directly increment and decrement the balances.
            --_packedAddressData[from]; // Updates: `balance -= 1`.
            ++_packedAddressData[to]; // Updates: `balance += 1`.

            // Updates:
            // - `address` to the next owner.
            // - `startTimestamp` to the timestamp of transfering.
            // - `burned` to `false`.
            // - `nextInitialized` to `true`.
            _packedOwnerships[tokenId] = _packOwnershipData(
                to,
                _BITMASK_NEXT_INITIALIZED | _nextExtraData(from, to, prevOwnershipPacked)
            );

            // If the next slot may not have been initialized (i.e. `nextInitialized == false`) .
            if (prevOwnershipPacked & _BITMASK_NEXT_INITIALIZED == 0) {
                uint256 nextTokenId = tokenId + 1;
                // If the next slot's address is zero and not burned (i.e. packed value is zero).
                if (_packedOwnerships[nextTokenId] == 0) {
                    // If the next slot is within bounds.
                    if (nextTokenId != _currentIndex) {
                        // Initialize the next slot to maintain correctness for `ownerOf(tokenId + 1)`.
                        _packedOwnerships[nextTokenId] = prevOwnershipPacked;
                    }
                }
            }
        }

        emit Transfer(from, to, tokenId);
        _afterTokenTransfers(from, to, tokenId, 1);
    }

    /**
     * @dev Equivalent to `safeTransferFrom(from, to, tokenId, '')`.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    ) public payable virtual override {
        safeTransferFrom(from, to, tokenId, '');
    }

    /**
     * @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 memory _data
    ) public payable virtual override {
        transferFrom(from, to, tokenId);
        if (to.code.length != 0)
            if (!_checkContractOnERC721Received(from, to, tokenId, _data)) {
                revert TransferToNonERC721ReceiverImplementer();
            }
    }

    /**
     * @dev Hook that is called before a set of serially-ordered token IDs
     * are about to be transferred. This includes minting.
     * And also called before burning one token.
     *
     * `startTokenId` - the first token ID to be transferred.
     * `quantity` - the amount to be transferred.
     *
     * Calling conditions:
     *
     * - When `from` and `to` are both non-zero, `from`'s `tokenId` will be
     * transferred to `to`.
     * - When `from` is zero, `tokenId` will be minted for `to`.
     * - When `to` is zero, `tokenId` will be burned by `from`.
     * - `from` and `to` are never both zero.
     */
    function _beforeTokenTransfers(
        address from,
        address to,
        uint256 startTokenId,
        uint256 quantity
    ) internal virtual {}

    /**
     * @dev Hook that is called after a set of serially-ordered token IDs
     * have been transferred. This includes minting.
     * And also called after one token has been burned.
     *
     * `startTokenId` - the first token ID to be transferred.
     * `quantity` - the amount to be transferred.
     *
     * Calling conditions:
     *
     * - When `from` and `to` are both non-zero, `from`'s `tokenId` has been
     * transferred to `to`.
     * - When `from` is zero, `tokenId` has been minted for `to`.
     * - When `to` is zero, `tokenId` has been burned by `from`.
     * - `from` and `to` are never both zero.
     */
    function _afterTokenTransfers(
        address from,
        address to,
        uint256 startTokenId,
        uint256 quantity
    ) internal virtual {}

    /**
     * @dev Private function to invoke {IERC721Receiver-onERC721Received} on a target contract.
     *
     * `from` - Previous owner of the given token ID.
     * `to` - Target address that will receive the token.
     * `tokenId` - Token ID to be transferred.
     * `_data` - Optional data to send along with the call.
     *
     * Returns whether the call correctly returned the expected magic value.
     */
    function _checkContractOnERC721Received(
        address from,
        address to,
        uint256 tokenId,
        bytes memory _data
    ) private returns (bool) {
        try ERC721A__IERC721Receiver(to).onERC721Received(_msgSenderERC721A(), from, tokenId, _data) returns (
            bytes4 retval
        ) {
            return retval == ERC721A__IERC721Receiver(to).onERC721Received.selector;
        } catch (bytes memory reason) {
            if (reason.length == 0) {
                revert TransferToNonERC721ReceiverImplementer();
            } else {
                assembly {
                    revert(add(32, reason), mload(reason))
                }
            }
        }
    }

    // =============================================================
    //                        MINT OPERATIONS
    // =============================================================

    /**
     * @dev Mints `quantity` tokens and transfers them to `to`.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - `quantity` must be greater than 0.
     *
     * Emits a {Transfer} event for each mint.
     */
    function _mint(address to, uint256 quantity) internal virtual {
        uint256 startTokenId = _currentIndex;
        if (quantity == 0) revert MintZeroQuantity();

        _beforeTokenTransfers(address(0), to, startTokenId, quantity);

        // Overflows are incredibly unrealistic.
        // `balance` and `numberMinted` have a maximum limit of 2**64.
        // `tokenId` has a maximum limit of 2**256.
        unchecked {
            // Updates:
            // - `balance += quantity`.
            // - `numberMinted += quantity`.
            //
            // We can directly add to the `balance` and `numberMinted`.
            _packedAddressData[to] += quantity * ((1 << _BITPOS_NUMBER_MINTED) | 1);

            // Updates:
            // - `address` to the owner.
            // - `startTimestamp` to the timestamp of minting.
            // - `burned` to `false`.
            // - `nextInitialized` to `quantity == 1`.
            _packedOwnerships[startTokenId] = _packOwnershipData(
                to,
                _nextInitializedFlag(quantity) | _nextExtraData(address(0), to, 0)
            );

            uint256 toMasked;
            uint256 end = startTokenId + quantity;

            // Use assembly to loop and emit the `Transfer` event for gas savings.
            // The duplicated `log4` removes an extra check and reduces stack juggling.
            // The assembly, together with the surrounding Solidity code, have been
            // delicately arranged to nudge the compiler into producing optimized opcodes.
            assembly {
                // Mask `to` to the lower 160 bits, in case the upper bits somehow aren't clean.
                toMasked := and(to, _BITMASK_ADDRESS)
                // Emit the `Transfer` event.
                log4(
                    0, // Start of data (0, since no data).
                    0, // End of data (0, since no data).
                    _TRANSFER_EVENT_SIGNATURE, // Signature.
                    0, // `address(0)`.
                    toMasked, // `to`.
                    startTokenId // `tokenId`.
                )

                // The `iszero(eq(,))` check ensures that large values of `quantity`
                // that overflows uint256 will make the loop run out of gas.
                // The compiler will optimize the `iszero` away for performance.
                for {
                    let tokenId := add(startTokenId, 1)
                } iszero(eq(tokenId, end)) {
                    tokenId := add(tokenId, 1)
                } {
                    // Emit the `Transfer` event. Similar to above.
                    log4(0, 0, _TRANSFER_EVENT_SIGNATURE, 0, toMasked, tokenId)
                }
            }
            if (toMasked == 0) revert MintToZeroAddress();

            _currentIndex = end;
        }
        _afterTokenTransfers(address(0), to, startTokenId, quantity);
    }

    /**
     * @dev Mints `quantity` tokens and transfers them to `to`.
     *
     * This function is intended for efficient minting only during contract creation.
     *
     * It emits only one {ConsecutiveTransfer} as defined in
     * [ERC2309](https://eips.ethereum.org/EIPS/eip-2309),
     * instead of a sequence of {Transfer} event(s).
     *
     * Calling this function outside of contract creation WILL make your contract
     * non-compliant with the ERC721 standard.
     * For full ERC721 compliance, substituting ERC721 {Transfer} event(s) with the ERC2309
     * {ConsecutiveTransfer} event is only permissible during contract creation.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - `quantity` must be greater than 0.
     *
     * Emits a {ConsecutiveTransfer} event.
     */
    function _mintERC2309(address to, uint256 quantity) internal virtual {
        uint256 startTokenId = _currentIndex;
        if (to == address(0)) revert MintToZeroAddress();
        if (quantity == 0) revert MintZeroQuantity();
        if (quantity > _MAX_MINT_ERC2309_QUANTITY_LIMIT) revert MintERC2309QuantityExceedsLimit();

        _beforeTokenTransfers(address(0), to, startTokenId, quantity);

        // Overflows are unrealistic due to the above check for `quantity` to be below the limit.
        unchecked {
            // Updates:
            // - `balance += quantity`.
            // - `numberMinted += quantity`.
            //
            // We can directly add to the `balance` and `numberMinted`.
            _packedAddressData[to] += quantity * ((1 << _BITPOS_NUMBER_MINTED) | 1);

            // Updates:
            // - `address` to the owner.
            // - `startTimestamp` to the timestamp of minting.
            // - `burned` to `false`.
            // - `nextInitialized` to `quantity == 1`.
            _packedOwnerships[startTokenId] = _packOwnershipData(
                to,
                _nextInitializedFlag(quantity) | _nextExtraData(address(0), to, 0)
            );

            emit ConsecutiveTransfer(startTokenId, startTokenId + quantity - 1, address(0), to);

            _currentIndex = startTokenId + quantity;
        }
        _afterTokenTransfers(address(0), to, startTokenId, quantity);
    }

    /**
     * @dev Safely mints `quantity` tokens and transfers them to `to`.
     *
     * Requirements:
     *
     * - If `to` refers to a smart contract, it must implement
     * {IERC721Receiver-onERC721Received}, which is called for each safe transfer.
     * - `quantity` must be greater than 0.
     *
     * See {_mint}.
     *
     * Emits a {Transfer} event for each mint.
     */
    function _safeMint(
        address to,
        uint256 quantity,
        bytes memory _data
    ) internal virtual {
        _mint(to, quantity);

        unchecked {
            if (to.code.length != 0) {
                uint256 end = _currentIndex;
                uint256 index = end - quantity;
                do {
                    if (!_checkContractOnERC721Received(address(0), to, index++, _data)) {
                        revert TransferToNonERC721ReceiverImplementer();
                    }
                } while (index < end);
                // Reentrancy protection.
                if (_currentIndex != end) revert();
            }
        }
    }

    /**
     * @dev Equivalent to `_safeMint(to, quantity, '')`.
     */
    function _safeMint(address to, uint256 quantity) internal virtual {
        _safeMint(to, quantity, '');
    }

    // =============================================================
    //                        BURN OPERATIONS
    // =============================================================

    /**
     * @dev Equivalent to `_burn(tokenId, false)`.
     */
    function _burn(uint256 tokenId) internal virtual {
        _burn(tokenId, false);
    }

    /**
     * @dev Destroys `tokenId`.
     * The approval is cleared when the token is burned.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     *
     * Emits a {Transfer} event.
     */
    function _burn(uint256 tokenId, bool approvalCheck) internal virtual {
        uint256 prevOwnershipPacked = _packedOwnershipOf(tokenId);

        address from = address(uint160(prevOwnershipPacked));

        (uint256 approvedAddressSlot, address approvedAddress) = _getApprovedSlotAndAddress(tokenId);

        if (approvalCheck) {
            // The nested ifs save around 20+ gas over a compound boolean condition.
            if (!_isSenderApprovedOrOwner(approvedAddress, from, _msgSenderERC721A()))
                if (!isApprovedForAll(from, _msgSenderERC721A())) revert TransferCallerNotOwnerNorApproved();
        }

        _beforeTokenTransfers(from, address(0), tokenId, 1);

        // Clear approvals from the previous owner.
        assembly {
            if approvedAddress {
                // This is equivalent to `delete _tokenApprovals[tokenId]`.
                sstore(approvedAddressSlot, 0)
            }
        }

        // Underflow of the sender's balance is impossible because we check for
        // ownership above and the recipient's balance can't realistically overflow.
        // Counter overflow is incredibly unrealistic as `tokenId` would have to be 2**256.
        unchecked {
            // Updates:
            // - `balance -= 1`.
            // - `numberBurned += 1`.
            //
            // We can directly decrement the balance, and increment the number burned.
            // This is equivalent to `packed -= 1; packed += 1 << _BITPOS_NUMBER_BURNED;`.
            _packedAddressData[from] += (1 << _BITPOS_NUMBER_BURNED) - 1;

            // Updates:
            // - `address` to the last owner.
            // - `startTimestamp` to the timestamp of burning.
            // - `burned` to `true`.
            // - `nextInitialized` to `true`.
            _packedOwnerships[tokenId] = _packOwnershipData(
                from,
                (_BITMASK_BURNED | _BITMASK_NEXT_INITIALIZED) | _nextExtraData(from, address(0), prevOwnershipPacked)
            );

            // If the next slot may not have been initialized (i.e. `nextInitialized == false`) .
            if (prevOwnershipPacked & _BITMASK_NEXT_INITIALIZED == 0) {
                uint256 nextTokenId = tokenId + 1;
                // If the next slot's address is zero and not burned (i.e. packed value is zero).
                if (_packedOwnerships[nextTokenId] == 0) {
                    // If the next slot is within bounds.
                    if (nextTokenId != _currentIndex) {
                        // Initialize the next slot to maintain correctness for `ownerOf(tokenId + 1)`.
                        _packedOwnerships[nextTokenId] = prevOwnershipPacked;
                    }
                }
            }
        }

        emit Transfer(from, address(0), tokenId);
        _afterTokenTransfers(from, address(0), tokenId, 1);

        // Overflow not possible, as _burnCounter cannot be exceed _currentIndex times.
        unchecked {
            _burnCounter++;
        }
    }

    // =============================================================
    //                     EXTRA DATA OPERATIONS
    // =============================================================

    /**
     * @dev Directly sets the extra data for the ownership data `index`.
     */
    function _setExtraDataAt(uint256 index, uint24 extraData) internal virtual {
        uint256 packed = _packedOwnerships[index];
        if (packed == 0) revert OwnershipNotInitializedForExtraData();
        uint256 extraDataCasted;
        // Cast `extraData` with assembly to avoid redundant masking.
        assembly {
            extraDataCasted := extraData
        }
        packed = (packed & _BITMASK_EXTRA_DATA_COMPLEMENT) | (extraDataCasted << _BITPOS_EXTRA_DATA);
        _packedOwnerships[index] = packed;
    }

    /**
     * @dev Called during each token transfer to set the 24bit `extraData` field.
     * Intended to be overridden by the cosumer contract.
     *
     * `previousExtraData` - the value of `extraData` before transfer.
     *
     * Calling conditions:
     *
     * - When `from` and `to` are both non-zero, `from`'s `tokenId` will be
     * transferred to `to`.
     * - When `from` is zero, `tokenId` will be minted for `to`.
     * - When `to` is zero, `tokenId` will be burned by `from`.
     * - `from` and `to` are never both zero.
     */
    function _extraData(
        address from,
        address to,
        uint24 previousExtraData
    ) internal view virtual returns (uint24) {}

    /**
     * @dev Returns the next extra data for the packed ownership data.
     * The returned result is shifted into position.
     */
    function _nextExtraData(
        address from,
        address to,
        uint256 prevOwnershipPacked
    ) private view returns (uint256) {
        uint24 extraData = uint24(prevOwnershipPacked >> _BITPOS_EXTRA_DATA);
        return uint256(_extraData(from, to, extraData)) << _BITPOS_EXTRA_DATA;
    }

    // =============================================================
    //                       OTHER OPERATIONS
    // =============================================================

    /**
     * @dev Returns the message sender (defaults to `msg.sender`).
     *
     * If you are writing GSN compatible contracts, you need to override this function.
     */
    function _msgSenderERC721A() internal view virtual returns (address) {
        return msg.sender;
    }

    /**
     * @dev Converts a uint256 to its ASCII string decimal representation.
     */
    function _toString(uint256 value) internal pure virtual returns (string memory str) {
        assembly {
            // The maximum value of a uint256 contains 78 digits (1 byte per digit), but
            // we allocate 0xa0 bytes to keep the free memory pointer 32-byte word aligned.
            // We will need 1 word for the trailing zeros padding, 1 word for the length,
            // and 3 words for a maximum of 78 digits. Total: 5 * 0x20 = 0xa0.
            let m := add(mload(0x40), 0xa0)
            // Update the free memory pointer to allocate.
            mstore(0x40, m)
            // Assign the `str` to the end.
            str := sub(m, 0x20)
            // Zeroize the slot after the string.
            mstore(str, 0)

            // Cache the end of the memory to calculate the length later.
            let end := str

            // We write the string from rightmost digit to leftmost digit.
            // The following is essentially a do-while loop that also handles the zero case.
            // prettier-ignore
            for { let temp := value } 1 {} {
                str := sub(str, 1)
                // Write the character to the pointer.
                // The ASCII index of the '0' character is 48.
                mstore8(str, add(48, mod(temp, 10)))
                // Keep dividing `temp` until zero.
                temp := div(temp, 10)
                // prettier-ignore
                if iszero(temp) { break }
            }

            let length := sub(end, str)
            // Move the pointer 32 bytes leftwards to make room for the length.
            str := sub(str, 0x20)
            // Store the length.
            mstore(str, length)
        }
    }
}

File 19 of 21 : IERC721A.sol
// SPDX-License-Identifier: MIT
// ERC721A Contracts v4.2.3
// Creator: Chiru Labs

pragma solidity ^0.8.4;

/**
 * @dev Interface of ERC721A.
 */
interface IERC721A {
    /**
     * The caller must own the token or be an approved operator.
     */
    error ApprovalCallerNotOwnerNorApproved();

    /**
     * The token does not exist.
     */
    error ApprovalQueryForNonexistentToken();

    /**
     * Cannot query the balance for the zero address.
     */
    error BalanceQueryForZeroAddress();

    /**
     * Cannot mint to the zero address.
     */
    error MintToZeroAddress();

    /**
     * The quantity of tokens minted must be more than zero.
     */
    error MintZeroQuantity();

    /**
     * The token does not exist.
     */
    error OwnerQueryForNonexistentToken();

    /**
     * The caller must own the token or be an approved operator.
     */
    error TransferCallerNotOwnerNorApproved();

    /**
     * The token must be owned by `from`.
     */
    error TransferFromIncorrectOwner();

    /**
     * Cannot safely transfer to a contract that does not implement the
     * ERC721Receiver interface.
     */
    error TransferToNonERC721ReceiverImplementer();

    /**
     * Cannot transfer to the zero address.
     */
    error TransferToZeroAddress();

    /**
     * The token does not exist.
     */
    error URIQueryForNonexistentToken();

    /**
     * The `quantity` minted with ERC2309 exceeds the safety limit.
     */
    error MintERC2309QuantityExceedsLimit();

    /**
     * The `extraData` cannot be set on an unintialized ownership slot.
     */
    error OwnershipNotInitializedForExtraData();

    // =============================================================
    //                            STRUCTS
    // =============================================================

    struct TokenOwnership {
        // The address of the owner.
        address addr;
        // Stores the start time of ownership with minimal overhead for tokenomics.
        uint64 startTimestamp;
        // Whether the token has been burned.
        bool burned;
        // Arbitrary data similar to `startTimestamp` that can be set via {_extraData}.
        uint24 extraData;
    }

    // =============================================================
    //                         TOKEN COUNTERS
    // =============================================================

    /**
     * @dev Returns the total number of tokens in existence.
     * Burned tokens will reduce the count.
     * To get the total number of tokens minted, please see {_totalMinted}.
     */
    function totalSupply() external view returns (uint256);

    // =============================================================
    //                            IERC165
    // =============================================================

    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified)
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);

    // =============================================================
    //                            IERC721
    // =============================================================

    /**
     * @dev Emitted when `tokenId` token is transferred from `from` to `to`.
     */
    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
     */
    event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables or disables
     * (`approved`) `operator` to manage all of its assets.
     */
    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);

    /**
     * @dev Returns the number of tokens in `owner`'s account.
     */
    function balanceOf(address owner) external view returns (uint256 balance);

    /**
     * @dev Returns the owner of the `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function ownerOf(uint256 tokenId) external view returns (address owner);

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`,
     * checking first that contract recipients are aware of the ERC721 protocol
     * to prevent tokens from being forever locked.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must be have been allowed to move
     * this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement
     * {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId,
        bytes calldata data
    ) external payable;

    /**
     * @dev Equivalent to `safeTransferFrom(from, to, tokenId, '')`.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external payable;

    /**
     * @dev Transfers `tokenId` from `from` to `to`.
     *
     * WARNING: Usage of this method is discouraged, use {safeTransferFrom}
     * whenever possible.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token
     * by either {approve} or {setApprovalForAll}.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external payable;

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

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

    // =============================================================
    //                        IERC721Metadata
    // =============================================================

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

    // =============================================================
    //                           IERC2309
    // =============================================================

    /**
     * @dev Emitted when tokens in `fromTokenId` to `toTokenId`
     * (inclusive) is transferred from `from` to `to`, as defined in the
     * [ERC2309](https://eips.ethereum.org/EIPS/eip-2309) standard.
     *
     * See {_mintERC2309} for more details.
     */
    event ConsecutiveTransfer(uint256 indexed fromTokenId, uint256 toTokenId, address indexed from, address indexed to);
}

File 20 of 21 : ERC721AQueryable.sol
// SPDX-License-Identifier: MIT
// ERC721A Contracts v4.2.3
// Creator: Chiru Labs

pragma solidity ^0.8.4;

import './IERC721AQueryable.sol';
import '../ERC721A.sol';

/**
 * @title ERC721AQueryable.
 *
 * @dev ERC721A subclass with convenience query functions.
 */
abstract contract ERC721AQueryable is ERC721A, IERC721AQueryable {
    /**
     * @dev Returns the `TokenOwnership` struct at `tokenId` without reverting.
     *
     * If the `tokenId` is out of bounds:
     *
     * - `addr = address(0)`
     * - `startTimestamp = 0`
     * - `burned = false`
     * - `extraData = 0`
     *
     * If the `tokenId` is burned:
     *
     * - `addr = <Address of owner before token was burned>`
     * - `startTimestamp = <Timestamp when token was burned>`
     * - `burned = true`
     * - `extraData = <Extra data when token was burned>`
     *
     * Otherwise:
     *
     * - `addr = <Address of owner>`
     * - `startTimestamp = <Timestamp of start of ownership>`
     * - `burned = false`
     * - `extraData = <Extra data at start of ownership>`
     */
    function explicitOwnershipOf(uint256 tokenId) public view virtual override returns (TokenOwnership memory) {
        TokenOwnership memory ownership;
        if (tokenId < _startTokenId() || tokenId >= _nextTokenId()) {
            return ownership;
        }
        ownership = _ownershipAt(tokenId);
        if (ownership.burned) {
            return ownership;
        }
        return _ownershipOf(tokenId);
    }

    /**
     * @dev Returns an array of `TokenOwnership` structs at `tokenIds` in order.
     * See {ERC721AQueryable-explicitOwnershipOf}
     */
    function explicitOwnershipsOf(uint256[] calldata tokenIds)
        external
        view
        virtual
        override
        returns (TokenOwnership[] memory)
    {
        unchecked {
            uint256 tokenIdsLength = tokenIds.length;
            TokenOwnership[] memory ownerships = new TokenOwnership[](tokenIdsLength);
            for (uint256 i; i != tokenIdsLength; ++i) {
                ownerships[i] = explicitOwnershipOf(tokenIds[i]);
            }
            return ownerships;
        }
    }

    /**
     * @dev Returns an array of token IDs owned by `owner`,
     * in the range [`start`, `stop`)
     * (i.e. `start <= tokenId < stop`).
     *
     * This function allows for tokens to be queried if the collection
     * grows too big for a single call of {ERC721AQueryable-tokensOfOwner}.
     *
     * Requirements:
     *
     * - `start < stop`
     */
    function tokensOfOwnerIn(
        address owner,
        uint256 start,
        uint256 stop
    ) external view virtual override returns (uint256[] memory) {
        unchecked {
            if (start >= stop) revert InvalidQueryRange();
            uint256 tokenIdsIdx;
            uint256 stopLimit = _nextTokenId();
            // Set `start = max(start, _startTokenId())`.
            if (start < _startTokenId()) {
                start = _startTokenId();
            }
            // Set `stop = min(stop, stopLimit)`.
            if (stop > stopLimit) {
                stop = stopLimit;
            }
            uint256 tokenIdsMaxLength = balanceOf(owner);
            // Set `tokenIdsMaxLength = min(balanceOf(owner), stop - start)`,
            // to cater for cases where `balanceOf(owner)` is too big.
            if (start < stop) {
                uint256 rangeLength = stop - start;
                if (rangeLength < tokenIdsMaxLength) {
                    tokenIdsMaxLength = rangeLength;
                }
            } else {
                tokenIdsMaxLength = 0;
            }
            uint256[] memory tokenIds = new uint256[](tokenIdsMaxLength);
            if (tokenIdsMaxLength == 0) {
                return tokenIds;
            }
            // We need to call `explicitOwnershipOf(start)`,
            // because the slot at `start` may not be initialized.
            TokenOwnership memory ownership = explicitOwnershipOf(start);
            address currOwnershipAddr;
            // If the starting slot exists (i.e. not burned), initialize `currOwnershipAddr`.
            // `ownership.address` will not be zero, as `start` is clamped to the valid token ID range.
            if (!ownership.burned) {
                currOwnershipAddr = ownership.addr;
            }
            for (uint256 i = start; i != stop && tokenIdsIdx != tokenIdsMaxLength; ++i) {
                ownership = _ownershipAt(i);
                if (ownership.burned) {
                    continue;
                }
                if (ownership.addr != address(0)) {
                    currOwnershipAddr = ownership.addr;
                }
                if (currOwnershipAddr == owner) {
                    tokenIds[tokenIdsIdx++] = i;
                }
            }
            // Downsize the array to fit.
            assembly {
                mstore(tokenIds, tokenIdsIdx)
            }
            return tokenIds;
        }
    }

    /**
     * @dev Returns an array of token IDs owned by `owner`.
     *
     * This function scans the ownership mapping and is O(`totalSupply`) in complexity.
     * It is meant to be called off-chain.
     *
     * See {ERC721AQueryable-tokensOfOwnerIn} for splitting the scan into
     * multiple smaller scans if the collection is large enough to cause
     * an out-of-gas error (10K collections should be fine).
     */
    function tokensOfOwner(address owner) external view virtual override returns (uint256[] memory) {
        unchecked {
            uint256 tokenIdsIdx;
            address currOwnershipAddr;
            uint256 tokenIdsLength = balanceOf(owner);
            uint256[] memory tokenIds = new uint256[](tokenIdsLength);
            TokenOwnership memory ownership;
            for (uint256 i = _startTokenId(); tokenIdsIdx != tokenIdsLength; ++i) {
                ownership = _ownershipAt(i);
                if (ownership.burned) {
                    continue;
                }
                if (ownership.addr != address(0)) {
                    currOwnershipAddr = ownership.addr;
                }
                if (currOwnershipAddr == owner) {
                    tokenIds[tokenIdsIdx++] = i;
                }
            }
            return tokenIds;
        }
    }
}

File 21 of 21 : IERC721AQueryable.sol
// SPDX-License-Identifier: MIT
// ERC721A Contracts v4.2.3
// Creator: Chiru Labs

pragma solidity ^0.8.4;

import '../IERC721A.sol';

/**
 * @dev Interface of ERC721AQueryable.
 */
interface IERC721AQueryable is IERC721A {
    /**
     * Invalid query range (`start` >= `stop`).
     */
    error InvalidQueryRange();

    /**
     * @dev Returns the `TokenOwnership` struct at `tokenId` without reverting.
     *
     * If the `tokenId` is out of bounds:
     *
     * - `addr = address(0)`
     * - `startTimestamp = 0`
     * - `burned = false`
     * - `extraData = 0`
     *
     * If the `tokenId` is burned:
     *
     * - `addr = <Address of owner before token was burned>`
     * - `startTimestamp = <Timestamp when token was burned>`
     * - `burned = true`
     * - `extraData = <Extra data when token was burned>`
     *
     * Otherwise:
     *
     * - `addr = <Address of owner>`
     * - `startTimestamp = <Timestamp of start of ownership>`
     * - `burned = false`
     * - `extraData = <Extra data at start of ownership>`
     */
    function explicitOwnershipOf(uint256 tokenId) external view returns (TokenOwnership memory);

    /**
     * @dev Returns an array of `TokenOwnership` structs at `tokenIds` in order.
     * See {ERC721AQueryable-explicitOwnershipOf}
     */
    function explicitOwnershipsOf(uint256[] memory tokenIds) external view returns (TokenOwnership[] memory);

    /**
     * @dev Returns an array of token IDs owned by `owner`,
     * in the range [`start`, `stop`)
     * (i.e. `start <= tokenId < stop`).
     *
     * This function allows for tokens to be queried if the collection
     * grows too big for a single call of {ERC721AQueryable-tokensOfOwner}.
     *
     * Requirements:
     *
     * - `start < stop`
     */
    function tokensOfOwnerIn(
        address owner,
        uint256 start,
        uint256 stop
    ) external view returns (uint256[] memory);

    /**
     * @dev Returns an array of token IDs owned by `owner`.
     *
     * This function scans the ownership mapping and is O(`totalSupply`) in complexity.
     * It is meant to be called off-chain.
     *
     * See {ERC721AQueryable-tokensOfOwnerIn} for splitting the scan into
     * multiple smaller scans if the collection is large enough to cause
     * an out-of-gas error (10K collections should be fine).
     */
    function tokensOfOwner(address owner) external view returns (uint256[] memory);
}

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"contract TerrapinGenesis","name":"terrapinGenesis_","type":"address"},{"internalType":"contract TerrapinUniverseCardPack","name":"terrapinUniverseVillainsCardPack_","type":"address"},{"internalType":"string","name":"baseURI_","type":"string"},{"internalType":"address[]","name":"operators","type":"address[]"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"ApprovalCallerNotOwnerNorApproved","type":"error"},{"inputs":[],"name":"ApprovalQueryForNonexistentToken","type":"error"},{"inputs":[],"name":"BalanceQueryForZeroAddress","type":"error"},{"inputs":[],"name":"InvalidCardPackTokenIds","type":"error"},{"inputs":[],"name":"InvalidQueryRange","type":"error"},{"inputs":[],"name":"InvalidTerrapinUniverseCardPackAddress","type":"error"},{"inputs":[],"name":"MaxSupplyExceeded","type":"error"},{"inputs":[],"name":"MintERC2309QuantityExceedsLimit","type":"error"},{"inputs":[],"name":"MintNotActive","type":"error"},{"inputs":[],"name":"MintToZeroAddress","type":"error"},{"inputs":[],"name":"MintZeroQuantity","type":"error"},{"inputs":[],"name":"OwnerQueryForNonexistentToken","type":"error"},{"inputs":[],"name":"OwnershipNotInitializedForExtraData","type":"error"},{"inputs":[],"name":"TransferCallerNotOwnerNorApproved","type":"error"},{"inputs":[],"name":"TransferFromIncorrectOwner","type":"error"},{"inputs":[],"name":"TransferToNonERC721ReceiverImplementer","type":"error"},{"inputs":[],"name":"TransferToZeroAddress","type":"error"},{"inputs":[],"name":"URIQueryForNonexistentToken","type":"error"},{"inputs":[],"name":"ValueUnchanged","type":"error"},{"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":false,"internalType":"string","name":"oldBaseURI","type":"string"},{"indexed":false,"internalType":"string","name":"baseURI","type":"string"}],"name":"BaseURIUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldTerrapinUniverseCardPack","type":"address"},{"indexed":false,"internalType":"address","name":"terrapinUniverseCardPack","type":"address"}],"name":"CardPackUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"fromTokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"toTokenId","type":"uint256"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"}],"name":"ConsecutiveTransfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"mintActive","type":"bool"}],"name":"MintActiveUpdated","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":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"LEVEL_EXP_DAYS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"NULL_ADDRESS","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"OPERATOR_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"OS_CONDUIT_ADDRESS","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"STAKE_START_THRESHOLD_DAYS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"START_TOKEN_ID","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"payable","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":"address","name":"account","type":"address"}],"name":"eligibleCardPackTokenIdsOf","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"explicitOwnershipOf","outputs":[{"components":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"uint64","name":"startTimestamp","type":"uint64"},{"internalType":"bool","name":"burned","type":"bool"},{"internalType":"uint24","name":"extraData","type":"uint24"}],"internalType":"struct IERC721A.TokenOwnership","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"explicitOwnershipsOf","outputs":[{"components":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"uint64","name":"startTimestamp","type":"uint64"},{"internalType":"bool","name":"burned","type":"bool"},{"internalType":"uint24","name":"extraData","type":"uint24"}],"internalType":"struct IERC721A.TokenOwnership[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"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":"tokenId","type":"uint256"}],"name":"isCardPackTokenIdUsed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"levelOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"mintActive","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"numberMinted","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"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":"uint256","name":"tokenId","type":"uint256"}],"name":"rawLevelOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"cardPackTokenIds","type":"uint256[]"}],"name":"redeem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256[]","name":"cardPackTokenIds","type":"uint256[]"}],"name":"redeemTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","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":"payable","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":"payable","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":"contract TerrapinUniverseCardPack","name":"terrapinUniverseCardPack_","type":"address"}],"name":"setCardPack","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"mintActive_","type":"bool"}],"name":"setMintActive","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":[],"name":"terrapinGenesis","outputs":[{"internalType":"contract TerrapinGenesis","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"terrapinUniverseCardPack","outputs":[{"internalType":"contract TerrapinUniverseCardPack","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenDetailOf","outputs":[{"components":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"uint64","name":"startTimestamp","type":"uint64"},{"internalType":"bool","name":"burned","type":"bool"},{"internalType":"uint24","name":"extraData","type":"uint24"}],"internalType":"struct IERC721A.TokenOwnership","name":"","type":"tuple"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"tokenIdToCardPackTokenId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"tokenIdToRawLevelAtLastTransfer","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":[{"internalType":"address","name":"owner","type":"address"}],"name":"tokensOfOwner","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"start","type":"uint256"},{"internalType":"uint256","name":"stop","type":"uint256"}],"name":"tokensOfOwnerIn","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalMinted","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"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":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"usedCardPackTokenIds","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]

610140604052600060a0908152600e60c052602c60e05260866101005260fe610120526200003290600b906005620002b1565b503480156200004057600080fd5b5060405162003ba738038062003ba783398101604081905262000063916200048f565b6040518060400160405280601881526020017f546572726170696e556e69766572736556696c6c61696e730000000000000000815250604051806040016040528060038152602001622a2aab60e91b815250858585858585620000d5620000cf620001d460201b60201c565b620001d8565b60016002558151620000ef90600590602085019062000306565b5080516200010590600690602084019062000306565b50600160035550506001600160a01b03848116608052600c80546001600160a01b03191691851691909117905581516200014790600d90602085019062000306565b506200015560003362000228565b60005b8151811015620001c357620001b07f97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b9298383815181106200019c576200019c620005a1565b60200260200101516200022860201b60201c565b620001bb81620005b7565b905062000158565b50505050505050505050506200061e565b3390565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60008281526001602090815260408083206001600160a01b038516845290915290205460ff16620002ad5760008281526001602081815260408084206001600160a01b0386168086529252808420805460ff19169093179092559051339285917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9190a45b5050565b828054828255906000526020600020908101928215620002f4579160200282015b82811115620002f4578251829060ff16905591602001919060010190620002d2565b506200030292915062000383565b5090565b8280546200031490620005e1565b90600052602060002090601f016020900481019282620003385760008555620002f4565b82601f106200035357805160ff1916838001178555620002f4565b82800160010185558215620002f4579182015b82811115620002f457825182559160200191906001019062000366565b5b8082111562000302576000815560010162000384565b6001600160a01b0381168114620003b057600080fd5b50565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b0381118282101715620003f457620003f4620003b3565b604052919050565b600082601f8301126200040e57600080fd5b815160206001600160401b038211156200042c576200042c620003b3565b8160051b6200043d828201620003c9565b92835284810182019282810190878511156200045857600080fd5b83870192505b848310156200048457825162000474816200039a565b825291830191908301906200045e565b979650505050505050565b60008060008060808587031215620004a657600080fd5b8451620004b3816200039a565b80945050602080860151620004c8816200039a565b60408701519094506001600160401b0380821115620004e657600080fd5b818801915088601f830112620004fb57600080fd5b815181811115620005105762000510620003b3565b62000524601f8201601f19168501620003c9565b8181528a858386010111156200053957600080fd5b60005b82811015620005595784810186015182820187015285016200053c565b828111156200056b5760008684840101525b5060608a0151909650935050808311156200058557600080fd5b50506200059587828801620003fc565b91505092959194509250565b634e487b7160e01b600052603260045260246000fd5b6000600019821415620005da57634e487b7160e01b600052601160045260246000fd5b5060010190565b600181811c90821680620005f657607f821691505b602082108114156200061857634e487b7160e01b600052602260045260246000fd5b50919050565b60805161356662000641600039600081816109a4015261209101526135666000f3fe6080604052600436106103355760003560e01c806387f65c91116101ab578063b94c54c7116100f7578063de0ce17d11610095578063f2fde38b1161006f578063f2fde38b14610972578063f4cc37bd14610992578063f5b541a6146109c6578063f9afb26a146109e857600080fd5b8063de0ce17d1461091d578063e985e9c514610932578063ee1cc9441461095257600080fd5b8063c87b56dd116100d1578063c87b56dd146108a7578063d547741f146108c7578063d5abeb01146108e7578063dc33e681146108fd57600080fd5b8063b94c54c71461083a578063bfe633a21461085a578063c23dc68f1461087a57600080fd5b8063a217fddf11610164578063a4bc32301161013e578063a4bc3230146107b8578063a937dfcb146107d8578063b40c2454146107f8578063b88d4fde1461082757600080fd5b8063a217fddf1461076e578063a22cb46514610783578063a2309ff8146107a357600080fd5b806387f65c91146106d15780638da5cb5b146106e657806391d1485414610704578063952abc461461072457806395d89b411461073957806399a2557a1461074e57600080fd5b80633ccfd60b116102855780636daa693c11610223578063715018a6116101fd578063715018a61461065a5780637c1f9eb11461066f5780637e1e80421461068f5780638462151c146106a457600080fd5b80636daa693c146105f2578063702d53941461061257806370a082311461063a57600080fd5b80635bbb21771161025f5780635bbb2177146105705780636352211e1461059d5780636c0360eb146105bd5780636d5e3032146105d257600080fd5b80633ccfd60b1461052857806342842e0e1461053d57806355f804b31461055057600080fd5b80630e88b22c116102f2578063248a9ca3116102cc578063248a9ca31461049657806325fd90f3146104c75780632f2ff15d146104e857806336568abe1461050857600080fd5b80630e88b22c1461043957806318160ddd1461046657806323b872dd1461048357600080fd5b806301ffc9a71461033a57806306fdde031461036f578063081812fc14610391578063095ea7b3146103c95780630be8d880146103de5780630dddeb60146103fe575b600080fd5b34801561034657600080fd5b5061035a610355366004612c0b565b610a08565b60405190151581526020015b60405180910390f35b34801561037b57600080fd5b50610384610a28565b6040516103669190612c80565b34801561039d57600080fd5b506103b16103ac366004612c93565b610aba565b6040516001600160a01b039091168152602001610366565b6103dc6103d7366004612cc1565b610afe565b005b3480156103ea57600080fd5b5061035a6103f9366004612c93565b610b9e565b34801561040a57600080fd5b5061042b610419366004612c93565b600e6020526000908152604090205481565b604051908152602001610366565b34801561044557600080fd5b5061042b610454366004612c93565b600f6020526000908152604090205481565b34801561047257600080fd5b50600454600354036000190161042b565b6103dc610491366004612ced565b610bab565b3480156104a257600080fd5b5061042b6104b1366004612c93565b6000908152600160208190526040909120015490565b3480156104d357600080fd5b50600c5461035a90600160a01b900460ff1681565b3480156104f457600080fd5b506103dc610503366004612d2e565b610d49565b34801561051457600080fd5b506103dc610523366004612d2e565b610d75565b34801561053457600080fd5b506103dc610df8565b6103dc61054b366004612ced565b610e11565b34801561055c57600080fd5b506103dc61056b366004612d5e565b610e2c565b34801561057c57600080fd5b5061059061058b366004612e1a565b610f15565b6040516103669190612e97565b3480156105a957600080fd5b506103b16105b8366004612c93565b610fc7565b3480156105c957600080fd5b50610384610fd2565b3480156105de57600080fd5b5061042b6105ed366004612c93565b611060565b3480156105fe57600080fd5b506103dc61060d366004612ed9565b61106d565b34801561061e57600080fd5b506103b1731e0049783f008a0085193e00003d00cd54003c7181565b34801561064657600080fd5b5061042b610655366004612ed9565b611117565b34801561066657600080fd5b506103dc611165565b34801561067b57600080fd5b506103dc61068a366004612ef6565b6111cb565b34801561069b57600080fd5b5061042b600381565b3480156106b057600080fd5b506106c46106bf366004612ed9565b6112e6565b6040516103669190612f4a565b3480156106dd57600080fd5b5061042b600181565b3480156106f257600080fd5b506000546001600160a01b03166103b1565b34801561071057600080fd5b5061035a61071f366004612d2e565b6113d3565b34801561073057600080fd5b506106c46113fe565b34801561074557600080fd5b5061038461140f565b34801561075a57600080fd5b506106c4610769366004612f82565b61141e565b34801561077a57600080fd5b5061042b600081565b34801561078f57600080fd5b506103dc61079e366004612fcc565b6115a9565b3480156107af57600080fd5b5061042b611615565b3480156107c457600080fd5b50600c546103b1906001600160a01b031681565b3480156107e457600080fd5b506106c46107f3366004612ed9565b611624565b34801561080457600080fd5b50610818610813366004612c93565b611849565b60405161036693929190613001565b6103dc610835366004613066565b61188b565b34801561084657600080fd5b5061042b610855366004612c93565b6118d5565b34801561086657600080fd5b5061042b610875366004612c93565b6118e2565b34801561088657600080fd5b5061089a610895366004612c93565b611903565b6040516103669190613129565b3480156108b357600080fd5b506103846108c2366004612c93565b611953565b3480156108d357600080fd5b506103dc6108e2366004612d2e565b6119d7565b3480156108f357600080fd5b5061042b6107d081565b34801561090957600080fd5b5061042b610918366004612ed9565b6119fe565b34801561092957600080fd5b506103b1600081565b34801561093e57600080fd5b5061035a61094d366004613137565b611a28565b34801561095e57600080fd5b506103dc61096d366004613165565b611a96565b34801561097e57600080fd5b506103dc61098d366004612ed9565b611b3d565b34801561099e57600080fd5b506103b17f000000000000000000000000000000000000000000000000000000000000000081565b3480156109d257600080fd5b5061042b60008051602061351183398151915281565b3480156109f457600080fd5b506103dc610a03366004612e1a565b611c05565b6000610a1382611c10565b80610a225750610a2282611c5e565b92915050565b606060058054610a3790613180565b80601f0160208091040260200160405190810160405280929190818152602001828054610a6390613180565b8015610ab05780601f10610a8557610100808354040283529160200191610ab0565b820191906000526020600020905b815481529060010190602001808311610a9357829003601f168201915b5050505050905090565b6000610ac582611c93565b610ae2576040516333d1c03960e21b815260040160405180910390fd5b506000908152600960205260409020546001600160a01b031690565b6000610b0982610fc7565b9050336001600160a01b03821614610b4257610b258133611a28565b610b42576040516367d9dca160e11b815260040160405180910390fd5b60008281526009602052604080822080546001600160a01b0319166001600160a01b0387811691821790925591518593918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b6000610a22601083611cc8565b6000610bb682611ce0565b9050836001600160a01b0316816001600160a01b031614610be95760405162a1148160e81b815260040160405180910390fd5b60008281526009602052604090208054338082146001600160a01b03881690911417610c3657610c198633611a28565b610c3657604051632ce44b5f60e11b815260040160405180910390fd5b6001600160a01b038516610c5d57604051633a954ecd60e21b815260040160405180910390fd5b610c6a8686866001611d49565b8015610c7557600082555b6001600160a01b038681166000908152600860205260408082208054600019019055918716808252919020805460010190554260a01b17600160e11b17600085815260076020526040902055600160e11b8316610d005760018401600081815260076020526040902054610cfe576003548114610cfe5760008181526007602052604090208490555b505b83856001600160a01b0316876001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050505050565b60008281526001602081905260409091200154610d668133611da4565b610d708383611e08565b505050565b6001600160a01b0381163314610dea5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084015b60405180910390fd5b610df48282611e73565b5050565b6000610e048133611da4565b610e0e3347611eda565b50565b610d708383836040518060200160405280600081525061188b565b600080516020613511833981519152610e458133611da4565b610e4d611ff3565b604051602001610e5d91906131bb565b604051602081830303815290604052805190602001208383604051602001610e869291906131d7565b604051602081830303815290604052805190602001201415610ebb5760405163df82d43b60e01b815260040160405180910390fd5b6000610ec5611ff3565b9050610ed3600d8585612b35565b507f309b29ded109b9e28fb9885757b3e0096eb75c51d23aa4635d68bcd569f6adc1818585604051610f07939291906131e7565b60405180910390a150505050565b6060816000816001600160401b03811115610f3257610f32613020565b604051908082528060200260200182016040528015610f6b57816020015b610f58612bb9565b815260200190600190039081610f505790505b50905060005b828114610fbe57610f99868683818110610f8d57610f8d61322d565b90506020020135611903565b828281518110610fab57610fab61322d565b6020908102919091010152600101610f71565b50949350505050565b6000610a2282611ce0565b600d8054610fdf90613180565b80601f016020809104026020016040519081016040528092919081815260200182805461100b90613180565b80156110585780601f1061102d57610100808354040283529160200191611058565b820191906000526020600020905b81548152906001019060200180831161103b57829003601f168201915b505050505081565b6000610a22826001612002565b6000805160206135118339815191526110868133611da4565b600c546001600160a01b03838116911614156110b55760405163df82d43b60e01b815260040160405180910390fd5b600c80546001600160a01b038481166001600160a01b031983168117909355604080519190921680825260208201939093527f4c040098ae777e3530660302202ceea5113846238aa009c6450f6a24c2259648910160405180910390a1505050565b60006001600160a01b038216611140576040516323d3ad8160e21b815260040160405180910390fd5b506001600160a01b03166000908152600860205260409020546001600160401b031690565b6000546001600160a01b031633146111bf5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610de1565b6111c960006121c3565b565b60028054141561121d5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610de1565b60028055600c54600160a01b900460ff1615156001146112505760405163914edb0f60e01b815260040160405180910390fd5b600c546001600160a01b0316611279576040516307c6bea960e11b815260040160405180910390fd5b61128281612213565b15156001146112a457604051638a164f6360e01b815260040160405180910390fd5b6112af828233612238565b15156001146112d1576040516344b9003760e11b815260040160405180910390fd5b6112dc8383836124af565b5050600160025550565b606060008060006112f685611117565b90506000816001600160401b0381111561131257611312613020565b60405190808252806020026020018201604052801561133b578160200160208202803683370190505b509050611346612bb9565b60015b8386146113c75761135981612591565b915081604001511561136a576113bf565b81516001600160a01b03161561137f57815194505b876001600160a01b0316856001600160a01b031614156113bf57808387806001019850815181106113b2576113b261322d565b6020026020010181815250505b600101611349565b50909695505050505050565b60009182526001602090815260408084206001600160a01b0393909316845291905290205460ff1690565b606061140a60106125b1565b905090565b606060068054610a3790613180565b606081831061144057604051631960ccad60e11b815260040160405180910390fd5b60008061144c60035490565b9050600185101561145c57600194505b80841115611468578093505b600061147387611117565b905084861015611492578585038181101561148c578091505b50611496565b5060005b6000816001600160401b038111156114b0576114b0613020565b6040519080825280602002602001820160405280156114d9578160200160208202803683370190505b509050816114ec5793506115a292505050565b60006114f788611903565b905060008160400151611508575080515b885b88811415801561151a5750848714155b156115965761152881612591565b92508260400151156115395761158e565b82516001600160a01b03161561154e57825191505b8a6001600160a01b0316826001600160a01b0316141561158e57808488806001019950815181106115815761158161322d565b6020026020010181815250505b60010161150a565b50505092835250909150505b9392505050565b336000818152600a602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b600061140a6003546000190190565b600c546060906001600160a01b0316611650576040516307c6bea960e11b815260040160405180910390fd5b600c54604051632118854760e21b81526001600160a01b0384811660048301526000921690638462151c9060240160006040518083038186803b15801561169657600080fd5b505afa1580156116aa573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526116d29190810190613243565b9050600081516001600160401b038111156116ef576116ef613020565b604051908082528060200260200182016040528015611718578160200160208202803683370190505b5090506000805b82518110156117a657600084828151811061173c5761173c61322d565b60200260200101519050600061175c826010611cc890919063ffffffff16565b151560011480159150611793578185858151811061177c5761177c61322d565b6020908102919091010152611790846132fe565b93505b50508061179f906132fe565b905061171f565b506000816001600160401b038111156117c1576117c1613020565b6040519080825280602002602001820160405280156117ea578160200160208202803683370190505b50905060005b8281101561183f5783818151811061180a5761180a61322d565b60200260200101518282815181106118245761182461322d565b6020908102919091010152611838816132fe565b90506117f0565b5095945050505050565b611851612bb9565b600080600061185f856125be565b9050600061186e866001612002565b9050600061187d876000612002565b929791965091945092505050565b611896848484610bab565b6001600160a01b0383163b156118cf576118b2848484846125d7565b6118cf576040516368d2bf6b60e11b815260040160405180910390fd5b50505050565b6000610a22826000612002565b600b81815481106118f257600080fd5b600091825260209091200154905081565b61190b612bb9565b611913612bb9565b600183108061192457506003548310155b1561192f5792915050565b61193883612591565b905080604001511561194a5792915050565b6115a2836125be565b606061195e82611c93565b61197b57604051630a14c4b560e41b815260040160405180910390fd5b6000611985611ff3565b90508051600014156119a657604051806020016040528060008152506115a2565b806119b0846126ce565b6040516020016119c1929190613319565b6040516020818303038152906040529392505050565b600082815260016020819052604090912001546119f48133611da4565b610d708383611e73565b6001600160a01b038116600090815260086020526040808220546001600160401b03911c16610a22565b6001600160a01b038083166000908152600a6020908152604080832093851683529290529081205460ff1615611a6057506001610a22565b6001600160a01b038216731e0049783f008a0085193e00003d00cd54003c711415611a8d57506001610a22565b50600092915050565b600080516020613511833981519152611aaf8133611da4565b600c5460ff600160a01b9091041615158215151415611ae15760405163df82d43b60e01b815260040160405180910390fd5b600c805460ff60a01b1916600160a01b8415158102919091179182905560405160ff9190920416151581527f4f6846e1a6a026ffba330735c9ca2845cfe23bccb44541d241c637b8542fa7a09060200160405180910390a15050565b6000546001600160a01b03163314611b975760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610de1565b6001600160a01b038116611bfc5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610de1565b610e0e816121c3565b610df43383836111cb565b60006301ffc9a760e01b6001600160e01b031983161480611c4157506380ac58cd60e01b6001600160e01b03198316145b80610a225750506001600160e01b031916635b5e139f60e01b1490565b60006001600160e01b03198216637965db0b60e01b1480610a2257506301ffc9a760e01b6001600160e01b0319831614610a22565b600081600111158015611ca7575060035482105b8015610a22575050600090815260076020526040902054600160e01b161590565b600081815260018301602052604081205415156115a2565b60008180600111611d3057600354811015611d3057600081815260076020526040902054600160e01b8116611d2e575b806115a2575060001901600081815260076020526040902054611d10565b505b604051636f96cda160e11b815260040160405180910390fd5b60005b81811015611d9d576000611d608285613348565b90506001600160a01b03861615611d8c57611d7c816000612002565b6000828152600f60205260409020555b50611d96816132fe565b9050611d4c565b5050505050565b611dae82826113d3565b610df457611dc6816001600160a01b0316601461271c565b611dd183602061271c565b604051602001611de2929190613360565b60408051601f198184030181529082905262461bcd60e51b8252610de191600401612c80565b611e1282826113d3565b610df45760008281526001602081815260408084206001600160a01b0386168086529252808420805460ff19169093179092559051339285917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9190a45050565b611e7d82826113d3565b15610df45760008281526001602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b80471015611f2a5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e63650000006044820152606401610de1565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114611f77576040519150601f19603f3d011682016040523d82523d6000602084013e611f7c565b606091505b5050905080610d705760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d617920686176652072657665727465640000000000006064820152608401610de1565b6060600d8054610a3790613180565b6000828152600f6020526040812054600b548110612021579050610a22565b600061202c856125be565b905060006201518082602001516001600160401b03164261204d91906133d5565b61205791906133ec565b9050600381101561206d57829350505050610a22565b81516040516370a0823160e01b81526001600160a01b0391821660048201526000917f000000000000000000000000000000000000000000000000000000000000000016906370a082319060240160206040518083038186803b1580156120d357600080fd5b505afa1580156120e7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061210b919061340e565b905060008661211b57600061211d565b815b612128906001613348565b90506000600384600b88815481106121425761214261322d565b90600052602060002001546121579190613348565b61216191906133d5565b9050600061216f8284613427565b90505b600b54871080156121a05750600b87815481106121915761219161322d565b90600052602060002001548110155b156121b5576121ae876132fe565b9650612172565b509498975050505050505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006107d0826122266003546000190190565b6122309190613348565b111592915050565b600c546000906001600160a01b0316612264576040516307c6bea960e11b815260040160405180910390fd5b600c546040805163d5abeb0160e01b815290516001926000926001600160a01b039091169163d5abeb0191600480820192602092909190829003018186803b1580156122af57600080fd5b505afa1580156122c3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122e7919061340e565b6001600160401b038111156122fe576122fe613020565b604051908082528060200260200182016040528015612327578160200160208202803683370190505b50905060005b85811080156123395750825b156124a45760008787838181106123525761235261322d565b9050602002013590506000612365600190565b61236f90836133d5565b9050600061238b600080516020613511833981519152896113d3565b8061241a5750600c546040516331a9108f60e11b8152600481018590526001600160a01b038a8116921690636352211e9060240160206040518083038186803b1580156123d757600080fd5b505afa1580156123eb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061240f9190613446565b6001600160a01b0316145b9050600061242784610b9e565b1515600115151415905060008684815181106124455761244561322d565b602090810291909101015115905082801561245d5750815b80156124665750805b9750600187858151811061247c5761247c61322d565b60200260200101901515908115158152505050505050508061249d906132fe565b905061232d565b509095945050505050565b60005b8181101561251f5760008383838181106124ce576124ce61322d565b9050602002013590506000826124e360035490565b6124ed9190613348565b6000818152600e60205260409020839055905061250b6010836128b7565b50505080612518906132fe565b90506124b2565b50600c5460405163b80f55c960e01b81526001600160a01b039091169063b80f55c9906125529085908590600401613463565b600060405180830381600087803b15801561256c57600080fd5b505af1158015612580573d6000803e3d6000fd5b50505050610d7083838390506128c3565b612599612bb9565b600082815260076020526040902054610a22906128dd565b606060006115a283612920565b6125c6612bb9565b610a226125d283611ce0565b6128dd565b604051630a85bd0160e11b81526000906001600160a01b0385169063150b7a029061260c90339089908890889060040161349f565b602060405180830381600087803b15801561262657600080fd5b505af1925050508015612656575060408051601f3d908101601f19168201909252612653918101906134dc565b60015b6126b1573d808015612684576040519150601f19603f3d011682016040523d82523d6000602084013e612689565b606091505b5080516126a9576040516368d2bf6b60e11b815260040160405180910390fd5b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050949350505050565b606060a06040510180604052602081039150506000815280825b600183039250600a81066030018353600a9004806127055761270a565b6126e8565b50819003601f19909101908152919050565b6060600061272b836002613427565b612736906002613348565b6001600160401b0381111561274d5761274d613020565b6040519080825280601f01601f191660200182016040528015612777576020820181803683370190505b509050600360fc1b816000815181106127925761279261322d565b60200101906001600160f81b031916908160001a905350600f60fb1b816001815181106127c1576127c161322d565b60200101906001600160f81b031916908160001a90535060006127e5846002613427565b6127f0906001613348565b90505b6001811115612868576f181899199a1a9b1b9c1cb0b131b232b360811b85600f16601081106128245761282461322d565b1a60f81b82828151811061283a5761283a61322d565b60200101906001600160f81b031916908160001a90535060049490941c93612861816134f9565b90506127f3565b5083156115a25760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610de1565b60006115a2838361297c565b610df48282604051806020016040528060008152506129cb565b6128e5612bb9565b6001600160a01b03821681526001600160401b0360a083901c166020820152600160e01b82161515604082015260e89190911c606082015290565b60608160000180548060200260200160405190810160405280929190818152602001828054801561297057602002820191906000526020600020905b81548152602001906001019080831161295c575b50505050509050919050565b60008181526001830160205260408120546129c357508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610a22565b506000610a22565b6129d58383612a31565b6001600160a01b0383163b15610d70576003548281035b6129ff60008683806001019450866125d7565b612a1c576040516368d2bf6b60e11b815260040160405180910390fd5b8181106129ec578160035414611d9d57600080fd5b60035481612a525760405163b562e8dd60e01b815260040160405180910390fd5b612a5f6000848385611d49565b6001600160a01b03831660008181526008602090815260408083208054680100000000000000018802019055848352600790915281206001851460e11b4260a01b178317905582840190839083907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8180a4600183015b818114612b0e57808360007fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef600080a4600101612ad6565b5081612b2c57604051622e076360e81b815260040160405180910390fd5b60035550505050565b828054612b4190613180565b90600052602060002090601f016020900481019282612b635760008555612ba9565b82601f10612b7c5782800160ff19823516178555612ba9565b82800160010185558215612ba9579182015b82811115612ba9578235825591602001919060010190612b8e565b50612bb5929150612be0565b5090565b60408051608081018252600080825260208201819052918101829052606081019190915290565b5b80821115612bb55760008155600101612be1565b6001600160e01b031981168114610e0e57600080fd5b600060208284031215612c1d57600080fd5b81356115a281612bf5565b60005b83811015612c43578181015183820152602001612c2b565b838111156118cf5750506000910152565b60008151808452612c6c816020860160208601612c28565b601f01601f19169290920160200192915050565b6020815260006115a26020830184612c54565b600060208284031215612ca557600080fd5b5035919050565b6001600160a01b0381168114610e0e57600080fd5b60008060408385031215612cd457600080fd5b8235612cdf81612cac565b946020939093013593505050565b600080600060608486031215612d0257600080fd5b8335612d0d81612cac565b92506020840135612d1d81612cac565b929592945050506040919091013590565b60008060408385031215612d4157600080fd5b823591506020830135612d5381612cac565b809150509250929050565b60008060208385031215612d7157600080fd5b82356001600160401b0380821115612d8857600080fd5b818501915085601f830112612d9c57600080fd5b813581811115612dab57600080fd5b866020828501011115612dbd57600080fd5b60209290920196919550909350505050565b60008083601f840112612de157600080fd5b5081356001600160401b03811115612df857600080fd5b6020830191508360208260051b8501011115612e1357600080fd5b9250929050565b60008060208385031215612e2d57600080fd5b82356001600160401b03811115612e4357600080fd5b612e4f85828601612dcf565b90969095509350505050565b80516001600160a01b031682526020808201516001600160401b03169083015260408082015115159083015260609081015162ffffff16910152565b6020808252825182820181905260009190848201906040850190845b818110156113c757612ec6838551612e5b565b9284019260809290920191600101612eb3565b600060208284031215612eeb57600080fd5b81356115a281612cac565b600080600060408486031215612f0b57600080fd5b8335612f1681612cac565b925060208401356001600160401b03811115612f3157600080fd5b612f3d86828701612dcf565b9497909650939450505050565b6020808252825182820181905260009190848201906040850190845b818110156113c757835183529284019291840191600101612f66565b600080600060608486031215612f9757600080fd5b8335612fa281612cac565b95602085013595506040909401359392505050565b80358015158114612fc757600080fd5b919050565b60008060408385031215612fdf57600080fd5b8235612fea81612cac565b9150612ff860208401612fb7565b90509250929050565b60c0810161300f8286612e5b565b608082019390935260a00152919050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b038111828210171561305e5761305e613020565b604052919050565b6000806000806080858703121561307c57600080fd5b843561308781612cac565b935060208581013561309881612cac565b93506040860135925060608601356001600160401b03808211156130bb57600080fd5b818801915088601f8301126130cf57600080fd5b8135818111156130e1576130e1613020565b6130f3601f8201601f19168501613036565b9150808252898482850101111561310957600080fd5b808484018584013760008482840101525080935050505092959194509250565b60808101610a228284612e5b565b6000806040838503121561314a57600080fd5b823561315581612cac565b91506020830135612d5381612cac565b60006020828403121561317757600080fd5b6115a282612fb7565b600181811c9082168061319457607f821691505b602082108114156131b557634e487b7160e01b600052602260045260246000fd5b50919050565b600082516131cd818460208701612c28565b9190910192915050565b8183823760009101908152919050565b6040815260006131fa6040830186612c54565b8281036020840152838152838560208301376000602085830101526020601f19601f860116820101915050949350505050565b634e487b7160e01b600052603260045260246000fd5b6000602080838503121561325657600080fd5b82516001600160401b038082111561326d57600080fd5b818501915085601f83011261328157600080fd5b81518181111561329357613293613020565b8060051b91506132a4848301613036565b81815291830184019184810190888411156132be57600080fd5b938501935b838510156132dc578451825293850193908501906132c3565b98975050505050505050565b634e487b7160e01b600052601160045260246000fd5b6000600019821415613312576133126132e8565b5060010190565b6000835161332b818460208801612c28565b83519083019061333f818360208801612c28565b01949350505050565b6000821982111561335b5761335b6132e8565b500190565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351613398816017850160208801612c28565b7001034b99036b4b9b9b4b733903937b6329607d1b60179184019182015283516133c9816028840160208801612c28565b01602801949350505050565b6000828210156133e7576133e76132e8565b500390565b60008261340957634e487b7160e01b600052601260045260246000fd5b500490565b60006020828403121561342057600080fd5b5051919050565b6000816000190483118215151615613441576134416132e8565b500290565b60006020828403121561345857600080fd5b81516115a281612cac565b6020808252810182905260006001600160fb1b0383111561348357600080fd5b8260051b80856040850137600092016040019182525092915050565b6001600160a01b03858116825284166020820152604081018390526080606082018190526000906134d290830184612c54565b9695505050505050565b6000602082840312156134ee57600080fd5b81516115a281612bf5565b600081613508576135086132e8565b50600019019056fe97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b929a26469706673582212200443ef06a8014b69447be21cea29d34d523e8d7b870cb1ab859103d3f3c4b3e164736f6c63430008090033000000000000000000000000f68f9bf35312c228c9d213f31c477c92032d80b7000000000000000000000000353556cd160f9edf8908c3167249f1255faf6c65000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000003668747470733a2f2f6d657461646174612e746572726170696e67656e657369732e636f6d2f746f6b656e2d756e6976657273652d762f000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000c329d2dc3685ed3be3209b33daf37f60347c969d000000000000000000000000b643c924632f71ac70a982ebc7e4099620f076c1

Deployed Bytecode

0x6080604052600436106103355760003560e01c806387f65c91116101ab578063b94c54c7116100f7578063de0ce17d11610095578063f2fde38b1161006f578063f2fde38b14610972578063f4cc37bd14610992578063f5b541a6146109c6578063f9afb26a146109e857600080fd5b8063de0ce17d1461091d578063e985e9c514610932578063ee1cc9441461095257600080fd5b8063c87b56dd116100d1578063c87b56dd146108a7578063d547741f146108c7578063d5abeb01146108e7578063dc33e681146108fd57600080fd5b8063b94c54c71461083a578063bfe633a21461085a578063c23dc68f1461087a57600080fd5b8063a217fddf11610164578063a4bc32301161013e578063a4bc3230146107b8578063a937dfcb146107d8578063b40c2454146107f8578063b88d4fde1461082757600080fd5b8063a217fddf1461076e578063a22cb46514610783578063a2309ff8146107a357600080fd5b806387f65c91146106d15780638da5cb5b146106e657806391d1485414610704578063952abc461461072457806395d89b411461073957806399a2557a1461074e57600080fd5b80633ccfd60b116102855780636daa693c11610223578063715018a6116101fd578063715018a61461065a5780637c1f9eb11461066f5780637e1e80421461068f5780638462151c146106a457600080fd5b80636daa693c146105f2578063702d53941461061257806370a082311461063a57600080fd5b80635bbb21771161025f5780635bbb2177146105705780636352211e1461059d5780636c0360eb146105bd5780636d5e3032146105d257600080fd5b80633ccfd60b1461052857806342842e0e1461053d57806355f804b31461055057600080fd5b80630e88b22c116102f2578063248a9ca3116102cc578063248a9ca31461049657806325fd90f3146104c75780632f2ff15d146104e857806336568abe1461050857600080fd5b80630e88b22c1461043957806318160ddd1461046657806323b872dd1461048357600080fd5b806301ffc9a71461033a57806306fdde031461036f578063081812fc14610391578063095ea7b3146103c95780630be8d880146103de5780630dddeb60146103fe575b600080fd5b34801561034657600080fd5b5061035a610355366004612c0b565b610a08565b60405190151581526020015b60405180910390f35b34801561037b57600080fd5b50610384610a28565b6040516103669190612c80565b34801561039d57600080fd5b506103b16103ac366004612c93565b610aba565b6040516001600160a01b039091168152602001610366565b6103dc6103d7366004612cc1565b610afe565b005b3480156103ea57600080fd5b5061035a6103f9366004612c93565b610b9e565b34801561040a57600080fd5b5061042b610419366004612c93565b600e6020526000908152604090205481565b604051908152602001610366565b34801561044557600080fd5b5061042b610454366004612c93565b600f6020526000908152604090205481565b34801561047257600080fd5b50600454600354036000190161042b565b6103dc610491366004612ced565b610bab565b3480156104a257600080fd5b5061042b6104b1366004612c93565b6000908152600160208190526040909120015490565b3480156104d357600080fd5b50600c5461035a90600160a01b900460ff1681565b3480156104f457600080fd5b506103dc610503366004612d2e565b610d49565b34801561051457600080fd5b506103dc610523366004612d2e565b610d75565b34801561053457600080fd5b506103dc610df8565b6103dc61054b366004612ced565b610e11565b34801561055c57600080fd5b506103dc61056b366004612d5e565b610e2c565b34801561057c57600080fd5b5061059061058b366004612e1a565b610f15565b6040516103669190612e97565b3480156105a957600080fd5b506103b16105b8366004612c93565b610fc7565b3480156105c957600080fd5b50610384610fd2565b3480156105de57600080fd5b5061042b6105ed366004612c93565b611060565b3480156105fe57600080fd5b506103dc61060d366004612ed9565b61106d565b34801561061e57600080fd5b506103b1731e0049783f008a0085193e00003d00cd54003c7181565b34801561064657600080fd5b5061042b610655366004612ed9565b611117565b34801561066657600080fd5b506103dc611165565b34801561067b57600080fd5b506103dc61068a366004612ef6565b6111cb565b34801561069b57600080fd5b5061042b600381565b3480156106b057600080fd5b506106c46106bf366004612ed9565b6112e6565b6040516103669190612f4a565b3480156106dd57600080fd5b5061042b600181565b3480156106f257600080fd5b506000546001600160a01b03166103b1565b34801561071057600080fd5b5061035a61071f366004612d2e565b6113d3565b34801561073057600080fd5b506106c46113fe565b34801561074557600080fd5b5061038461140f565b34801561075a57600080fd5b506106c4610769366004612f82565b61141e565b34801561077a57600080fd5b5061042b600081565b34801561078f57600080fd5b506103dc61079e366004612fcc565b6115a9565b3480156107af57600080fd5b5061042b611615565b3480156107c457600080fd5b50600c546103b1906001600160a01b031681565b3480156107e457600080fd5b506106c46107f3366004612ed9565b611624565b34801561080457600080fd5b50610818610813366004612c93565b611849565b60405161036693929190613001565b6103dc610835366004613066565b61188b565b34801561084657600080fd5b5061042b610855366004612c93565b6118d5565b34801561086657600080fd5b5061042b610875366004612c93565b6118e2565b34801561088657600080fd5b5061089a610895366004612c93565b611903565b6040516103669190613129565b3480156108b357600080fd5b506103846108c2366004612c93565b611953565b3480156108d357600080fd5b506103dc6108e2366004612d2e565b6119d7565b3480156108f357600080fd5b5061042b6107d081565b34801561090957600080fd5b5061042b610918366004612ed9565b6119fe565b34801561092957600080fd5b506103b1600081565b34801561093e57600080fd5b5061035a61094d366004613137565b611a28565b34801561095e57600080fd5b506103dc61096d366004613165565b611a96565b34801561097e57600080fd5b506103dc61098d366004612ed9565b611b3d565b34801561099e57600080fd5b506103b17f000000000000000000000000f68f9bf35312c228c9d213f31c477c92032d80b781565b3480156109d257600080fd5b5061042b60008051602061351183398151915281565b3480156109f457600080fd5b506103dc610a03366004612e1a565b611c05565b6000610a1382611c10565b80610a225750610a2282611c5e565b92915050565b606060058054610a3790613180565b80601f0160208091040260200160405190810160405280929190818152602001828054610a6390613180565b8015610ab05780601f10610a8557610100808354040283529160200191610ab0565b820191906000526020600020905b815481529060010190602001808311610a9357829003601f168201915b5050505050905090565b6000610ac582611c93565b610ae2576040516333d1c03960e21b815260040160405180910390fd5b506000908152600960205260409020546001600160a01b031690565b6000610b0982610fc7565b9050336001600160a01b03821614610b4257610b258133611a28565b610b42576040516367d9dca160e11b815260040160405180910390fd5b60008281526009602052604080822080546001600160a01b0319166001600160a01b0387811691821790925591518593918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b6000610a22601083611cc8565b6000610bb682611ce0565b9050836001600160a01b0316816001600160a01b031614610be95760405162a1148160e81b815260040160405180910390fd5b60008281526009602052604090208054338082146001600160a01b03881690911417610c3657610c198633611a28565b610c3657604051632ce44b5f60e11b815260040160405180910390fd5b6001600160a01b038516610c5d57604051633a954ecd60e21b815260040160405180910390fd5b610c6a8686866001611d49565b8015610c7557600082555b6001600160a01b038681166000908152600860205260408082208054600019019055918716808252919020805460010190554260a01b17600160e11b17600085815260076020526040902055600160e11b8316610d005760018401600081815260076020526040902054610cfe576003548114610cfe5760008181526007602052604090208490555b505b83856001600160a01b0316876001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050505050565b60008281526001602081905260409091200154610d668133611da4565b610d708383611e08565b505050565b6001600160a01b0381163314610dea5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084015b60405180910390fd5b610df48282611e73565b5050565b6000610e048133611da4565b610e0e3347611eda565b50565b610d708383836040518060200160405280600081525061188b565b600080516020613511833981519152610e458133611da4565b610e4d611ff3565b604051602001610e5d91906131bb565b604051602081830303815290604052805190602001208383604051602001610e869291906131d7565b604051602081830303815290604052805190602001201415610ebb5760405163df82d43b60e01b815260040160405180910390fd5b6000610ec5611ff3565b9050610ed3600d8585612b35565b507f309b29ded109b9e28fb9885757b3e0096eb75c51d23aa4635d68bcd569f6adc1818585604051610f07939291906131e7565b60405180910390a150505050565b6060816000816001600160401b03811115610f3257610f32613020565b604051908082528060200260200182016040528015610f6b57816020015b610f58612bb9565b815260200190600190039081610f505790505b50905060005b828114610fbe57610f99868683818110610f8d57610f8d61322d565b90506020020135611903565b828281518110610fab57610fab61322d565b6020908102919091010152600101610f71565b50949350505050565b6000610a2282611ce0565b600d8054610fdf90613180565b80601f016020809104026020016040519081016040528092919081815260200182805461100b90613180565b80156110585780601f1061102d57610100808354040283529160200191611058565b820191906000526020600020905b81548152906001019060200180831161103b57829003601f168201915b505050505081565b6000610a22826001612002565b6000805160206135118339815191526110868133611da4565b600c546001600160a01b03838116911614156110b55760405163df82d43b60e01b815260040160405180910390fd5b600c80546001600160a01b038481166001600160a01b031983168117909355604080519190921680825260208201939093527f4c040098ae777e3530660302202ceea5113846238aa009c6450f6a24c2259648910160405180910390a1505050565b60006001600160a01b038216611140576040516323d3ad8160e21b815260040160405180910390fd5b506001600160a01b03166000908152600860205260409020546001600160401b031690565b6000546001600160a01b031633146111bf5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610de1565b6111c960006121c3565b565b60028054141561121d5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610de1565b60028055600c54600160a01b900460ff1615156001146112505760405163914edb0f60e01b815260040160405180910390fd5b600c546001600160a01b0316611279576040516307c6bea960e11b815260040160405180910390fd5b61128281612213565b15156001146112a457604051638a164f6360e01b815260040160405180910390fd5b6112af828233612238565b15156001146112d1576040516344b9003760e11b815260040160405180910390fd5b6112dc8383836124af565b5050600160025550565b606060008060006112f685611117565b90506000816001600160401b0381111561131257611312613020565b60405190808252806020026020018201604052801561133b578160200160208202803683370190505b509050611346612bb9565b60015b8386146113c75761135981612591565b915081604001511561136a576113bf565b81516001600160a01b03161561137f57815194505b876001600160a01b0316856001600160a01b031614156113bf57808387806001019850815181106113b2576113b261322d565b6020026020010181815250505b600101611349565b50909695505050505050565b60009182526001602090815260408084206001600160a01b0393909316845291905290205460ff1690565b606061140a60106125b1565b905090565b606060068054610a3790613180565b606081831061144057604051631960ccad60e11b815260040160405180910390fd5b60008061144c60035490565b9050600185101561145c57600194505b80841115611468578093505b600061147387611117565b905084861015611492578585038181101561148c578091505b50611496565b5060005b6000816001600160401b038111156114b0576114b0613020565b6040519080825280602002602001820160405280156114d9578160200160208202803683370190505b509050816114ec5793506115a292505050565b60006114f788611903565b905060008160400151611508575080515b885b88811415801561151a5750848714155b156115965761152881612591565b92508260400151156115395761158e565b82516001600160a01b03161561154e57825191505b8a6001600160a01b0316826001600160a01b0316141561158e57808488806001019950815181106115815761158161322d565b6020026020010181815250505b60010161150a565b50505092835250909150505b9392505050565b336000818152600a602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b600061140a6003546000190190565b600c546060906001600160a01b0316611650576040516307c6bea960e11b815260040160405180910390fd5b600c54604051632118854760e21b81526001600160a01b0384811660048301526000921690638462151c9060240160006040518083038186803b15801561169657600080fd5b505afa1580156116aa573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526116d29190810190613243565b9050600081516001600160401b038111156116ef576116ef613020565b604051908082528060200260200182016040528015611718578160200160208202803683370190505b5090506000805b82518110156117a657600084828151811061173c5761173c61322d565b60200260200101519050600061175c826010611cc890919063ffffffff16565b151560011480159150611793578185858151811061177c5761177c61322d565b6020908102919091010152611790846132fe565b93505b50508061179f906132fe565b905061171f565b506000816001600160401b038111156117c1576117c1613020565b6040519080825280602002602001820160405280156117ea578160200160208202803683370190505b50905060005b8281101561183f5783818151811061180a5761180a61322d565b60200260200101518282815181106118245761182461322d565b6020908102919091010152611838816132fe565b90506117f0565b5095945050505050565b611851612bb9565b600080600061185f856125be565b9050600061186e866001612002565b9050600061187d876000612002565b929791965091945092505050565b611896848484610bab565b6001600160a01b0383163b156118cf576118b2848484846125d7565b6118cf576040516368d2bf6b60e11b815260040160405180910390fd5b50505050565b6000610a22826000612002565b600b81815481106118f257600080fd5b600091825260209091200154905081565b61190b612bb9565b611913612bb9565b600183108061192457506003548310155b1561192f5792915050565b61193883612591565b905080604001511561194a5792915050565b6115a2836125be565b606061195e82611c93565b61197b57604051630a14c4b560e41b815260040160405180910390fd5b6000611985611ff3565b90508051600014156119a657604051806020016040528060008152506115a2565b806119b0846126ce565b6040516020016119c1929190613319565b6040516020818303038152906040529392505050565b600082815260016020819052604090912001546119f48133611da4565b610d708383611e73565b6001600160a01b038116600090815260086020526040808220546001600160401b03911c16610a22565b6001600160a01b038083166000908152600a6020908152604080832093851683529290529081205460ff1615611a6057506001610a22565b6001600160a01b038216731e0049783f008a0085193e00003d00cd54003c711415611a8d57506001610a22565b50600092915050565b600080516020613511833981519152611aaf8133611da4565b600c5460ff600160a01b9091041615158215151415611ae15760405163df82d43b60e01b815260040160405180910390fd5b600c805460ff60a01b1916600160a01b8415158102919091179182905560405160ff9190920416151581527f4f6846e1a6a026ffba330735c9ca2845cfe23bccb44541d241c637b8542fa7a09060200160405180910390a15050565b6000546001600160a01b03163314611b975760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610de1565b6001600160a01b038116611bfc5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610de1565b610e0e816121c3565b610df43383836111cb565b60006301ffc9a760e01b6001600160e01b031983161480611c4157506380ac58cd60e01b6001600160e01b03198316145b80610a225750506001600160e01b031916635b5e139f60e01b1490565b60006001600160e01b03198216637965db0b60e01b1480610a2257506301ffc9a760e01b6001600160e01b0319831614610a22565b600081600111158015611ca7575060035482105b8015610a22575050600090815260076020526040902054600160e01b161590565b600081815260018301602052604081205415156115a2565b60008180600111611d3057600354811015611d3057600081815260076020526040902054600160e01b8116611d2e575b806115a2575060001901600081815260076020526040902054611d10565b505b604051636f96cda160e11b815260040160405180910390fd5b60005b81811015611d9d576000611d608285613348565b90506001600160a01b03861615611d8c57611d7c816000612002565b6000828152600f60205260409020555b50611d96816132fe565b9050611d4c565b5050505050565b611dae82826113d3565b610df457611dc6816001600160a01b0316601461271c565b611dd183602061271c565b604051602001611de2929190613360565b60408051601f198184030181529082905262461bcd60e51b8252610de191600401612c80565b611e1282826113d3565b610df45760008281526001602081815260408084206001600160a01b0386168086529252808420805460ff19169093179092559051339285917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9190a45050565b611e7d82826113d3565b15610df45760008281526001602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b80471015611f2a5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e63650000006044820152606401610de1565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114611f77576040519150601f19603f3d011682016040523d82523d6000602084013e611f7c565b606091505b5050905080610d705760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d617920686176652072657665727465640000000000006064820152608401610de1565b6060600d8054610a3790613180565b6000828152600f6020526040812054600b548110612021579050610a22565b600061202c856125be565b905060006201518082602001516001600160401b03164261204d91906133d5565b61205791906133ec565b9050600381101561206d57829350505050610a22565b81516040516370a0823160e01b81526001600160a01b0391821660048201526000917f000000000000000000000000f68f9bf35312c228c9d213f31c477c92032d80b716906370a082319060240160206040518083038186803b1580156120d357600080fd5b505afa1580156120e7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061210b919061340e565b905060008661211b57600061211d565b815b612128906001613348565b90506000600384600b88815481106121425761214261322d565b90600052602060002001546121579190613348565b61216191906133d5565b9050600061216f8284613427565b90505b600b54871080156121a05750600b87815481106121915761219161322d565b90600052602060002001548110155b156121b5576121ae876132fe565b9650612172565b509498975050505050505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006107d0826122266003546000190190565b6122309190613348565b111592915050565b600c546000906001600160a01b0316612264576040516307c6bea960e11b815260040160405180910390fd5b600c546040805163d5abeb0160e01b815290516001926000926001600160a01b039091169163d5abeb0191600480820192602092909190829003018186803b1580156122af57600080fd5b505afa1580156122c3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122e7919061340e565b6001600160401b038111156122fe576122fe613020565b604051908082528060200260200182016040528015612327578160200160208202803683370190505b50905060005b85811080156123395750825b156124a45760008787838181106123525761235261322d565b9050602002013590506000612365600190565b61236f90836133d5565b9050600061238b600080516020613511833981519152896113d3565b8061241a5750600c546040516331a9108f60e11b8152600481018590526001600160a01b038a8116921690636352211e9060240160206040518083038186803b1580156123d757600080fd5b505afa1580156123eb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061240f9190613446565b6001600160a01b0316145b9050600061242784610b9e565b1515600115151415905060008684815181106124455761244561322d565b602090810291909101015115905082801561245d5750815b80156124665750805b9750600187858151811061247c5761247c61322d565b60200260200101901515908115158152505050505050508061249d906132fe565b905061232d565b509095945050505050565b60005b8181101561251f5760008383838181106124ce576124ce61322d565b9050602002013590506000826124e360035490565b6124ed9190613348565b6000818152600e60205260409020839055905061250b6010836128b7565b50505080612518906132fe565b90506124b2565b50600c5460405163b80f55c960e01b81526001600160a01b039091169063b80f55c9906125529085908590600401613463565b600060405180830381600087803b15801561256c57600080fd5b505af1158015612580573d6000803e3d6000fd5b50505050610d7083838390506128c3565b612599612bb9565b600082815260076020526040902054610a22906128dd565b606060006115a283612920565b6125c6612bb9565b610a226125d283611ce0565b6128dd565b604051630a85bd0160e11b81526000906001600160a01b0385169063150b7a029061260c90339089908890889060040161349f565b602060405180830381600087803b15801561262657600080fd5b505af1925050508015612656575060408051601f3d908101601f19168201909252612653918101906134dc565b60015b6126b1573d808015612684576040519150601f19603f3d011682016040523d82523d6000602084013e612689565b606091505b5080516126a9576040516368d2bf6b60e11b815260040160405180910390fd5b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050949350505050565b606060a06040510180604052602081039150506000815280825b600183039250600a81066030018353600a9004806127055761270a565b6126e8565b50819003601f19909101908152919050565b6060600061272b836002613427565b612736906002613348565b6001600160401b0381111561274d5761274d613020565b6040519080825280601f01601f191660200182016040528015612777576020820181803683370190505b509050600360fc1b816000815181106127925761279261322d565b60200101906001600160f81b031916908160001a905350600f60fb1b816001815181106127c1576127c161322d565b60200101906001600160f81b031916908160001a90535060006127e5846002613427565b6127f0906001613348565b90505b6001811115612868576f181899199a1a9b1b9c1cb0b131b232b360811b85600f16601081106128245761282461322d565b1a60f81b82828151811061283a5761283a61322d565b60200101906001600160f81b031916908160001a90535060049490941c93612861816134f9565b90506127f3565b5083156115a25760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610de1565b60006115a2838361297c565b610df48282604051806020016040528060008152506129cb565b6128e5612bb9565b6001600160a01b03821681526001600160401b0360a083901c166020820152600160e01b82161515604082015260e89190911c606082015290565b60608160000180548060200260200160405190810160405280929190818152602001828054801561297057602002820191906000526020600020905b81548152602001906001019080831161295c575b50505050509050919050565b60008181526001830160205260408120546129c357508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610a22565b506000610a22565b6129d58383612a31565b6001600160a01b0383163b15610d70576003548281035b6129ff60008683806001019450866125d7565b612a1c576040516368d2bf6b60e11b815260040160405180910390fd5b8181106129ec578160035414611d9d57600080fd5b60035481612a525760405163b562e8dd60e01b815260040160405180910390fd5b612a5f6000848385611d49565b6001600160a01b03831660008181526008602090815260408083208054680100000000000000018802019055848352600790915281206001851460e11b4260a01b178317905582840190839083907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8180a4600183015b818114612b0e57808360007fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef600080a4600101612ad6565b5081612b2c57604051622e076360e81b815260040160405180910390fd5b60035550505050565b828054612b4190613180565b90600052602060002090601f016020900481019282612b635760008555612ba9565b82601f10612b7c5782800160ff19823516178555612ba9565b82800160010185558215612ba9579182015b82811115612ba9578235825591602001919060010190612b8e565b50612bb5929150612be0565b5090565b60408051608081018252600080825260208201819052918101829052606081019190915290565b5b80821115612bb55760008155600101612be1565b6001600160e01b031981168114610e0e57600080fd5b600060208284031215612c1d57600080fd5b81356115a281612bf5565b60005b83811015612c43578181015183820152602001612c2b565b838111156118cf5750506000910152565b60008151808452612c6c816020860160208601612c28565b601f01601f19169290920160200192915050565b6020815260006115a26020830184612c54565b600060208284031215612ca557600080fd5b5035919050565b6001600160a01b0381168114610e0e57600080fd5b60008060408385031215612cd457600080fd5b8235612cdf81612cac565b946020939093013593505050565b600080600060608486031215612d0257600080fd5b8335612d0d81612cac565b92506020840135612d1d81612cac565b929592945050506040919091013590565b60008060408385031215612d4157600080fd5b823591506020830135612d5381612cac565b809150509250929050565b60008060208385031215612d7157600080fd5b82356001600160401b0380821115612d8857600080fd5b818501915085601f830112612d9c57600080fd5b813581811115612dab57600080fd5b866020828501011115612dbd57600080fd5b60209290920196919550909350505050565b60008083601f840112612de157600080fd5b5081356001600160401b03811115612df857600080fd5b6020830191508360208260051b8501011115612e1357600080fd5b9250929050565b60008060208385031215612e2d57600080fd5b82356001600160401b03811115612e4357600080fd5b612e4f85828601612dcf565b90969095509350505050565b80516001600160a01b031682526020808201516001600160401b03169083015260408082015115159083015260609081015162ffffff16910152565b6020808252825182820181905260009190848201906040850190845b818110156113c757612ec6838551612e5b565b9284019260809290920191600101612eb3565b600060208284031215612eeb57600080fd5b81356115a281612cac565b600080600060408486031215612f0b57600080fd5b8335612f1681612cac565b925060208401356001600160401b03811115612f3157600080fd5b612f3d86828701612dcf565b9497909650939450505050565b6020808252825182820181905260009190848201906040850190845b818110156113c757835183529284019291840191600101612f66565b600080600060608486031215612f9757600080fd5b8335612fa281612cac565b95602085013595506040909401359392505050565b80358015158114612fc757600080fd5b919050565b60008060408385031215612fdf57600080fd5b8235612fea81612cac565b9150612ff860208401612fb7565b90509250929050565b60c0810161300f8286612e5b565b608082019390935260a00152919050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b038111828210171561305e5761305e613020565b604052919050565b6000806000806080858703121561307c57600080fd5b843561308781612cac565b935060208581013561309881612cac565b93506040860135925060608601356001600160401b03808211156130bb57600080fd5b818801915088601f8301126130cf57600080fd5b8135818111156130e1576130e1613020565b6130f3601f8201601f19168501613036565b9150808252898482850101111561310957600080fd5b808484018584013760008482840101525080935050505092959194509250565b60808101610a228284612e5b565b6000806040838503121561314a57600080fd5b823561315581612cac565b91506020830135612d5381612cac565b60006020828403121561317757600080fd5b6115a282612fb7565b600181811c9082168061319457607f821691505b602082108114156131b557634e487b7160e01b600052602260045260246000fd5b50919050565b600082516131cd818460208701612c28565b9190910192915050565b8183823760009101908152919050565b6040815260006131fa6040830186612c54565b8281036020840152838152838560208301376000602085830101526020601f19601f860116820101915050949350505050565b634e487b7160e01b600052603260045260246000fd5b6000602080838503121561325657600080fd5b82516001600160401b038082111561326d57600080fd5b818501915085601f83011261328157600080fd5b81518181111561329357613293613020565b8060051b91506132a4848301613036565b81815291830184019184810190888411156132be57600080fd5b938501935b838510156132dc578451825293850193908501906132c3565b98975050505050505050565b634e487b7160e01b600052601160045260246000fd5b6000600019821415613312576133126132e8565b5060010190565b6000835161332b818460208801612c28565b83519083019061333f818360208801612c28565b01949350505050565b6000821982111561335b5761335b6132e8565b500190565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351613398816017850160208801612c28565b7001034b99036b4b9b9b4b733903937b6329607d1b60179184019182015283516133c9816028840160208801612c28565b01602801949350505050565b6000828210156133e7576133e76132e8565b500390565b60008261340957634e487b7160e01b600052601260045260246000fd5b500490565b60006020828403121561342057600080fd5b5051919050565b6000816000190483118215151615613441576134416132e8565b500290565b60006020828403121561345857600080fd5b81516115a281612cac565b6020808252810182905260006001600160fb1b0383111561348357600080fd5b8260051b80856040850137600092016040019182525092915050565b6001600160a01b03858116825284166020820152604081018390526080606082018190526000906134d290830184612c54565b9695505050505050565b6000602082840312156134ee57600080fd5b81516115a281612bf5565b600081613508576135086132e8565b50600019019056fe97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b929a26469706673582212200443ef06a8014b69447be21cea29d34d523e8d7b870cb1ab859103d3f3c4b3e164736f6c63430008090033

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

000000000000000000000000f68f9bf35312c228c9d213f31c477c92032d80b7000000000000000000000000353556cd160f9edf8908c3167249f1255faf6c65000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000003668747470733a2f2f6d657461646174612e746572726170696e67656e657369732e636f6d2f746f6b656e2d756e6976657273652d762f000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000c329d2dc3685ed3be3209b33daf37f60347c969d000000000000000000000000b643c924632f71ac70a982ebc7e4099620f076c1

-----Decoded View---------------
Arg [0] : terrapinGenesis_ (address): 0xf68f9Bf35312C228c9D213f31c477c92032d80b7
Arg [1] : terrapinUniverseVillainsCardPack_ (address): 0x353556CD160f9eDF8908c3167249f1255Faf6c65
Arg [2] : baseURI_ (string): https://metadata.terrapingenesis.com/token-universe-v/
Arg [3] : operators (address[]): 0xC329D2dC3685eD3BE3209b33DAF37f60347c969d,0xb643c924632f71ac70a982Ebc7E4099620f076C1

-----Encoded View---------------
10 Constructor Arguments found :
Arg [0] : 000000000000000000000000f68f9bf35312c228c9d213f31c477c92032d80b7
Arg [1] : 000000000000000000000000353556cd160f9edf8908c3167249f1255faf6c65
Arg [2] : 0000000000000000000000000000000000000000000000000000000000000080
Arg [3] : 00000000000000000000000000000000000000000000000000000000000000e0
Arg [4] : 0000000000000000000000000000000000000000000000000000000000000036
Arg [5] : 68747470733a2f2f6d657461646174612e746572726170696e67656e65736973
Arg [6] : 2e636f6d2f746f6b656e2d756e6976657273652d762f00000000000000000000
Arg [7] : 0000000000000000000000000000000000000000000000000000000000000002
Arg [8] : 000000000000000000000000c329d2dc3685ed3be3209b33daf37f60347c969d
Arg [9] : 000000000000000000000000b643c924632f71ac70a982ebc7e4099620f076c1


Loading...
Loading
Loading...
Loading
[ Download: CSV Export  ]
[ Download: CSV Export  ]

A token is a representation of an on-chain or off-chain asset. The token page shows information such as price, total supply, holders, transfers and social links. Learn more about this page in our Knowledge Base.