GLMR Price: $0.126159 (-6.36%)

Contract

0xfa8032396Fa04CDa1bA6EDe7cAe39E220F2B6931

Overview

GLMR Balance

Moonbeam Chain LogoMoonbeam Chain LogoMoonbeam Chain Logo0 GLMR

GLMR Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To

There are no matching entries

Please try again later

Parent Transaction Hash Block From To
View All Internal Transactions
Loading...
Loading

Similar Match Source Code
This contract matches the deployed Bytecode of the Source Code for Contract 0xEA03a3B1...5DE9b6116
The constructor portion of the code might be different and could alter the actual behaviour of the contract

Contract Name:
ERC721NFTProductContract

Compiler Version
v0.8.15+commit.e14f2714

Optimization Enabled:
Yes with 10000 runs

Other Settings:
default evmVersion
File 1 of 24 : ERC721NFTProductContract.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "../templates/ERC721NFTProduct.sol";

contract ERC721NFTProductContract is ERC721NFTProduct {
    constructor(
        Config.Deployment memory deploymentConfig,
        Config.Runtime memory runtimeConfig,
        RolesAddresses[] memory rolesAddresses
    ) initializer {
        initialize(deploymentConfig, runtimeConfig, rolesAddresses);
    }
}

File 2 of 24 : AccessControlUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/AccessControl.sol)

pragma solidity ^0.8.0;

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

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

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

    mapping(bytes32 => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

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

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

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

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

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

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

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     *
     * May emit a {RoleGranted} event.
     */
    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.
     *
     * May emit a {RoleRevoked} event.
     */
    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`.
     *
     * May emit a {RoleRevoked} event.
     */
    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.
     *
     * May emit a {RoleGranted} event.
     *
     * [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.
     *
     * May emit a {RoleGranted} event.
     */
    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.
     *
     * May emit a {RoleRevoked} event.
     */
    function _revokeRole(bytes32 role, address account) internal virtual {
        if (hasRole(role, account)) {
            _roles[role].members[account] = false;
            emit RoleRevoked(role, account, _msgSender());
        }
    }

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

File 4 of 24 : Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol)

pragma solidity ^0.8.2;

import "../../utils/AddressUpgradeable.sol";

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
 * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
 * case an upgrade adds a module that needs to be initialized.
 *
 * For example:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * contract MyToken is ERC20Upgradeable {
 *     function initialize() initializer public {
 *         __ERC20_init("MyToken", "MTK");
 *     }
 * }
 * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
 *     function initializeV2() reinitializer(2) public {
 *         __ERC20Permit_init("MyToken");
 *     }
 * }
 * ```
 *
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
 *
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 *
 * [CAUTION]
 * ====
 * Avoid leaving a contract uninitialized.
 *
 * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
 * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
 * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * /// @custom:oz-upgrades-unsafe-allow constructor
 * constructor() {
 *     _disableInitializers();
 * }
 * ```
 * ====
 */
abstract contract Initializable {
    /**
     * @dev Indicates that the contract has been initialized.
     * @custom:oz-retyped-from bool
     */
    uint8 private _initialized;

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

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

    /**
     * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
     * `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`.
     */
    modifier initializer() {
        bool isTopLevelCall = !_initializing;
        require(
            (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),
            "Initializable: contract is already initialized"
        );
        _initialized = 1;
        if (isTopLevelCall) {
            _initializing = true;
        }
        _;
        if (isTopLevelCall) {
            _initializing = false;
            emit Initialized(1);
        }
    }

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

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

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

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

pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";

/**
 * @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 ReentrancyGuardUpgradeable is Initializable {
    // 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;

    function __ReentrancyGuard_init() internal onlyInitializing {
        __ReentrancyGuard_init_unchained();
    }

    function __ReentrancyGuard_init_unchained() internal onlyInitializing {
        _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;
    }

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

File 6 of 24 : ERC721Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/ERC721.sol)

pragma solidity ^0.8.0;

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

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

    // Token name
    string private _name;

    // Token symbol
    string private _symbol;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        _approve(to, tokenId);
    }

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

        return _tokenApprovals[tokenId];
    }

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

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

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

        _transfer(from, to, tokenId);
    }

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

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

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the ERC721 protocol to prevent tokens from being forever locked.
     *
     * `data` is additional data, it has no specified format and it is sent in call to `to`.
     *
     * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
     * implement alternative mechanisms to perform token transfer, such as signature-based.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function _safeTransfer(
        address from,
        address to,
        uint256 tokenId,
        bytes memory data
    ) internal virtual {
        _transfer(from, to, tokenId);
        require(_checkOnERC721Received(from, to, tokenId, data), "ERC721: transfer to non ERC721Receiver implementer");
    }

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

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

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

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

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

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

        _balances[to] += 1;
        _owners[tokenId] = to;

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

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

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

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

        // Clear approvals
        _approve(address(0), tokenId);

        _balances[owner] -= 1;
        delete _owners[tokenId];

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

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

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

        _beforeTokenTransfer(from, to, tokenId);

        // Clear approvals from the previous owner
        _approve(address(0), tokenId);

        _balances[from] -= 1;
        _balances[to] += 1;
        _owners[tokenId] = to;

        emit Transfer(from, to, tokenId);

        _afterTokenTransfer(from, to, tokenId);
    }

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

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

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

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

    /**
     * @dev Hook that is called before any token transfer. This includes minting
     * and burning.
     *
     * 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, ``from``'s `tokenId` will be burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(
        address from,
        address to,
        uint256 tokenId
    ) internal virtual {}

    /**
     * @dev Hook that is called after any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _afterTokenTransfer(
        address from,
        address to,
        uint256 tokenId
    ) internal virtual {}

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

        return super.tokenURI(tokenId);
    }

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

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

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

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

File 8 of 24 : IERC721MetadataUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)

pragma solidity ^0.8.0;

import "../IERC721Upgradeable.sol";

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

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

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

File 9 of 24 : IERC721ReceiverUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)

pragma solidity ^0.8.0;

/**
 * @title ERC721 token receiver interface
 * @dev Interface for any contract that wants to support safeTransfers
 * from ERC721 asset contracts.
 */
interface IERC721ReceiverUpgradeable {
    /**
     * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
     * by `operator` from `from`, this function is called.
     *
     * It must return its Solidity selector to confirm the token transfer.
     * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
     *
     * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.
     */
    function onERC721Received(
        address operator,
        address from,
        uint256 tokenId,
        bytes calldata data
    ) external returns (bytes4);
}

File 10 of 24 : IERC721Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/IERC721.sol)

pragma solidity ^0.8.0;

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

/**
 * @dev Required interface of an ERC721 compliant contract.
 */
interface IERC721Upgradeable is IERC165Upgradeable {
    /**
     * @dev Emitted when `tokenId` token is transferred from `from` to `to`.
     */
    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);

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

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

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

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

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId,
        bytes calldata data
    ) external;

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

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

    /**
     * @dev Gives permission to `to` to transfer `tokenId` token to another account.
     * The approval is cleared when the token is transferred.
     *
     * Only a single account can be approved at a time, so approving the zero address clears previous approvals.
     *
     * Requirements:
     *
     * - The caller must own the token or be an approved operator.
     * - `tokenId` must exist.
     *
     * Emits an {Approval} event.
     */
    function approve(address to, uint256 tokenId) external;

    /**
     * @dev Approve or remove `operator` as an operator for the caller.
     * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
     *
     * Requirements:
     *
     * - The `operator` cannot be the caller.
     *
     * Emits an {ApprovalForAll} event.
     */
    function setApprovalForAll(address operator, bool _approved) external;

    /**
     * @dev Returns the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) external view returns (address operator);

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

File 11 of 24 : AddressUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library AddressUpgradeable {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

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

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

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

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

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

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

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

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

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

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

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

File 12 of 24 : ContextUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract ContextUpgradeable is Initializable {
    function __Context_init() internal onlyInitializing {
    }

    function __Context_init_unchained() internal onlyInitializing {
    }
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

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

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

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

pragma solidity ^0.8.0;

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

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
 * for the additional interface id that will be supported. For example:
 *
 * ```solidity
 * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
 *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
 * }
 * ```
 *
 * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
 */
abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable {
    function __ERC165_init() internal onlyInitializing {
    }

    function __ERC165_init_unchained() internal onlyInitializing {
    }
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IERC165Upgradeable).interfaceId;
    }

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

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

pragma solidity ^0.8.0;

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

File 15 of 24 : StringsUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)

pragma solidity ^0.8.0;

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

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        // 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);
    }

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

File 16 of 24 : IERC2981.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (interfaces/IERC2981.sol)

pragma solidity ^0.8.0;

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

/**
 * @dev Interface for the NFT Royalty Standard.
 *
 * A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal
 * support for royalty payments across all NFT marketplaces and ecosystem participants.
 *
 * _Available since v4.5._
 */
interface IERC2981 is IERC165 {
    /**
     * @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of
     * exchange. The royalty amount is denominated and should be paid in that same unit of exchange.
     */
    function royaltyInfo(uint256 tokenId, uint256 salePrice)
        external
        view
        returns (address receiver, uint256 royaltyAmount);
}

File 17 of 24 : ERC2981.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/common/ERC2981.sol)

pragma solidity ^0.8.0;

import "../../interfaces/IERC2981.sol";
import "../../utils/introspection/ERC165.sol";

/**
 * @dev Implementation of the NFT Royalty Standard, a standardized way to retrieve royalty payment information.
 *
 * Royalty information can be specified globally for all token ids via {_setDefaultRoyalty}, and/or individually for
 * specific token ids via {_setTokenRoyalty}. The latter takes precedence over the first.
 *
 * Royalty is specified as a fraction of sale price. {_feeDenominator} is overridable but defaults to 10000, meaning the
 * fee is specified in basis points by default.
 *
 * IMPORTANT: ERC-2981 only specifies a way to signal royalty information and does not enforce its payment. See
 * https://eips.ethereum.org/EIPS/eip-2981#optional-royalty-payments[Rationale] in the EIP. Marketplaces are expected to
 * voluntarily pay royalties together with sales, but note that this standard is not yet widely supported.
 *
 * _Available since v4.5._
 */
abstract contract ERC2981 is IERC2981, ERC165 {
    struct RoyaltyInfo {
        address receiver;
        uint96 royaltyFraction;
    }

    RoyaltyInfo private _defaultRoyaltyInfo;
    mapping(uint256 => RoyaltyInfo) private _tokenRoyaltyInfo;

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

    /**
     * @inheritdoc IERC2981
     */
    function royaltyInfo(uint256 _tokenId, uint256 _salePrice) public view virtual override returns (address, uint256) {
        RoyaltyInfo memory royalty = _tokenRoyaltyInfo[_tokenId];

        if (royalty.receiver == address(0)) {
            royalty = _defaultRoyaltyInfo;
        }

        uint256 royaltyAmount = (_salePrice * royalty.royaltyFraction) / _feeDenominator();

        return (royalty.receiver, royaltyAmount);
    }

    /**
     * @dev The denominator with which to interpret the fee set in {_setTokenRoyalty} and {_setDefaultRoyalty} as a
     * fraction of the sale price. Defaults to 10000 so fees are expressed in basis points, but may be customized by an
     * override.
     */
    function _feeDenominator() internal pure virtual returns (uint96) {
        return 10000;
    }

    /**
     * @dev Sets the royalty information that all ids in this contract will default to.
     *
     * Requirements:
     *
     * - `receiver` cannot be the zero address.
     * - `feeNumerator` cannot be greater than the fee denominator.
     */
    function _setDefaultRoyalty(address receiver, uint96 feeNumerator) internal virtual {
        require(feeNumerator <= _feeDenominator(), "ERC2981: royalty fee will exceed salePrice");
        require(receiver != address(0), "ERC2981: invalid receiver");

        _defaultRoyaltyInfo = RoyaltyInfo(receiver, feeNumerator);
    }

    /**
     * @dev Removes default royalty information.
     */
    function _deleteDefaultRoyalty() internal virtual {
        delete _defaultRoyaltyInfo;
    }

    /**
     * @dev Sets the royalty information for a specific token id, overriding the global default.
     *
     * Requirements:
     *
     * - `receiver` cannot be the zero address.
     * - `feeNumerator` cannot be greater than the fee denominator.
     */
    function _setTokenRoyalty(
        uint256 tokenId,
        address receiver,
        uint96 feeNumerator
    ) internal virtual {
        require(feeNumerator <= _feeDenominator(), "ERC2981: royalty fee will exceed salePrice");
        require(receiver != address(0), "ERC2981: Invalid parameters");

        _tokenRoyaltyInfo[tokenId] = RoyaltyInfo(receiver, feeNumerator);
    }

    /**
     * @dev Resets royalty information for the token id back to the global default.
     */
    function _resetTokenRoyalty(uint256 tokenId) internal virtual {
        delete _tokenRoyaltyInfo[tokenId];
    }
}

File 18 of 24 : 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 19 of 24 : 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 20 of 24 : Base64.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.14;

/// @title Base64
/// @notice Provides a function for encoding some bytes in base64
/// @author Brecht Devos <[email protected]>
library Base64 {
    bytes internal constant _TABLE =
        "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";

    /// @notice Encodes some bytes to the base64 representation
    function encode(bytes memory data) internal pure returns (string memory) {
        uint256 len = data.length;
        if (len == 0) return "";

        // multiply by 4/3 rounded up
        uint256 encodedLen = 4 * ((len + 2) / 3);

        // Add some extra buffer at the end
        bytes memory result = new bytes(encodedLen + 32);

        bytes memory table = _TABLE;

        // solhint-disable-next-line no-inline-assembly
        assembly {
            let tablePtr := add(table, 1)
            let resultPtr := add(result, 32)

            for {
                let i := 0
            } lt(i, len) {
                // solhint-disable-previous-line no-empty-blocks
            } {
                i := add(i, 3)
                let input := and(mload(add(data, i)), 0xffffff)

                let out := mload(add(tablePtr, and(shr(18, input), 0x3F)))
                out := shl(8, out)
                out := add(
                    out,
                    and(mload(add(tablePtr, and(shr(12, input), 0x3F))), 0xFF)
                )
                out := shl(8, out)
                out := add(
                    out,
                    and(mload(add(tablePtr, and(shr(6, input), 0x3F))), 0xFF)
                )
                out := shl(8, out)
                out := add(
                    out,
                    and(mload(add(tablePtr, and(input, 0x3F))), 0xFF)
                )
                out := shl(224, out)

                mstore(resultPtr, out)

                resultPtr := add(resultPtr, 4)
            }

            switch mod(len, 3)
            case 1 {
                mstore(sub(resultPtr, 2), shl(240, 0x3d3d))
            }
            case 2 {
                mstore(sub(resultPtr, 1), shl(248, 0x3d))
            }

            mstore(result, encodedLen)
        }

        return string(result);
    }
}

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

library Config {
    /// Fixed at deployment time
    struct Deployment {
        // Name of the NFT contract.
        string name;
        // Symbol of the NFT contract.
        string symbol;
        // The contract owner address. If you wish to own the contract, then set it as your wallet address.
        // This is also the wallet that can manage the contract on NFT marketplaces.
        address owner;
        // If true, tokens may be burned by owner. Cannot be changed later.
        bool tokensBurnable;
    }

    /// Updatable by admins and owner
    struct Runtime {
        // Metadata base URI for tokens, NFTs minted in this contract will have metadata URI of `baseURI` + `tokenID`.
        // Set this to reveal token metadata.
        string baseURI;
        // If true, the base URI of the NFTs minted in the specified contract can be updated after minting (token URIs
        // are not frozen on the contract level). This is useful for revealing NFTs after the drop. If false, all the
        // NFTs minted in this contract are frozen by default which means token URIs are non-updatable.
        bool metadataUpdatable;
        // If true, tokens may be transferred by owner. Default is true. Can be only changed to false.
        bool tokensTransferable;
        // Secondary market royalties in basis points (100 bps = 1%)
        uint256 royaltiesBps;
        // Address for royalties
        address royaltiesAddress;
    }
}

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

import "contracts/@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";

/*
 * Custom roles handling abstract contract.
 * Used for fine-grained access controls to contracts.
 * Supported roles are:
 * - `ADMIN_ROLE`, is granted to the initializer and one other account specified during intialization
 * - `MINT_ROLE`, is used for minting tokens
 * - `UPDATE_CONTRACT_ROLE`, is used for updating the contract
 * - `BURN_ROLE`, is used for burning tokens
 * - `TRANSFER_ROLE`, is used for transferring tokens
 * `ADMIN_ROLE` has all the access rights for all the roles.
 *
 * Each role besides the `ADMIN_ROLE` can have any amount of addresses and can be made immutable.
 */
abstract contract GranularRoles is AccessControlUpgradeable {
    // Roles list
    // Admin role can have 2 addresses:
    // one address same as (_owner) which can be changed
    // one for NFTPort API access which can only be revoked
    bytes32 public constant ADMIN_ROLE = keccak256("ADMIN_ROLE");
    // Following roles can have multiple addresses, can be changed by admin or update contract role
    bytes32 public constant MINT_ROLE = keccak256("MINT_ROLE");
    bytes32 public constant UPDATE_CONTRACT_ROLE =
        keccak256("UPDATE_CONTRACT_ROLE");
    bytes32 public constant UPDATE_TOKEN_ROLE = keccak256("UPDATE_TOKEN_ROLE");
    bytes32 public constant BURN_ROLE = keccak256("BURN_ROLE");
    bytes32 public constant TRANSFER_ROLE = keccak256("TRANSFER_ROLE");

    /*
     * Used for intializing and updating roles
     * Each role can have any number of addresses attached to it and can be frozen separately,
     * meaning any further updates to it are disabled.
     * Cannot be used to update or initialize `ADMIN_ROLE`.
     */
    struct RolesAddresses {
        bytes32 role;
        address[] addresses;
        bool frozen;
    }

    // Contract owner address, this address can edit the contract on OpenSea and has `ADMIN_ROLE`
    address internal _owner;
    // Initialized as the address that initializes the contract.
    address internal _nftPort;

    // Used to get roles enumeration
    mapping(bytes32 => address[]) internal _rolesAddressesIndexed;
    // Mapping from role to boolean that shows if role can be updated
    mapping(bytes32 => bool) internal _rolesFrozen;

    // Event emitted when `transferOwnership` called by current owner.
    event OwnershipTransferred(
        address indexed previousOwner,
        address indexed newOwner
    );

    /*
     * Contract owner address
     * @dev Required for easy integration with OpenSea, the owner address can edit the collection there
     */
    function owner() public view returns (address) {
        return _owner;
    }

    // Transfer contract ownership, only callable by the current owner
    function transferOwnership(address newOwner) public {
        require(newOwner != _owner, "GranularRoles: already the owner");
        require(msg.sender == _owner, "GranularRoles: not the owner");
        _revokeRole(ADMIN_ROLE, _owner);
        address previousOwner = _owner;
        _owner = newOwner;
        _grantRole(ADMIN_ROLE, _owner);
        emit OwnershipTransferred(previousOwner, newOwner);
    }

    // Removes `ADMIN_ROLE` from the account that initialized the contract
    function revokeNFTPortPermissions() public onlyRole(ADMIN_ROLE) {
        _revokeRole(ADMIN_ROLE, _nftPort);
        _nftPort = address(0);
    }

    // Admin role has all access granted by default
    function hasRole(bytes32 role, address account)
        public
        view
        virtual
        override
        returns (bool)
    {
        // Contract owner has all access rights
        if (account == _owner) return true;
        // Anyone else cannot have DEFAULT_ADMIN_ROLE
        if (role == DEFAULT_ADMIN_ROLE) return false;
        // ADMIN_ROLE inherits any other roles
        return
            super.hasRole(ADMIN_ROLE, account) || super.hasRole(role, account);
    }

    /**
     * Initialize roles, should only be called once, for updating `_updateRoles` is used.
     * Can only be used to set the `_owner` and `_nftport` addresses,
     * or any amount of accounts for any supported role.
     */
    function _initRoles(address owner_, RolesAddresses[] memory rolesAddresses)
        internal
    {
        require(owner_ != address(0), "Contract must have an owner");
        _owner = owner_;
        _nftPort = msg.sender;
        _grantRole(ADMIN_ROLE, _owner);
        _grantRole(ADMIN_ROLE, _nftPort);

        // Loop through all roles from the input
        for (
            uint256 roleIndex = 0;
            roleIndex < rolesAddresses.length;
            roleIndex++
        ) {
            bytes32 role = rolesAddresses[roleIndex].role;
            // Check if the role is supported and is not `ADMIN_ROLE`
            require(
                _regularRoleValid(role),
                string(
                    abi.encodePacked(
                        "GranularRoles: invalid role ",
                        StringsUpgradeable.toHexString(uint256(role), 32)
                    )
                )
            );
            // Loop through all the addresses for the role being processed
            // Grant the given role to all the specified addresses
            // and add them to the roles enumaration `_rolesAddressesIndexed`
            for (
                uint256 addressIndex = 0;
                addressIndex < rolesAddresses[roleIndex].addresses.length;
                addressIndex++
            ) {
                _grantRole(
                    role,
                    rolesAddresses[roleIndex].addresses[addressIndex]
                );
                _rolesAddressesIndexed[role].push(
                    rolesAddresses[roleIndex].addresses[addressIndex]
                );
            }
            // If the given role is frozen then further updates to it are disabled
            if (rolesAddresses[roleIndex].frozen) {
                _rolesFrozen[role] = true;
            }
        }
    }

    /**
     * Used for updating and/or freezing roles.
     * Only callable by accounts with the `ADMIN_ROLE`
     * and cannot be used to update `ADMIN_ROLE`
     */
    function _updateRoles(RolesAddresses[] memory rolesAddresses) internal {
        if (rolesAddresses.length > 0) {
            require(
                hasRole(ADMIN_ROLE, msg.sender),
                "GranularRoles: not an admin"
            );

            // Loop through all roles from the input
            for (
                uint256 roleIndex = 0;
                roleIndex < rolesAddresses.length;
                roleIndex++
            ) {
                bytes32 role = rolesAddresses[roleIndex].role;
                // Check if the role is supported and is not `ADMIN_ROLE`
                require(
                    _regularRoleValid(role),
                    string(
                        abi.encodePacked(
                            "GranularRoles: invalid role ",
                            StringsUpgradeable.toHexString(uint256(role), 32)
                        )
                    )
                );
                // If given role is frozen then it cannot be updated
                require(
                    !_rolesFrozen[role],
                    string(
                        abi.encodePacked(
                            "GranularRoles: role ",
                            StringsUpgradeable.toHexString(uint256(role), 32),
                            " is frozen"
                        )
                    )
                );
                // Loop through all the addresses for the given role
                // Remove all accounts from the role being processed to add new ones from the input
                for (
                    uint256 addressIndex = 0;
                    addressIndex < _rolesAddressesIndexed[role].length;
                    addressIndex++
                ) {
                    _revokeRole(
                        role,
                        _rolesAddressesIndexed[role][addressIndex]
                    );
                }
                delete _rolesAddressesIndexed[role];
                // Loop through all the addresses for the given role from the input.
                // Grant roles to given addresses for the role being processed
                // and add the accounts to the role enumeration.
                for (
                    uint256 addressIndex = 0;
                    addressIndex < rolesAddresses[roleIndex].addresses.length;
                    addressIndex++
                ) {
                    _grantRole(
                        role,
                        rolesAddresses[roleIndex].addresses[addressIndex]
                    );
                    _rolesAddressesIndexed[role].push(
                        rolesAddresses[roleIndex].addresses[addressIndex]
                    );
                }
                if (rolesAddresses[roleIndex].frozen) {
                    _rolesFrozen[role] = true;
                }
            }
        }
    }

    // Checks if role is valid, does not contain the `ADMIN_ROLE`
    function _regularRoleValid(bytes32 role) internal pure returns (bool) {
        return
            role == MINT_ROLE ||
            role == UPDATE_CONTRACT_ROLE ||
            role == UPDATE_TOKEN_ROLE ||
            role == BURN_ROLE ||
            role == TRANSFER_ROLE;
    }
}

File 23 of 24 : ITemplate.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/*
 * Template interface, used by factory contracts to get the name and version of a contract,
 * that extends this interface.
 */
interface ITemplate {
    function NAME() external view returns (string memory);

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

File 24 of 24 : ERC721NFTProduct.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {IERC2981} from "contracts/@openzeppelin/contracts/token/common/ERC2981.sol";
import "contracts/@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721URIStorageUpgradeable.sol";
import "contracts/@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";

import "../lib/Base64.sol";
import "../lib/GranularRoles.sol";
import "../lib/Config.sol";
import "../lib/ITemplate.sol";

/*
 * ERC-721 proxy contract, meaning it does not make use of a constructor but rather uses `initialize` with `initializer`
 * modifier, see {Initializable}
 *
 * Minting and other write transactions only supported for accounts with relevant access rights.
 */
contract ERC721NFTProduct is
    ERC721URIStorageUpgradeable,
    GranularRoles,
    ITemplate,
    ReentrancyGuardUpgradeable
{
    /*******************************
     * Extensions, structs, events *
     *******************************/

    using StringsUpgradeable for uint256;

    /*
     * Event emitted to show opensea that metadata of a token is frozen,
     * see https://docs.opensea.io/docs/metadata-standards
     */
    event PermanentURI(string _value, uint256 indexed _id);
    // Event emitted to show that all tokens have their metadata frozen
    event PermanentURIGlobal();

    /*************
     * Constants *
     *************/

    // Template name
    string public constant NAME = "ERC721NFTProduct";
    // Template version
    uint256 public constant VERSION = 1_01_00;
    // Basis for calculating royalties.
    // This has to be 10k for royaltiesBps to be in basis points.
    uint16 public constant ROYALTIES_BASIS = 10000;

    /********************
     * Public variables *
     ********************/

    // If true then tokens metadata can be updated
    bool public metadataUpdatable;
    // If true then tokens can be burned by their owners
    bool public tokensBurnable;
    // If true then tokens can be transferred by having the correct access rights {GranularRoles-TRANSFER_ROLE}
    // if the token is owned by {GranularRoles-_owner} address
    bool public tokensTransferable;

    // Mapping of individually frozen tokens
    mapping(uint256 => bool) public freezeTokenUris;

    // Base URI of the tokens, token URIs are calculated as baseURI + tokenURI
    string public baseURI;

    // Address where royalties will be transferred to
    address public royaltiesAddress;
    // Secondary market royalties in basis points (100 bps = 1%). Royalties use ERC2981 standard and support
    // OpenSea standard.
    uint256 public royaltiesBasisPoints;

    // Counter for the total number of tokens minted in this contract
    uint256 public totalSupply;

    /***************************
     * Contract initialization *
     ***************************/

    constructor() initializer {
        // solhint-disable-previous-line no-empty-blocks
    }

    // Can only be called once, used because constructors cannot be used for proxy contracts
    function initialize(
        Config.Deployment memory deploymentConfig,
        Config.Runtime memory runtimeConfig,
        RolesAddresses[] memory rolesAddresses
    ) public initializer {
        // @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
        __ERC721_init(deploymentConfig.name, deploymentConfig.symbol);
        __ReentrancyGuard_init();

        _setRoyalties(
            runtimeConfig.royaltiesAddress,
            runtimeConfig.royaltiesBps
        );

        metadataUpdatable = runtimeConfig.metadataUpdatable;
        tokensBurnable = deploymentConfig.tokensBurnable;
        tokensTransferable = runtimeConfig.tokensTransferable;

        baseURI = runtimeConfig.baseURI;

        _initRoles(deploymentConfig.owner, rolesAddresses);
    }

    /*******************
     * Write functions *
     *******************/

    // Mint a token to input `caller` address
    function mintToCaller(
        address caller,
        uint256 tokenId,
        string memory tokenURI
    ) public onlyRole(MINT_ROLE) nonReentrant returns (uint256) {
        _safeMint(caller, tokenId);
        totalSupply += 1;

        _setTokenURI(tokenId, tokenURI);

        return tokenId;
    }

    /*
     * Function to update token URIs for individual tokens,
     * can be used to update and optionally freeze token URIs
     *
     * only callable if `metadataUpdatable` is true, the medatadata
     * for the token has not been frozen previously and the caller has `UPDATE_TOKEN_ROLE` (or `ADMIN_ROLE`) role
     */
    function updateTokenUri(
        uint256 _tokenId,
        string memory _tokenUri,
        bool _isFreezeTokenUri
    ) public onlyRole(UPDATE_TOKEN_ROLE) {
        require(_exists(_tokenId), "Token: Token does not exist");
        require(metadataUpdatable, "Token: Metadata is frozen");
        require(freezeTokenUris[_tokenId] != true, "Token: Token is frozen");
        require(
            _isFreezeTokenUri || (bytes(_tokenUri).length != 0),
            "Token: Token URI is missing"
        );

        if (bytes(_tokenUri).length != 0) {
            _setTokenURI(_tokenId, _tokenUri);
        }

        if (_isFreezeTokenUri) {
            freezeTokenUris[_tokenId] = true;
            emit PermanentURI(tokenURI(_tokenId), _tokenId);
        }
    }

    /*
     * Function to transfer tokens owned by the `_owner` address.
     *
     * only callable if `tokensTransferable` is true, the token to be transferred
     * is owned by `_owner` and the caller has `TRANSFER_ROLE` (or `ADMIN_ROLE`) role
     */
    function transferByOwner(address _to, uint256 _tokenId)
        public
        onlyRole(TRANSFER_ROLE)
    {
        require(tokensTransferable, "Transfer: Transfers are disabled");
        _safeTransfer(_owner, _to, _tokenId, "");
    }

    /*
     * Function to burn tokens owned by the `_owner` address.
     *
     * only callable if `tokensBurnable` is true, the token to be burned
     * is owned by `_owner` and the caller has `BURN_ROLE` (or `ADMIN_ROLE`) role
     */
    function burn(uint256 _tokenId) public onlyRole(BURN_ROLE) {
        require(tokensBurnable, "Burn: Burns are disabled");
        require(_exists(_tokenId), "Burn: Token does not exist");
        require(
            ERC721Upgradeable.ownerOf(_tokenId) == _owner,
            "Burn: not held by contract owner"
        );

        _burn(_tokenId);
        totalSupply -= 1;
    }

    /*
     * Function to update the collection configuration.
     *
     * Only callable if `metadataUpdatable` is true, or `baseURI` is not updated.
     * The ability to transfer tokens or update metadata can only be turned OFF with this, not vice-versa.
     *
     * This can also be used to revoke NFTPort access to the contract,
     * meaning access rights for NFTPort account will be removed.
     */
    function update(
        Config.Runtime calldata newConfig,
        RolesAddresses[] memory rolesAddresses,
        bool isRevokeNFTPortPermissions
    ) public onlyRole(UPDATE_CONTRACT_ROLE) {
        // If metadata is frozen, baseURI cannot be updated
        require(
            metadataUpdatable ||
                (keccak256(abi.encodePacked(newConfig.baseURI)) ==
                    keccak256(abi.encodePacked(baseURI))),
            "Update: Metadata is frozen"
        );

        baseURI = newConfig.baseURI;
        _setRoyalties(newConfig.royaltiesAddress, newConfig.royaltiesBps);

        if (!newConfig.tokensTransferable) {
            tokensTransferable = false;
        }
        if (!newConfig.metadataUpdatable && metadataUpdatable) {
            metadataUpdatable = false;
            emit PermanentURIGlobal();
        }

        _updateRoles(rolesAddresses);

        if (isRevokeNFTPortPermissions) {
            revokeNFTPortPermissions();
        }
    }

    /******************
     * View functions *
     ******************/

    function supportsInterface(bytes4 interfaceId)
        public
        view
        override(ERC721Upgradeable, AccessControlUpgradeable)
        returns (bool)
    {
        return
            ERC721Upgradeable.supportsInterface(interfaceId) ||
            interfaceId == type(IERC2981).interfaceId;
    }

    // @dev ERC2981 token royalty info
    function royaltyInfo(uint256, uint256 salePrice)
        external
        view
        returns (address, uint256)
    {
        return (
            royaltiesAddress,
            (royaltiesBasisPoints * salePrice) / ROYALTIES_BASIS
        );
    }

    /**
     * @dev OpenSea contract metadata, returns a base64 encoded JSON string containing royalties basis points
     * and royalties address
     */
    function contractURI() external view returns (string memory) {
        string memory json = Base64.encode(
            bytes(
                string(
                    abi.encodePacked(
                        '{"seller_fee_basis_points": ', // solhint-disable-line quotes
                        royaltiesBasisPoints.toString(),
                        ', "fee_recipient": "', // solhint-disable-line quotes
                        uint256(uint160(royaltiesAddress)).toHexString(20),
                        '"}' // solhint-disable-line quotes
                    )
                )
            )
        );

        string memory output = string(
            abi.encodePacked("data:application/json;base64,", json)
        );

        return output;
    }

    /*************
     * Internals *
     *************/

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

    function _setRoyalties(address newAddress, uint newBps) internal {
        require(newBps <= ROYALTIES_BASIS, "Cannot set royalties to over 100%");

        royaltiesAddress = newAddress;
        royaltiesBasisPoints = newBps;
    }
}

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

Contract Security Audit

Contract ABI

[{"inputs":[{"components":[{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"symbol","type":"string"},{"internalType":"address","name":"owner","type":"address"},{"internalType":"bool","name":"tokensBurnable","type":"bool"}],"internalType":"struct Config.Deployment","name":"deploymentConfig","type":"tuple"},{"components":[{"internalType":"string","name":"baseURI","type":"string"},{"internalType":"bool","name":"metadataUpdatable","type":"bool"},{"internalType":"bool","name":"tokensTransferable","type":"bool"},{"internalType":"uint256","name":"royaltiesBps","type":"uint256"},{"internalType":"address","name":"royaltiesAddress","type":"address"}],"internalType":"struct Config.Runtime","name":"runtimeConfig","type":"tuple"},{"components":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address[]","name":"addresses","type":"address[]"},{"internalType":"bool","name":"frozen","type":"bool"}],"internalType":"struct GranularRoles.RolesAddresses[]","name":"rolesAddresses","type":"tuple[]"}],"stateMutability":"nonpayable","type":"constructor"},{"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":"uint8","name":"version","type":"uint8"}],"name":"Initialized","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":false,"internalType":"string","name":"_value","type":"string"},{"indexed":true,"internalType":"uint256","name":"_id","type":"uint256"}],"name":"PermanentURI","type":"event"},{"anonymous":false,"inputs":[],"name":"PermanentURIGlobal","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":"ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"BURN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MINT_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"NAME","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ROYALTIES_BASIS","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"TRANSFER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"UPDATE_CONTRACT_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"UPDATE_TOKEN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"VERSION","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":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"baseURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"contractURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"freezeTokenUris","outputs":[{"internalType":"bool","name":"","type":"bool"}],"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":[{"components":[{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"symbol","type":"string"},{"internalType":"address","name":"owner","type":"address"},{"internalType":"bool","name":"tokensBurnable","type":"bool"}],"internalType":"struct Config.Deployment","name":"deploymentConfig","type":"tuple"},{"components":[{"internalType":"string","name":"baseURI","type":"string"},{"internalType":"bool","name":"metadataUpdatable","type":"bool"},{"internalType":"bool","name":"tokensTransferable","type":"bool"},{"internalType":"uint256","name":"royaltiesBps","type":"uint256"},{"internalType":"address","name":"royaltiesAddress","type":"address"}],"internalType":"struct Config.Runtime","name":"runtimeConfig","type":"tuple"},{"components":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address[]","name":"addresses","type":"address[]"},{"internalType":"bool","name":"frozen","type":"bool"}],"internalType":"struct GranularRoles.RolesAddresses[]","name":"rolesAddresses","type":"tuple[]"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","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":[],"name":"metadataUpdatable","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"caller","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"string","name":"tokenURI","type":"string"}],"name":"mintToCaller","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"revokeNFTPortPermissions","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":[],"name":"royaltiesAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"royaltiesBasisPoints","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"salePrice","type":"uint256"}],"name":"royaltyInfo","outputs":[{"internalType":"address","name":"","type":"address"},{"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":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tokensBurnable","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tokensTransferable","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"transferByOwner","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":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"string","name":"baseURI","type":"string"},{"internalType":"bool","name":"metadataUpdatable","type":"bool"},{"internalType":"bool","name":"tokensTransferable","type":"bool"},{"internalType":"uint256","name":"royaltiesBps","type":"uint256"},{"internalType":"address","name":"royaltiesAddress","type":"address"}],"internalType":"struct Config.Runtime","name":"newConfig","type":"tuple"},{"components":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address[]","name":"addresses","type":"address[]"},{"internalType":"bool","name":"frozen","type":"bool"}],"internalType":"struct GranularRoles.RolesAddresses[]","name":"rolesAddresses","type":"tuple[]"},{"internalType":"bool","name":"isRevokeNFTPortPermissions","type":"bool"}],"name":"update","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"string","name":"_tokenUri","type":"string"},{"internalType":"bool","name":"_isFreezeTokenUri","type":"bool"}],"name":"updateTokenUri","outputs":[],"stateMutability":"nonpayable","type":"function"}]

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106103155760003560e01c80637afdcdbb116101a7578063b88d4fde116100ee578063e8a3d48511610097578063f153c2e511610071578063f153c2e51461076d578063f2fde38b14610775578063ffa1ad741461078857600080fd5b8063e8a3d48514610702578063e985e9c51461070a578063e9a9c8501461074657600080fd5b8063d547741f116100c8578063d547741f146106c8578063de374d9d146106db578063e3d52072146106ef57600080fd5b8063b88d4fde1461067b578063b930908f1461068e578063c87b56dd146106b557600080fd5b8063a217fddf11610150578063a3f4df7e1161012a578063a3f4df7e1461060e578063a53a84b61461064a578063b29c097a1461065457600080fd5b8063a217fddf146105e0578063a22cb465146105e8578063a2f551ec146105fb57600080fd5b806391d148541161018157806391d14854146105a957806395d89b41146105bc5780639da5b0a5146105c457600080fd5b80637afdcdbb146105615780638d010db3146105745780638da5cb5b1461059857600080fd5b80632c23b9651161026b57806342966c68116102145780636c0360eb116101ee5780636c0360eb1461051f57806370a082311461052757806375b238fc1461053a57600080fd5b806342966c68146104eb5780634e6f9dd6146104fe5780636352211e1461050c57600080fd5b8063328825351161024557806332882535146104b157806336568abe146104c557806342842e0e146104d857600080fd5b80632c23b965146104645780632e628b611461048b5780632f2ff15d1461049e57600080fd5b8063206b60f9116102cd578063248a9ca3116102a7578063248a9ca3146103fc57806325d22c8e1461041f5780632a55205a1461043257600080fd5b8063206b60f9146103af57806321e92d49146103d657806323b872dd146103e957600080fd5b8063081812fc116102fe578063081812fc14610357578063095ea7b31461038257806318160ddd1461039757600080fd5b806301ffc9a71461031a57806306fdde0314610342575b600080fd5b61032d61032836600461371a565b610791565b60405190151581526020015b60405180910390f35b61034a6107ee565b604051610339919061378f565b61036a6103653660046137a2565b610880565b6040516001600160a01b039091168152602001610339565b6103956103903660046137d7565b6108a7565b005b6103a16101365481565b604051908152602001610339565b6103a17f8502233096d909befbda0999bb8ea2f3a6be3c138b9fbf003752a4c8bce86f6c81565b6103956103e43660046137d7565b6109dd565b6103956103f7366004613801565b610a89565b6103a161040a3660046137a2565b600090815260c9602052604090206001015490565b61039561042d366004613b78565b610b10565b610445610440366004613c74565b610d51565b604080516001600160a01b039093168352602083019190915201610339565b6103a17f9b16859c0d694afa65b1b6551542db11ea12d6208b6a17dc922f10f2d74440f581565b610395610499366004613c96565b610d8f565b6103956104ac366004613d12565b610f56565b6101345461036a906001600160a01b031681565b6103956104d3366004613d12565b610f7b565b6103956104e6366004613801565b611007565b6103956104f93660046137a2565b611022565b6101315461032d9060ff1681565b61036a61051a3660046137a2565b611199565b61034a6111fe565b6103a1610535366004613d3e565b61128d565b6103a17fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c2177581565b6103a161056f366004613d59565b611327565b61032d6105823660046137a2565b6101326020526000908152604090205460ff1681565b60fb546001600160a01b031661036a565b61032d6105b7366004613d12565b6113e5565b61034a611482565b6105cd61271081565b60405161ffff9091168152602001610339565b6103a1600081565b6103956105f6366004613da6565b611491565b610395610609366004613dd0565b61149c565b61034a6040518060400160405280601081526020017f4552433732314e465450726f647563740000000000000000000000000000000081525081565b6103a16101355481565b6103a17f852fd44a27d33057a8c3d90859d4e4c9f54309d4d66d1d968e063befba9198e681565b610395610689366004613e0f565b6116b0565b6103a17fe97b137254058bd94f28d2f3eb79e2d34074ffb488d042e3bc958e0a57d2fa2281565b61034a6106c33660046137a2565b611738565b6103956106d6366004613d12565b61183b565b6101315461032d9062010000900460ff1681565b6101315461032d90610100900460ff1681565b61034a611860565b61032d610718366004613e8b565b6001600160a01b039182166000908152606a6020908152604080832093909416825291909152205460ff1690565b6103a17f154c00819833dac601ee5ddded6fda79d9d8b506b911b3dbd54cdb95fe6c368681565b6103956118dc565b610395610783366004613d3e565b611968565b6103a161277481565b600061079c82611d62565b806107e857507fffffffff0000000000000000000000000000000000000000000000000000000082167f2a55205a00000000000000000000000000000000000000000000000000000000145b92915050565b6060606580546107fd90613eb5565b80601f016020809104026020016040519081016040528092919081815260200182805461082990613eb5565b80156108765780601f1061084b57610100808354040283529160200191610876565b820191906000526020600020905b81548152906001019060200180831161085957829003601f168201915b5050505050905090565b600061088b82611e45565b506000908152606960205260409020546001600160a01b031690565b60006108b282611199565b9050806001600160a01b0316836001600160a01b0316036109405760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560448201527f720000000000000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b336001600160a01b038216148061095c575061095c8133610718565b6109ce5760405162461bcd60e51b815260206004820152603e60248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60448201527f6b656e206f776e6572206e6f7220617070726f76656420666f7220616c6c00006064820152608401610937565b6109d88383611eac565b505050565b7f8502233096d909befbda0999bb8ea2f3a6be3c138b9fbf003752a4c8bce86f6c610a0781611f32565b6101315462010000900460ff16610a605760405162461bcd60e51b815260206004820181905260248201527f5472616e736665723a205472616e7366657273206172652064697361626c65646044820152606401610937565b60fb546040805160208101909152600081526109d8916001600160a01b03169085908590611f3c565b610a933382611fc5565b610b055760405162461bcd60e51b815260206004820152602e60248201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560448201527f72206e6f7220617070726f7665640000000000000000000000000000000000006064820152608401610937565b6109d8838383612043565b600054610100900460ff1615808015610b305750600054600160ff909116105b80610b4a5750303b158015610b4a575060005460ff166001145b610bbc5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a65640000000000000000000000000000000000006064820152608401610937565b6000805460ff191660011790558015610bfc57600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b610c0e84600001518560200151612228565b610c166122af565b610c2883608001518460600151612336565b6020830151610131805460608701516040870151151562010000027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ffff911515610100027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff951515959095167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000909316929092179390931792909216919091179055825161013390610cd99082613f56565b50610ce88460400151836123ee565b8015610d4b57600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050565b610134546101355460009182916001600160a01b039091169061271090610d79908690614045565b610d839190614093565b915091505b9250929050565b7f9b16859c0d694afa65b1b6551542db11ea12d6208b6a17dc922f10f2d74440f5610db981611f32565b6101315460ff1680610e245750610133604051602001610dd991906140a7565b60408051601f198184030181529190528051602090910120610dfb858061411d565b604051602001610e0c929190614182565b60405160208183030381529060405280519060200120145b610e705760405162461bcd60e51b815260206004820152601a60248201527f5570646174653a204d657461646174612069732066726f7a656e0000000000006044820152606401610937565b610e7a848061411d565b61013391610e89919083614192565b50610ea7610e9d60a0860160808701613d3e565b8560600135612336565b610eb76060850160408601614253565b610ee55761013180547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ffff1690555b610ef56040850160208601614253565b158015610f0557506101315460ff165b15610f3f57610131805460ff191690556040517fb59f45df38ec0d34114b1248c38a29cdbccbf3e745ae3ef310ac66199a4ceccf90600090a15b610f48836126c6565b8115610d4b57610d4b6118dc565b600082815260c96020526040902060010154610f7181611f32565b6109d883836129da565b6001600160a01b0381163314610ff95760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c6600000000000000000000000000000000006064820152608401610937565b6110038282612a60565b5050565b6109d8838383604051806020016040528060008152506116b0565b7fe97b137254058bd94f28d2f3eb79e2d34074ffb488d042e3bc958e0a57d2fa2261104c81611f32565b61013154610100900460ff166110a45760405162461bcd60e51b815260206004820152601860248201527f4275726e3a204275726e73206172652064697361626c656400000000000000006044820152606401610937565b6000828152606760205260409020546001600160a01b03166111085760405162461bcd60e51b815260206004820152601a60248201527f4275726e3a20546f6b656e20646f6573206e6f742065786973740000000000006044820152606401610937565b60fb546001600160a01b031661111d83611199565b6001600160a01b0316146111735760405162461bcd60e51b815260206004820181905260248201527f4275726e3a206e6f742068656c6420627920636f6e7472616374206f776e65726044820152606401610937565b61117c82612ac7565b60016101366000828254611190919061426e565b90915550505050565b6000818152606760205260408120546001600160a01b0316806107e85760405162461bcd60e51b815260206004820152601860248201527f4552433732313a20696e76616c696420746f6b656e20494400000000000000006044820152606401610937565b610133805461120c90613eb5565b80601f016020809104026020016040519081016040528092919081815260200182805461123890613eb5565b80156112855780601f1061125a57610100808354040283529160200191611285565b820191906000526020600020905b81548152906001019060200180831161126857829003601f168201915b505050505081565b60006001600160a01b03821661130b5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a2061646472657373207a65726f206973206e6f74206120766160448201527f6c6964206f776e657200000000000000000000000000000000000000000000006064820152608401610937565b506001600160a01b031660009081526068602052604090205490565b60007f154c00819833dac601ee5ddded6fda79d9d8b506b911b3dbd54cdb95fe6c368661135381611f32565b600260ff54036113a55760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610937565b600260ff556113b48585612b07565b600161013660008282546113c89190614285565b909155506113d890508484612b21565b5050600160ff5550919050565b60fb546000906001600160a01b0390811690831603611406575060016107e8565b82611413575060006107e8565b6001600160a01b03821660009081527f56eafcfe4e056e5ee1febf92b17728968883505f0e8dc799e4f43119d826ca85602052604090205460ff168061147b5750600083815260c9602090815260408083206001600160a01b038616845290915290205460ff165b9392505050565b6060606680546107fd90613eb5565b611003338383612bc3565b7f852fd44a27d33057a8c3d90859d4e4c9f54309d4d66d1d968e063befba9198e66114c681611f32565b6000848152606760205260409020546001600160a01b031661152a5760405162461bcd60e51b815260206004820152601b60248201527f546f6b656e3a20546f6b656e20646f6573206e6f7420657869737400000000006044820152606401610937565b6101315460ff1661157d5760405162461bcd60e51b815260206004820152601960248201527f546f6b656e3a204d657461646174612069732066726f7a656e000000000000006044820152606401610937565b6000848152610132602052604090205460ff1615156001036115e15760405162461bcd60e51b815260206004820152601660248201527f546f6b656e3a20546f6b656e2069732066726f7a656e000000000000000000006044820152606401610937565b81806115ed5750825115155b6116395760405162461bcd60e51b815260206004820152601b60248201527f546f6b656e3a20546f6b656e20555249206973206d697373696e6700000000006044820152606401610937565b82511561164a5761164a8484612b21565b8115610d4b57600084815261013260205260409020805460ff19166001179055837fa109ba539900bf1b633f956d63c96fc89b814c7287f7aa50a9216d0b5565720761169582611738565b6040516116a2919061378f565b60405180910390a250505050565b6116ba3383611fc5565b61172c5760405162461bcd60e51b815260206004820152602e60248201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560448201527f72206e6f7220617070726f7665640000000000000000000000000000000000006064820152608401610937565b610d4b84848484611f3c565b606061174382611e45565b6000828152609760205260408120805461175c90613eb5565b80601f016020809104026020016040519081016040528092919081815260200182805461178890613eb5565b80156117d55780601f106117aa576101008083540402835291602001916117d5565b820191906000526020600020905b8154815290600101906020018083116117b857829003601f168201915b5050505050905060006117e6612c91565b905080516000036117f8575092915050565b81511561182a57808260405160200161181292919061429d565b60405160208183030381529060405292505050919050565b61183384612ca1565b949350505050565b600082815260c9602052604090206001015461185681611f32565b6109d88383612a60565b606060006118b061187361013554612d07565b6101345461188b906001600160a01b03166014611b0e565b60405160200161189c9291906142cc565b604051602081830303815290604052612e3c565b90506000816040516020016118c59190614377565b60408051601f198184030181529190529392505050565b7fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c2177561190681611f32565b60fc5461193d907fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c21775906001600160a01b0316612a60565b5060fc80547fffffffffffffffffffffffff0000000000000000000000000000000000000000169055565b60fb546001600160a01b03908116908216036119c65760405162461bcd60e51b815260206004820181905260248201527f4772616e756c6172526f6c65733a20616c726561647920746865206f776e65726044820152606401610937565b60fb546001600160a01b03163314611a205760405162461bcd60e51b815260206004820152601c60248201527f4772616e756c6172526f6c65733a206e6f7420746865206f776e6572000000006044820152606401610937565b60fb54611a57907fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c21775906001600160a01b0316612a60565b60fb80546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093551690611abb907fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c21775906129da565b816001600160a01b0316816001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b6001600160a01b03163b151590565b60606000611b1d836002614045565b611b28906002614285565b67ffffffffffffffff811115611b4057611b4061383d565b6040519080825280601f01601f191660200182016040528015611b6a576020820181803683370190505b5090507f300000000000000000000000000000000000000000000000000000000000000081600081518110611ba157611ba16143bc565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f780000000000000000000000000000000000000000000000000000000000000081600181518110611c0457611c046143bc565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506000611c40846002614045565b611c4b906001614285565b90505b6001811115611ce8577f303132333435363738396162636465660000000000000000000000000000000085600f1660108110611c8c57611c8c6143bc565b1a60f81b828281518110611ca257611ca26143bc565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060049490941c93611ce1816143eb565b9050611c4e565b50831561147b5760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610937565b600091825260c9602090815260408084206001600160a01b0393909316845291905290205460ff1690565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f80ac58cd000000000000000000000000000000000000000000000000000000001480611df557507fffffffff0000000000000000000000000000000000000000000000000000000082167f5b5e139f00000000000000000000000000000000000000000000000000000000145b806107e857507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316146107e8565b6000818152606760205260409020546001600160a01b0316611ea95760405162461bcd60e51b815260206004820152601860248201527f4552433732313a20696e76616c696420746f6b656e20494400000000000000006044820152606401610937565b50565b600081815260696020526040902080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0384169081179091558190611ef982611199565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b611ea98133612ffb565b611f47848484612043565b611f538484848461305f565b610d4b5760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e74657200000000000000000000000000006064820152608401610937565b600080611fd183611199565b9050806001600160a01b0316846001600160a01b0316148061201857506001600160a01b038082166000908152606a602090815260408083209388168352929052205460ff165b806118335750836001600160a01b031661203184610880565b6001600160a01b031614949350505050565b826001600160a01b031661205682611199565b6001600160a01b0316146120d25760405162461bcd60e51b815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201527f6f776e65720000000000000000000000000000000000000000000000000000006064820152608401610937565b6001600160a01b03821661214d5760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f2061646460448201527f72657373000000000000000000000000000000000000000000000000000000006064820152608401610937565b612158600082611eac565b6001600160a01b038316600090815260686020526040812080546001929061218190849061426e565b90915550506001600160a01b03821660009081526068602052604081208054600192906121af908490614285565b909155505060008181526067602052604080822080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600054610100900460ff166122a55760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610937565b6110038282613200565b600054610100900460ff1661232c5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610937565b612334613296565b565b6127108111156123ae5760405162461bcd60e51b815260206004820152602160248201527f43616e6e6f742073657420726f79616c7469657320746f206f7665722031303060448201527f25000000000000000000000000000000000000000000000000000000000000006064820152608401610937565b61013480547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b03939093169290921790915561013555565b6001600160a01b0382166124445760405162461bcd60e51b815260206004820152601b60248201527f436f6e7472616374206d757374206861766520616e206f776e657200000000006044820152606401610937565b60fb80546001600160a01b0384167fffffffffffffffffffffffff0000000000000000000000000000000000000000918216811790925560fc8054909116331790556124b1907fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c21775906129da565b60fc546124e8907fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c21775906001600160a01b03166129da565b60005b81518110156109d8576000828281518110612508576125086143bc565b602002602001015160000151905061251f8161331a565b61252a826020611b0e565b60405160200161253a9190614402565b604051602081830303815290604052906125675760405162461bcd60e51b8152600401610937919061378f565b5060005b83838151811061257d5761257d6143bc565b60200260200101516020015151811015612675576125d1828585815181106125a7576125a76143bc565b60200260200101516020015183815181106125c4576125c46143bc565b60200260200101516129da565b600082815260fd6020526040902084518590859081106125f3576125f36143bc565b6020026020010151602001518281518110612610576126106143bc565b60209081029190910181015182546001810184556000938452919092200180547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b039092169190911790558061266d81614447565b91505061256b565b50828281518110612688576126886143bc565b602002602001015160400151156126b357600081815260fe60205260409020805460ff191660011790555b50806126be81614447565b9150506124eb565b805115611ea9576126f77fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c21775336113e5565b6127435760405162461bcd60e51b815260206004820152601b60248201527f4772616e756c6172526f6c65733a206e6f7420616e2061646d696e00000000006044820152606401610937565b60005b8151811015611003576000828281518110612763576127636143bc565b602002602001015160000151905061277a8161331a565b612785826020611b0e565b6040516020016127959190614402565b604051602081830303815290604052906127c25760405162461bcd60e51b8152600401610937919061378f565b50600081815260fe602090815260409091205460ff1615906127e5908390611b0e565b6040516020016127f59190614461565b604051602081830303815290604052906128225760405162461bcd60e51b8152600401610937919061378f565b5060005b600082815260fd602052604090205481101561288e57600082815260fd60205260409020805461287c91849184908110612862576128626143bc565b6000918252602090912001546001600160a01b0316612a60565b8061288681614447565b915050612826565b50600081815260fd602052604081206128a69161367f565b60005b8383815181106128bb576128bb6143bc565b60200260200101516020015151811015612989576128e5828585815181106125a7576125a76143bc565b600082815260fd602052604090208451859085908110612907576129076143bc565b6020026020010151602001518281518110612924576129246143bc565b60209081029190910181015182546001810184556000938452919092200180547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b039092169190911790558061298181614447565b9150506128a9565b5082828151811061299c5761299c6143bc565b602002602001015160400151156129c757600081815260fe60205260409020805460ff191660011790555b50806129d281614447565b915050612746565b6129e482826113e5565b61100357600082815260c9602090815260408083206001600160a01b03851684529091529020805460ff19166001179055612a1c3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b612a6a82826113e5565b1561100357600082815260c9602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b612ad0816133e9565b60008181526097602052604090208054612ae990613eb5565b159050611ea9576000818152609760205260408120611ea99161369d565b61100382826040518060200160405280600081525061349c565b6000828152606760205260409020546001600160a01b0316612bab5760405162461bcd60e51b815260206004820152602e60248201527f45524337323155524953746f726167653a2055524920736574206f66206e6f6e60448201527f6578697374656e7420746f6b656e0000000000000000000000000000000000006064820152608401610937565b60008281526097602052604090206109d88282613f56565b816001600160a01b0316836001600160a01b031603612c245760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610937565b6001600160a01b038381166000818152606a6020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b606061013380546107fd90613eb5565b6060612cac82611e45565b6000612cb6612c91565b90506000815111612cd6576040518060200160405280600081525061147b565b80612ce084612d07565b604051602001612cf192919061429d565b6040516020818303038152906040529392505050565b606081600003612d4a57505060408051808201909152600181527f3000000000000000000000000000000000000000000000000000000000000000602082015290565b8160005b8115612d745780612d5e81614447565b9150612d6d9050600a83614093565b9150612d4e565b60008167ffffffffffffffff811115612d8f57612d8f61383d565b6040519080825280601f01601f191660200182016040528015612db9576020820181803683370190505b5090505b841561183357612dce60018361426e565b9150612ddb600a866144cd565b612de6906030614285565b60f81b818381518110612dfb57612dfb6143bc565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350612e35600a86614093565b9450612dbd565b80516060906000819003612e60575050604080516020810190915260008152919050565b60006003612e6f836002614285565b612e799190614093565b612e84906004614045565b90506000612e93826020614285565b67ffffffffffffffff811115612eab57612eab61383d565b6040519080825280601f01601f191660200182016040528015612ed5576020820181803683370190505b50905060006040518060600160405280604081526020016145bc604091399050600181016020830160005b86811015612f61576003818a01810151603f601282901c8116860151600c83901c8216870151600684901c831688015192909316870151600891821b60ff94851601821b92841692909201901b91160160e01b835260049092019101612f00565b506003860660018114612f7b5760028114612fc557612fed565b7f3d3d0000000000000000000000000000000000000000000000000000000000007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe830152612fed565b7f3d000000000000000000000000000000000000000000000000000000000000006000198301525b505050918152949350505050565b61300582826113e5565b6110035761301d816001600160a01b03166014611b0e565b613028836020611b0e565b6040516020016130399291906144e1565b60408051601f198184030181529082905262461bcd60e51b82526109379160040161378f565b60006001600160a01b0384163b156131f5576040517f150b7a020000000000000000000000000000000000000000000000000000000081526001600160a01b0385169063150b7a02906130bc903390899088908890600401614562565b6020604051808303816000875af19250505080156130f7575060408051601f3d908101601f191682019092526130f49181019061459e565b60015b6131aa573d808015613125576040519150601f19603f3d011682016040523d82523d6000602084013e61312a565b606091505b5080516000036131a25760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e74657200000000000000000000000000006064820152608401610937565b805181602001fd5b7fffffffff00000000000000000000000000000000000000000000000000000000167f150b7a0200000000000000000000000000000000000000000000000000000000149050611833565b506001949350505050565b600054610100900460ff1661327d5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610937565b60656132898382613f56565b5060666109d88282613f56565b600054610100900460ff166133135760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610937565b600160ff55565b60007f154c00819833dac601ee5ddded6fda79d9d8b506b911b3dbd54cdb95fe6c368682148061336957507f9b16859c0d694afa65b1b6551542db11ea12d6208b6a17dc922f10f2d74440f582145b8061339357507f852fd44a27d33057a8c3d90859d4e4c9f54309d4d66d1d968e063befba9198e682145b806133bd57507fe97b137254058bd94f28d2f3eb79e2d34074ffb488d042e3bc958e0a57d2fa2282145b806107e85750507f8502233096d909befbda0999bb8ea2f3a6be3c138b9fbf003752a4c8bce86f6c1490565b60006133f482611199565b9050613401600083611eac565b6001600160a01b038116600090815260686020526040812080546001929061342a90849061426e565b909155505060008281526067602052604080822080547fffffffffffffffffffffffff0000000000000000000000000000000000000000169055518391906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b6134a68383613525565b6134b3600084848461305f565b6109d85760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e74657200000000000000000000000000006064820152608401610937565b6001600160a01b03821661357b5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610937565b6000818152606760205260409020546001600160a01b0316156135e05760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610937565b6001600160a01b0382166000908152606860205260408120805460019290613609908490614285565b909155505060008181526067602052604080822080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b5080546000825590600052602060002090810190611ea991906136d3565b5080546136a990613eb5565b6000825580601f106136b9575050565b601f016020900490600052602060002090810190611ea991905b5b808211156136e857600081556001016136d4565b5090565b7fffffffff0000000000000000000000000000000000000000000000000000000081168114611ea957600080fd5b60006020828403121561372c57600080fd5b813561147b816136ec565b60005b8381101561375257818101518382015260200161373a565b83811115610d4b5750506000910152565b6000815180845261377b816020860160208601613737565b601f01601f19169290920160200192915050565b60208152600061147b6020830184613763565b6000602082840312156137b457600080fd5b5035919050565b80356001600160a01b03811681146137d257600080fd5b919050565b600080604083850312156137ea57600080fd5b6137f3836137bb565b946020939093013593505050565b60008060006060848603121561381657600080fd5b61381f846137bb565b925061382d602085016137bb565b9150604084013590509250925092565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040516060810167ffffffffffffffff8111828210171561388f5761388f61383d565b60405290565b6040516080810167ffffffffffffffff8111828210171561388f5761388f61383d565b604051601f8201601f1916810167ffffffffffffffff811182821017156138e1576138e161383d565b604052919050565b600067ffffffffffffffff8311156139035761390361383d565b6139166020601f19601f860116016138b8565b905082815283838301111561392a57600080fd5b828260208301376000602084830101529392505050565b600082601f83011261395257600080fd5b61147b838335602085016138e9565b803580151581146137d257600080fd5b600060a0828403121561398357600080fd5b60405160a0810167ffffffffffffffff82821081831117156139a7576139a761383d565b8160405282935084359150808211156139bf57600080fd5b506139cc85828601613941565b8252506139db60208401613961565b60208201526139ec60408401613961565b604082015260608301356060820152613a07608084016137bb565b60808201525092915050565b600067ffffffffffffffff821115613a2d57613a2d61383d565b5060051b60200190565b600082601f830112613a4857600080fd5b81356020613a5d613a5883613a13565b6138b8565b82815260059290921b84018101918181019086841115613a7c57600080fd5b8286015b84811015613b6d57803567ffffffffffffffff80821115613aa15760008081fd5b8189019150606080601f19848d03011215613abc5760008081fd5b613ac461386c565b87840135815260408085013584811115613ade5760008081fd5b85019350603f84018d13613af25760008081fd5b88840135613b02613a5882613a13565b81815260059190911b85018201908a8101908f831115613b225760008081fd5b958301955b82871015613b4757613b38876137bb565b8252958b0195908b0190613b27565b848c015250613b599050858401613961565b908201528652505050918301918301613a80565b509695505050505050565b600080600060608486031215613b8d57600080fd5b833567ffffffffffffffff80821115613ba557600080fd5b9085019060808288031215613bb957600080fd5b613bc1613895565b823582811115613bd057600080fd5b613bdc89828601613941565b825250602083013582811115613bf157600080fd5b613bfd89828601613941565b602083015250613c0f604084016137bb565b6040820152613c2060608401613961565b606082015294506020860135915080821115613c3b57600080fd5b613c4787838801613971565b93506040860135915080821115613c5d57600080fd5b50613c6a86828701613a37565b9150509250925092565b60008060408385031215613c8757600080fd5b50508035926020909101359150565b600080600060608486031215613cab57600080fd5b833567ffffffffffffffff80821115613cc357600080fd5b9085019060a08288031215613cd757600080fd5b90935060208501359080821115613ced57600080fd5b50613cfa86828701613a37565b925050613d0960408501613961565b90509250925092565b60008060408385031215613d2557600080fd5b82359150613d35602084016137bb565b90509250929050565b600060208284031215613d5057600080fd5b61147b826137bb565b600080600060608486031215613d6e57600080fd5b613d77846137bb565b925060208401359150604084013567ffffffffffffffff811115613d9a57600080fd5b613c6a86828701613941565b60008060408385031215613db957600080fd5b613dc2836137bb565b9150613d3560208401613961565b600080600060608486031215613de557600080fd5b83359250602084013567ffffffffffffffff811115613e0357600080fd5b613cfa86828701613941565b60008060008060808587031215613e2557600080fd5b613e2e856137bb565b9350613e3c602086016137bb565b925060408501359150606085013567ffffffffffffffff811115613e5f57600080fd5b8501601f81018713613e7057600080fd5b613e7f878235602084016138e9565b91505092959194509250565b60008060408385031215613e9e57600080fd5b613ea7836137bb565b9150613d35602084016137bb565b600181811c90821680613ec957607f821691505b602082108103613f02577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b601f8211156109d857600081815260208120601f850160051c81016020861015613f2f5750805b601f850160051c820191505b81811015613f4e57828155600101613f3b565b505050505050565b815167ffffffffffffffff811115613f7057613f7061383d565b613f8481613f7e8454613eb5565b84613f08565b602080601f831160018114613fb95760008415613fa15750858301515b600019600386901b1c1916600185901b178555613f4e565b600085815260208120601f198616915b82811015613fe857888601518255948401946001909101908401613fc9565b50858210156140065787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600081600019048311821515161561405f5761405f614016565b500290565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b6000826140a2576140a2614064565b500490565b60008083546140b581613eb5565b600182811680156140cd57600181146140e257614111565b60ff1984168752821515830287019450614111565b8760005260208060002060005b858110156141085781548a8201529084019082016140ef565b50505082870194505b50929695505050505050565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe184360301811261415257600080fd5b83018035915067ffffffffffffffff82111561416d57600080fd5b602001915036819003821315610d8857600080fd5b8183823760009101908152919050565b67ffffffffffffffff8311156141aa576141aa61383d565b6141be836141b88354613eb5565b83613f08565b6000601f8411600181146141f257600085156141da5750838201355b600019600387901b1c1916600186901b17835561424c565b600083815260209020601f19861690835b828110156142235786850135825560209485019460019092019101614203565b50868210156142405760001960f88860031b161c19848701351681555b505060018560011b0183555b5050505050565b60006020828403121561426557600080fd5b61147b82613961565b60008282101561428057614280614016565b500390565b6000821982111561429857614298614016565b500190565b600083516142af818460208801613737565b8351908301906142c3818360208801613737565b01949350505050565b7f7b2273656c6c65725f6665655f62617369735f706f696e7473223a200000000081526000835161430481601c850160208801613737565b7f2c20226665655f726563697069656e74223a2022000000000000000000000000601c918401918201528351614341816030840160208801613737565b7f227d00000000000000000000000000000000000000000000000000000000000060309290910191820152603201949350505050565b7f646174613a6170706c69636174696f6e2f6a736f6e3b6261736536342c0000008152600082516143af81601d850160208701613737565b91909101601d0192915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6000816143fa576143fa614016565b506000190190565b7f4772616e756c6172526f6c65733a20696e76616c696420726f6c65200000000081526000825161443a81601c850160208701613737565b91909101601c0192915050565b6000600019820361445a5761445a614016565b5060010190565b7f4772616e756c6172526f6c65733a20726f6c6520000000000000000000000000815260008251614499816014850160208701613737565b7f2069732066726f7a656e000000000000000000000000000000000000000000006014939091019283015250601e01919050565b6000826144dc576144dc614064565b500690565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351614519816017850160208801613737565b7f206973206d697373696e6720726f6c65200000000000000000000000000000006017918401918201528351614556816028840160208801613737565b01602801949350505050565b60006001600160a01b038087168352808616602084015250836040830152608060608301526145946080830184613763565b9695505050505050565b6000602082840312156145b057600080fd5b815161147b816136ec56fe4142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a303132333435363738392b2fa26469706673582212203605b083af0c6f46567cca6af52db1fff2bbe98f7e11ec21c577a0b823a005b764736f6c634300080f0033

Block Transaction Gas Used Reward
view all blocks collator

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

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits

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