false
false

Contract Address Details

0x4abCE25C599dd104dfBc8d42E864FDB582A0F04E

Contract Name
NFTBadgeV1
Creator
0xe3a7f8–1d7bd5 at 0x4949f5–a20edd
Balance
0 JINDA
Tokens
Fetching tokens...
Transactions
0 Transactions
Transfers
0 Transfers
Gas Used
Fetching gas used...
Last Balance Update
10158313
Contract name:
NFTBadgeV1




Optimization enabled
true
Compiler version
v0.8.7+commit.e28d00a7




Optimization runs
200
EVM Version
default




Verified at
2023-03-07T04:56:32.078380Z

Contract source code

// File: @openzeppelin\contracts-upgradeable\utils\math\SafeMathUpgradeable.sol

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

pragma solidity ^0.8.0;

// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.

/**
 * @dev Wrappers over Solidity's arithmetic operations.
 *
 * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler
 * now has built in overflow checking.
 */
library SafeMathUpgradeable {
    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            uint256 c = a + b;
            if (c < a) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b > a) return (false, 0);
            return (true, a - b);
        }
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
            // benefit is lost if 'b' is also tested.
            // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
            if (a == 0) return (true, 0);
            uint256 c = a * b;
            if (c / a != b) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the division of two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a / b);
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a % b);
        }
    }

    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        return a + b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return a - b;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        return a * b;
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator.
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return a % b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {trySub}.
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b <= a, errorMessage);
            return a - b;
        }
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b > 0, errorMessage);
            return a / b;
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting with custom message when dividing by zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryMod}.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b > 0, errorMessage);
            return a % b;
        }
    }
}

// File: @openzeppelin\contracts-upgradeable\utils\AddressUpgradeable.sol


// 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: @openzeppelin\contracts-upgradeable\proxy\utils\Initializable.sol


// OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol)

pragma solidity ^0.8.2;

/**
 * @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: @openzeppelin\contracts-upgradeable\access\IAccessControlUpgradeable.sol


// 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: @openzeppelin\contracts-upgradeable\utils\ContextUpgradeable.sol


// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract 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: @openzeppelin\contracts-upgradeable\utils\StringsUpgradeable.sol


// 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: @openzeppelin\contracts-upgradeable\utils\introspection\IERC165Upgradeable.sol


// 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: @openzeppelin\contracts-upgradeable\utils\introspection\ERC165Upgradeable.sol


// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)

pragma solidity ^0.8.0;


/**
 * @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: @openzeppelin\contracts-upgradeable\access\AccessControlUpgradeable.sol


// OpenZeppelin Contracts (last updated v4.7.0) (access/AccessControl.sol)

pragma solidity ^0.8.0;





/**
 * @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: contracts\NFT_Permission.sol


pragma solidity ^0.8.7;

interface InterfaceNFTPermission {
    function checkAdminRole(address account) external view returns (bool);
    function checkMinterRole(address account) external view returns (bool);
    function checkBurnerRole(address account) external view returns (bool);
    function checkTransferRole(address account) external view returns (bool);
    function checkAccessRole(address account) external view returns (bool);
    function checkTokenAccessRole(address account, string memory _role) external view returns (bool);
    function getAddressRole(address account) external view returns (string memory);
}


contract NFTPermission is Initializable, AccessControlUpgradeable, InterfaceNFTPermission{

    struct TokenAccessRole {
        string permission;
        bool accountExist;
    }

    string[] public roles;

    bytes32 private constant MINTER_ROLE = keccak256("MINTER_ROLE");
    bytes32 private constant BURNER_ROLE = keccak256("BURNER_ROLE");
    bytes32 private constant TRANSFER_ROLE = keccak256("TRANSFER_ROLE");

    /// @custom:oz-upgrades-unsafe-allow constructor
    constructor() {
        _disableInitializers();
    }

    function initialize(address _admin) initializer public {
        __AccessControl_init();
        _grantRole(DEFAULT_ADMIN_ROLE, _admin);
        _grantRole(BURNER_ROLE, _admin);
        _grantRole(TRANSFER_ROLE, _admin);
        _grantRole(MINTER_ROLE, _admin);
        tokenAccessRoleAccountExist[_admin].permission = "DEFAULT ADMIN";
        tokenAccessRoleAccountExist[_admin].accountExist = true;
        roles.push("DEFAULT ADMIN");
    }


    // walletAddress => TokenAccessRole
    mapping(address => TokenAccessRole) public tokenAccessRoleAccountExist;
    mapping(string => bool) public mapRoleExist;

    //Permission
    modifier onlyAdmin() {
        require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender), "Require admin role.");
        _;
    }

    function listRole() public view returns(string[] memory) {
        return roles;
    }

    function setTokenAccessRole(address account, string memory role) public onlyAdmin
    {
        require(!tokenAccessRoleAccountExist[account].accountExist,"Account already exists.");

        grantRole(keccak256(abi.encodePacked(role)),account);
        grantRole(MINTER_ROLE,account);
        grantRole(BURNER_ROLE,account);
        grantRole(TRANSFER_ROLE,account);

        if(!mapRoleExist[role]){
            roles.push(role);
        }

        mapRoleExist[role] = true;
        tokenAccessRoleAccountExist[account].accountExist = true;
        tokenAccessRoleAccountExist[account].permission = role;
    }

    function revokeTokenAccessRole(address account) public onlyAdmin
    {
        require(tokenAccessRoleAccountExist[account].accountExist,"Account isn't exist.");
        require(!hasRole(DEFAULT_ADMIN_ROLE,account), "Can't revoke admin role.");
        revokeRole(keccak256(abi.encodePacked(tokenAccessRoleAccountExist[account].permission)),account);
        revokeRole(MINTER_ROLE,account);
        revokeRole(BURNER_ROLE,account);
        revokeRole(TRANSFER_ROLE,account);
        delete tokenAccessRoleAccountExist[account];
    }

    function checkAdminRole(address account) external view override returns (bool){
        return hasRole(DEFAULT_ADMIN_ROLE, account);
    }

    function checkMinterRole(address account) external view override returns (bool){
        return hasRole(MINTER_ROLE, account);
    }

    function checkBurnerRole(address account) external view override returns (bool){
        return hasRole(BURNER_ROLE, account);
    }

    function checkTransferRole(address account) external view override returns (bool){
        return hasRole(TRANSFER_ROLE, account);
    }

    function checkAccessRole(address account) external view override returns (bool){
        return tokenAccessRoleAccountExist[account].accountExist;
    }

    function checkTokenAccessRole(address account, string memory _role) external view override returns (bool){
        return hasRole(keccak256(abi.encodePacked(_role)), account);
    }

    function getAddressRole(address account) external view override returns (string memory){
        return tokenAccessRoleAccountExist[account].permission;
    }




}

// File: @openzeppelin\contracts-upgradeable\utils\CountersUpgradeable.sol


// OpenZeppelin Contracts v4.4.1 (utils/Counters.sol)

pragma solidity ^0.8.0;

/**
 * @title Counters
 * @author Matt Condon (@shrugs)
 * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number
 * of elements in a mapping, issuing ERC721 ids, or counting request ids.
 *
 * Include with `using Counters for Counters.Counter;`
 */
library CountersUpgradeable {
    struct Counter {
        // This variable should never be directly accessed by users of the library: interactions must be restricted to
        // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add
        // this feature: see https://github.com/ethereum/solidity/issues/4637
        uint256 _value; // default: 0
    }

    function current(Counter storage counter) internal view returns (uint256) {
        return counter._value;
    }

    function increment(Counter storage counter) internal {
        unchecked {
            counter._value += 1;
        }
    }

    function decrement(Counter storage counter) internal {
        uint256 value = counter._value;
        require(value > 0, "Counter: decrement overflow");
        unchecked {
            counter._value = value - 1;
        }
    }

    function reset(Counter storage counter) internal {
        counter._value = 0;
    }
}

// File: @openzeppelin\contracts-upgradeable\token\ERC1155\IERC1155Upgradeable.sol


// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC1155/IERC1155.sol)

pragma solidity ^0.8.0;

/**
 * @dev Required interface of an ERC1155 compliant contract, as defined in the
 * https://eips.ethereum.org/EIPS/eip-1155[EIP].
 *
 * _Available since v3.1._
 */
interface IERC1155Upgradeable is IERC165Upgradeable {
    /**
     * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.
     */
    event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);

    /**
     * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all
     * transfers.
     */
    event TransferBatch(
        address indexed operator,
        address indexed from,
        address indexed to,
        uint256[] ids,
        uint256[] values
    );

    /**
     * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to
     * `approved`.
     */
    event ApprovalForAll(address indexed account, address indexed operator, bool approved);

    /**
     * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.
     *
     * If an {URI} event was emitted for `id`, the standard
     * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value
     * returned by {IERC1155MetadataURI-uri}.
     */
    event URI(string value, uint256 indexed id);

    /**
     * @dev Returns the amount of tokens of token type `id` owned by `account`.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     */
    function balanceOf(address account, uint256 id) external view returns (uint256);

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.
     *
     * Requirements:
     *
     * - `accounts` and `ids` must have the same length.
     */
    function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids)
        external
        view
        returns (uint256[] memory);

    /**
     * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,
     *
     * Emits an {ApprovalForAll} event.
     *
     * Requirements:
     *
     * - `operator` cannot be the caller.
     */
    function setApprovalForAll(address operator, bool approved) external;

    /**
     * @dev Returns true if `operator` is approved to transfer ``account``'s tokens.
     *
     * See {setApprovalForAll}.
     */
    function isApprovedForAll(address account, address operator) external view returns (bool);

    /**
     * @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}.
     * - `from` must have a balance of tokens of type `id` of at least `amount`.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
     * acceptance magic value.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 id,
        uint256 amount,
        bytes calldata data
    ) external;

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
     *
     * Emits a {TransferBatch} event.
     *
     * Requirements:
     *
     * - `ids` and `amounts` must have the same length.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
     * acceptance magic value.
     */
    function safeBatchTransferFrom(
        address from,
        address to,
        uint256[] calldata ids,
        uint256[] calldata amounts,
        bytes calldata data
    ) external;
}

// File: @openzeppelin\contracts-upgradeable\token\ERC1155\IERC1155ReceiverUpgradeable.sol


// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/IERC1155Receiver.sol)

pragma solidity ^0.8.0;

/**
 * @dev _Available since v3.1._
 */
interface IERC1155ReceiverUpgradeable is IERC165Upgradeable {
    /**
     * @dev Handles the receipt of a single ERC1155 token type. This function is
     * called at the end of a `safeTransferFrom` after the balance has been updated.
     *
     * NOTE: To accept the transfer, this must return
     * `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))`
     * (i.e. 0xf23a6e61, or its own function selector).
     *
     * @param operator The address which initiated the transfer (i.e. msg.sender)
     * @param from The address which previously owned the token
     * @param id The ID of the token being transferred
     * @param value The amount of tokens being transferred
     * @param data Additional data with no specified format
     * @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed
     */
    function onERC1155Received(
        address operator,
        address from,
        uint256 id,
        uint256 value,
        bytes calldata data
    ) external returns (bytes4);

    /**
     * @dev Handles the receipt of a multiple ERC1155 token types. This function
     * is called at the end of a `safeBatchTransferFrom` after the balances have
     * been updated.
     *
     * NOTE: To accept the transfer(s), this must return
     * `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))`
     * (i.e. 0xbc197c81, or its own function selector).
     *
     * @param operator The address which initiated the batch transfer (i.e. msg.sender)
     * @param from The address which previously owned the token
     * @param ids An array containing ids of each token being transferred (order and length must match values array)
     * @param values An array containing amounts of each token being transferred (order and length must match ids array)
     * @param data Additional data with no specified format
     * @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed
     */
    function onERC1155BatchReceived(
        address operator,
        address from,
        uint256[] calldata ids,
        uint256[] calldata values,
        bytes calldata data
    ) external returns (bytes4);
}

// File: @openzeppelin\contracts-upgradeable\token\ERC1155\extensions\IERC1155MetadataURIUpgradeable.sol


// OpenZeppelin Contracts v4.4.1 (token/ERC1155/extensions/IERC1155MetadataURI.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the optional ERC1155MetadataExtension interface, as defined
 * in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[EIP].
 *
 * _Available since v3.1._
 */
interface IERC1155MetadataURIUpgradeable is IERC1155Upgradeable {
    /**
     * @dev Returns the URI for token type `id`.
     *
     * If the `\{id\}` substring is present in the URI, it must be replaced by
     * clients with the actual token type ID.
     */
    function uri(uint256 id) external view returns (string memory);
}

// File: @openzeppelin\contracts-upgradeable\token\ERC1155\ERC1155Upgradeable.sol


// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC1155/ERC1155.sol)

pragma solidity ^0.8.0;







/**
 * @dev Implementation of the basic standard multi-token.
 * See https://eips.ethereum.org/EIPS/eip-1155
 * Originally based on code by Enjin: https://github.com/enjin/erc-1155
 *
 * _Available since v3.1._
 */
contract ERC1155Upgradeable is Initializable, ContextUpgradeable, ERC165Upgradeable, IERC1155Upgradeable, IERC1155MetadataURIUpgradeable {
    using AddressUpgradeable for address;

    // Mapping from token ID to account balances
    mapping(uint256 => mapping(address => uint256)) private _balances;

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

    // Used as the URI for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.json
    string private _uri;

    /**
     * @dev See {_setURI}.
     */
    function __ERC1155_init(string memory uri_) internal onlyInitializing {
        __ERC1155_init_unchained(uri_);
    }

    function __ERC1155_init_unchained(string memory uri_) internal onlyInitializing {
        _setURI(uri_);
    }

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

    /**
     * @dev See {IERC1155MetadataURI-uri}.
     *
     * This implementation returns the same URI for *all* token types. It relies
     * on the token type ID substitution mechanism
     * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP].
     *
     * Clients calling this function must replace the `\{id\}` substring with the
     * actual token type ID.
     */
    function uri(uint256) public view virtual override returns (string memory) {
        return _uri;
    }

    /**
     * @dev See {IERC1155-balanceOf}.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     */
    function balanceOf(address account, uint256 id) public view virtual override returns (uint256) {
        require(account != address(0), "ERC1155: address zero is not a valid owner");
        return _balances[id][account];
    }

    /**
     * @dev See {IERC1155-balanceOfBatch}.
     *
     * Requirements:
     *
     * - `accounts` and `ids` must have the same length.
     */
    function balanceOfBatch(address[] memory accounts, uint256[] memory ids)
        public
        view
        virtual
        override
        returns (uint256[] memory)
    {
        require(accounts.length == ids.length, "ERC1155: accounts and ids length mismatch");

        uint256[] memory batchBalances = new uint256[](accounts.length);

        for (uint256 i = 0; i < accounts.length; ++i) {
            batchBalances[i] = balanceOf(accounts[i], ids[i]);
        }

        return batchBalances;
    }

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

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

    /**
     * @dev See {IERC1155-safeTransferFrom}.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 id,
        uint256 amount,
        bytes memory data
    ) public virtual override {
        require(
            from == _msgSender() || isApprovedForAll(from, _msgSender()),
            "ERC1155: caller is not token owner nor approved"
        );
        _safeTransferFrom(from, to, id, amount, data);
    }

    /**
     * @dev See {IERC1155-safeBatchTransferFrom}.
     */
    function safeBatchTransferFrom(
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) public virtual override {
        require(
            from == _msgSender() || isApprovedForAll(from, _msgSender()),
            "ERC1155: caller is not token owner nor approved"
        );
        _safeBatchTransferFrom(from, to, ids, amounts, data);
    }

    /**
     * @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - `from` must have a balance of tokens of type `id` of at least `amount`.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
     * acceptance magic value.
     */
    function _safeTransferFrom(
        address from,
        address to,
        uint256 id,
        uint256 amount,
        bytes memory data
    ) internal virtual {
        require(to != address(0), "ERC1155: transfer to the zero address");

        address operator = _msgSender();
        uint256[] memory ids = _asSingletonArray(id);
        uint256[] memory amounts = _asSingletonArray(amount);

        _beforeTokenTransfer(operator, from, to, ids, amounts, data);

        uint256 fromBalance = _balances[id][from];
        require(fromBalance >= amount, "ERC1155: insufficient balance for transfer");
        unchecked {
            _balances[id][from] = fromBalance - amount;
        }
        _balances[id][to] += amount;

        emit TransferSingle(operator, from, to, id, amount);

        _afterTokenTransfer(operator, from, to, ids, amounts, data);

        _doSafeTransferAcceptanceCheck(operator, from, to, id, amount, data);
    }

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_safeTransferFrom}.
     *
     * Emits a {TransferBatch} event.
     *
     * Requirements:
     *
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
     * acceptance magic value.
     */
    function _safeBatchTransferFrom(
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) internal virtual {
        require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
        require(to != address(0), "ERC1155: transfer to the zero address");

        address operator = _msgSender();

        _beforeTokenTransfer(operator, from, to, ids, amounts, data);

        for (uint256 i = 0; i < ids.length; ++i) {
            uint256 id = ids[i];
            uint256 amount = amounts[i];

            uint256 fromBalance = _balances[id][from];
            require(fromBalance >= amount, "ERC1155: insufficient balance for transfer");
            unchecked {
                _balances[id][from] = fromBalance - amount;
            }
            _balances[id][to] += amount;
        }

        emit TransferBatch(operator, from, to, ids, amounts);

        _afterTokenTransfer(operator, from, to, ids, amounts, data);

        _doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, amounts, data);
    }

    /**
     * @dev Sets a new URI for all token types, by relying on the token type ID
     * substitution mechanism
     * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP].
     *
     * By this mechanism, any occurrence of the `\{id\}` substring in either the
     * URI or any of the amounts in the JSON file at said URI will be replaced by
     * clients with the token type ID.
     *
     * For example, the `https://token-cdn-domain/\{id\}.json` URI would be
     * interpreted by clients as
     * `https://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json`
     * for token type ID 0x4cce0.
     *
     * See {uri}.
     *
     * Because these URIs cannot be meaningfully represented by the {URI} event,
     * this function emits no events.
     */
    function _setURI(string memory newuri) internal virtual {
        _uri = newuri;
    }

    /**
     * @dev Creates `amount` tokens of token type `id`, and assigns them to `to`.
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
     * acceptance magic value.
     */
    function _mint(
        address to,
        uint256 id,
        uint256 amount,
        bytes memory data
    ) internal virtual {
        require(to != address(0), "ERC1155: mint to the zero address");

        address operator = _msgSender();
        uint256[] memory ids = _asSingletonArray(id);
        uint256[] memory amounts = _asSingletonArray(amount);

        _beforeTokenTransfer(operator, address(0), to, ids, amounts, data);

        _balances[id][to] += amount;
        emit TransferSingle(operator, address(0), to, id, amount);

        _afterTokenTransfer(operator, address(0), to, ids, amounts, data);

        _doSafeTransferAcceptanceCheck(operator, address(0), to, id, amount, data);
    }

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_mint}.
     *
     * Emits a {TransferBatch} event.
     *
     * Requirements:
     *
     * - `ids` and `amounts` must have the same length.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
     * acceptance magic value.
     */
    function _mintBatch(
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) internal virtual {
        require(to != address(0), "ERC1155: mint to the zero address");
        require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");

        address operator = _msgSender();

        _beforeTokenTransfer(operator, address(0), to, ids, amounts, data);

        for (uint256 i = 0; i < ids.length; i++) {
            _balances[ids[i]][to] += amounts[i];
        }

        emit TransferBatch(operator, address(0), to, ids, amounts);

        _afterTokenTransfer(operator, address(0), to, ids, amounts, data);

        _doSafeBatchTransferAcceptanceCheck(operator, address(0), to, ids, amounts, data);
    }

    /**
     * @dev Destroys `amount` tokens of token type `id` from `from`
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `from` must have at least `amount` tokens of token type `id`.
     */
    function _burn(
        address from,
        uint256 id,
        uint256 amount
    ) internal virtual {
        require(from != address(0), "ERC1155: burn from the zero address");

        address operator = _msgSender();
        uint256[] memory ids = _asSingletonArray(id);
        uint256[] memory amounts = _asSingletonArray(amount);

        _beforeTokenTransfer(operator, from, address(0), ids, amounts, "");

        uint256 fromBalance = _balances[id][from];
        require(fromBalance >= amount, "ERC1155: burn amount exceeds balance");
        unchecked {
            _balances[id][from] = fromBalance - amount;
        }

        emit TransferSingle(operator, from, address(0), id, amount);

        _afterTokenTransfer(operator, from, address(0), ids, amounts, "");
    }

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}.
     *
     * Emits a {TransferBatch} event.
     *
     * Requirements:
     *
     * - `ids` and `amounts` must have the same length.
     */
    function _burnBatch(
        address from,
        uint256[] memory ids,
        uint256[] memory amounts
    ) internal virtual {
        require(from != address(0), "ERC1155: burn from the zero address");
        require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");

        address operator = _msgSender();

        _beforeTokenTransfer(operator, from, address(0), ids, amounts, "");

        for (uint256 i = 0; i < ids.length; i++) {
            uint256 id = ids[i];
            uint256 amount = amounts[i];

            uint256 fromBalance = _balances[id][from];
            require(fromBalance >= amount, "ERC1155: burn amount exceeds balance");
            unchecked {
                _balances[id][from] = fromBalance - amount;
            }
        }

        emit TransferBatch(operator, from, address(0), ids, amounts);

        _afterTokenTransfer(operator, from, address(0), ids, amounts, "");
    }

    /**
     * @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, "ERC1155: setting approval status for self");
        _operatorApprovals[owner][operator] = approved;
        emit ApprovalForAll(owner, operator, approved);
    }

    /**
     * @dev Hook that is called before any token transfer. This includes minting
     * and burning, as well as batched variants.
     *
     * The same hook is called on both single and batched variants. For single
     * transfers, the length of the `ids` and `amounts` arrays will be 1.
     *
     * Calling conditions (for each `id` and `amount` pair):
     *
     * - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * of token type `id` will be  transferred to `to`.
     * - When `from` is zero, `amount` tokens of token type `id` will be minted
     * for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens of token type `id`
     * will be burned.
     * - `from` and `to` are never both zero.
     * - `ids` and `amounts` have the same, non-zero length.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(
        address operator,
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) internal virtual {}

    /**
     * @dev Hook that is called after any token transfer. This includes minting
     * and burning, as well as batched variants.
     *
     * The same hook is called on both single and batched variants. For single
     * transfers, the length of the `id` and `amount` arrays will be 1.
     *
     * Calling conditions (for each `id` and `amount` pair):
     *
     * - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * of token type `id` will be  transferred to `to`.
     * - When `from` is zero, `amount` tokens of token type `id` will be minted
     * for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens of token type `id`
     * will be burned.
     * - `from` and `to` are never both zero.
     * - `ids` and `amounts` have the same, non-zero length.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _afterTokenTransfer(
        address operator,
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) internal virtual {}

    function _doSafeTransferAcceptanceCheck(
        address operator,
        address from,
        address to,
        uint256 id,
        uint256 amount,
        bytes memory data
    ) private {
        if (to.isContract()) {
            try IERC1155ReceiverUpgradeable(to).onERC1155Received(operator, from, id, amount, data) returns (bytes4 response) {
                if (response != IERC1155ReceiverUpgradeable.onERC1155Received.selector) {
                    revert("ERC1155: ERC1155Receiver rejected tokens");
                }
            } catch Error(string memory reason) {
                revert(reason);
            } catch {
                revert("ERC1155: transfer to non ERC1155Receiver implementer");
            }
        }
    }

    function _doSafeBatchTransferAcceptanceCheck(
        address operator,
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) private {
        if (to.isContract()) {
            try IERC1155ReceiverUpgradeable(to).onERC1155BatchReceived(operator, from, ids, amounts, data) returns (
                bytes4 response
            ) {
                if (response != IERC1155ReceiverUpgradeable.onERC1155BatchReceived.selector) {
                    revert("ERC1155: ERC1155Receiver rejected tokens");
                }
            } catch Error(string memory reason) {
                revert(reason);
            } catch {
                revert("ERC1155: transfer to non ERC1155Receiver implementer");
            }
        }
    }

    function _asSingletonArray(uint256 element) private pure returns (uint256[] memory) {
        uint256[] memory array = new uint256[](1);
        array[0] = element;

        return array;
    }

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

// File: @openzeppelin\contracts-upgradeable\token\ERC1155\extensions\ERC1155BurnableUpgradeable.sol


// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC1155/extensions/ERC1155Burnable.sol)

pragma solidity ^0.8.0;


/**
 * @dev Extension of {ERC1155} that allows token holders to destroy both their
 * own tokens and those that they have been approved to use.
 *
 * _Available since v3.1._
 */
abstract contract ERC1155BurnableUpgradeable is Initializable, ERC1155Upgradeable {
    function __ERC1155Burnable_init() internal onlyInitializing {
    }

    function __ERC1155Burnable_init_unchained() internal onlyInitializing {
    }
    function burn(
        address account,
        uint256 id,
        uint256 value
    ) public virtual {
        require(
            account == _msgSender() || isApprovedForAll(account, _msgSender()),
            "ERC1155: caller is not token owner nor approved"
        );

        _burn(account, id, value);
    }

    function burnBatch(
        address account,
        uint256[] memory ids,
        uint256[] memory values
    ) public virtual {
        require(
            account == _msgSender() || isApprovedForAll(account, _msgSender()),
            "ERC1155: caller is not token owner nor approved"
        );

        _burnBatch(account, ids, values);
    }

    /**
     * @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: contracts\NFT_Token.sol


pragma solidity ^0.8.7;
interface InterfaceCertificateToken {
    function currentTokenId() external view returns (uint256);
    function burnToken(address _account, uint256 _id, uint256 _amount, address _sender, string memory _role) external;
    function mintToken(address _account, uint256 _id, uint256 _amount, bytes memory _data, address _sender, address _contractAddress, string memory _externalId, string memory _uri, string memory _tokenType) external;
    function safeTransferTokenFrom(address _from, address _to, uint256 _id, uint256 _amount, bytes memory _data, address _sender, string memory _role) external;
    function safeBatchTransferTokenFrom(address _from, address _to, uint256[] memory _ids, uint256[] memory _amounts, bytes memory _data, address _sender, string memory _role) external;
    //badge
    function addUserBadge(address _user, uint256 _tokenId, address _sender) external;
    function findBadgeIndex(address _receiver, uint256 _tokenId) external view returns (int);
    function removeBadgeList(address _receiver, int _index, address _sender, string memory _role) external;
    //certificate
    function addUserCertificate(address _user, uint256 _tokenId, address _sender) external;
    function findCertificateIndex(address _receiver, uint256 _tokenId) external view returns (int);
    function removeCertificateList(address _receiver, int _index, address _sender, string memory _role) external;

}


contract CertificateToken is Initializable, ERC1155Upgradeable, ERC1155BurnableUpgradeable, AccessControlUpgradeable, InterfaceCertificateToken {

    struct TokenInfo {
        address contractAddress;
        string externalId;
        string tokenType;
        string uri;
    }

    mapping(uint256 => TokenInfo) mapTokenInfo;
    // walletAddress => badge list
    mapping(address => uint256[]) private mapUserBadge;
    // walletAddress => certificate list
    mapping(address => uint256[]) private mapUserCertificate;

    address NFTPermissionAddress;
    string public TokenName;

    using CountersUpgradeable for CountersUpgradeable.Counter;
    CountersUpgradeable.Counter private tokenId;

    /// @custom:oz-upgrades-unsafe-allow constructor
    constructor() {
        _disableInitializers();
    }

    function initialize(string memory _tokenName, address _nftPermissionAddress) initializer public {
        __ERC1155_init("");
        __ERC1155Burnable_init();
        __AccessControl_init();
        TokenName = _tokenName;
        NFTPermissionAddress = _nftPermissionAddress;
        tokenId.increment();
    }

    function supportsInterface(bytes4 interfaceId)
    public
    view
    override(ERC1155Upgradeable, AccessControlUpgradeable)
    returns (bool)
    {
        return super.supportsInterface(interfaceId);
    }

    function setTokenName(string memory _tokenName) public {
        TokenName = _tokenName;
    }

    function setUri(uint256 _tokenId, string memory _uri) public {
        require(InterfaceNFTPermission(NFTPermissionAddress).checkAdminRole(msg.sender),"only admin role.");
        require(_tokenId < tokenId.current() && _tokenId != 0, "token isn't exist");
        mapTokenInfo[_tokenId].uri = _uri;
    }

    function name() external view returns (string memory) {
        return TokenName;
    }

    function symbol() external pure returns (string memory) {
        return "CERT";
    }

    function currentTokenId() external view override returns (uint256) {
        return tokenId.current();
    }

    function uri(uint256 _tokenId) public override view returns (string memory) {
        return mapTokenInfo[_tokenId].uri;
    }

    function burnToken(address _account, uint256 _id, uint256 _amount, address _sender, string memory _role) external override {
        require(InterfaceNFTPermission(NFTPermissionAddress).checkBurnerRole(_sender),"only burner role");
        require(InterfaceNFTPermission(NFTPermissionAddress).checkTokenAccessRole(_sender, _role) || InterfaceNFTPermission(NFTPermissionAddress).checkAdminRole(_sender),"Invalid token access role.");
        _burn(_account, _id, _amount);
    }

    function mintToken(address _account, uint256 _id, uint256 _amount, bytes memory _data, address _sender, address _contractAddress, string memory _externalId, string memory _uri, string memory _tokenType) external override {
        require(InterfaceNFTPermission(NFTPermissionAddress).checkMinterRole(_sender),"only minter role");
        require(InterfaceNFTPermission(NFTPermissionAddress).checkAccessRole(_sender),"Need token access role.");
        _mint(_account, _id, _amount, _data);

        TokenInfo memory tokenInfo = TokenInfo(_contractAddress, _externalId, _tokenType, _uri);

        mapTokenInfo[_id] = tokenInfo;
        tokenId.increment();
    }

    function safeTransferTokenFrom(address _from, address _to, uint256 _id, uint256 _amount, bytes memory _data, address _sender, string memory _role) external override   {
        require(InterfaceNFTPermission(NFTPermissionAddress).checkTransferRole(_sender),"only transfer role");
        require(InterfaceNFTPermission(NFTPermissionAddress).checkTokenAccessRole(_sender, _role) || InterfaceNFTPermission(NFTPermissionAddress).checkAdminRole(_sender),"Invalid token access role.");
        _safeTransferFrom(_from, _to, _id, _amount, _data);
    }

    function safeBatchTransferTokenFrom(address _from, address _to, uint256[] memory _ids, uint256[] memory _amounts, bytes memory _data, address _sender, string memory _role) external override  {
        require(InterfaceNFTPermission(NFTPermissionAddress).checkTransferRole(_sender),"only transfer role");
        for (uint i = 0; i < _ids.length; i++) {
            require(InterfaceNFTPermission(NFTPermissionAddress).checkTokenAccessRole(_sender, _role) || InterfaceNFTPermission(NFTPermissionAddress).checkAdminRole(_sender),"Invalid token access role.");
            require(_ids[i] > 0, "token 0 isn't exist.");
        }
        _safeBatchTransferFrom(_from, _to, _ids, _amounts, _data);
    }

    function getTokenInfo(uint _id) public view returns (TokenInfo memory){
        return mapTokenInfo[_id];
    }

    // Badge
    function addUserBadge(address _user, uint256 _tokenId, address _sender) external override {
        require(InterfaceNFTPermission(NFTPermissionAddress).checkMinterRole(_sender) || InterfaceNFTPermission(NFTPermissionAddress).checkTransferRole(_sender),"only minter role or transfer role");
        mapUserBadge[_user].push(_tokenId);
    }

    function findBadgeIndex(address _receiver, uint256 _tokenId) external override view returns (int) {
        uint256[] storage list = mapUserBadge[_receiver];
        for (uint i = 0; i < list.length; i++) {
            if (list[i] == _tokenId) {
                return int(i);
            }
        }
        return - 1;
    }

    function removeBadgeList(address _receiver, int _index, address _sender, string memory _role) external override {
        require(InterfaceNFTPermission(NFTPermissionAddress).checkBurnerRole(_sender),"only burner role");
        require(InterfaceNFTPermission(NFTPermissionAddress).checkTokenAccessRole(_sender, _role) || InterfaceNFTPermission(NFTPermissionAddress).checkAdminRole(_sender),"Invalid token access role.");
        require(_index >= 0, "not found index");
        uint256 [] storage mapList = mapUserBadge[_receiver];
        require(uint(_index) < mapList.length, "not found index");
        if (balanceOf(_receiver, mapList[uint(_index)]) == 0) {
            for (uint i = uint(_index); i < mapList.length - 1; i++) {
                mapList[i] = mapList[i + 1];
            }
            mapList.pop();
            mapUserBadge[_receiver] = mapList;
        }
    }

    function listUserBadge(address _wallet) public view returns (uint256[] memory){
        return mapUserBadge[_wallet];
    }

    // Certificate
    function addUserCertificate(address _user, uint256 _tokenId, address _sender) external override {
        require(InterfaceNFTPermission(NFTPermissionAddress).checkMinterRole(_sender) || InterfaceNFTPermission(NFTPermissionAddress).checkTransferRole(_sender),"only minter role or transfer role");
        mapUserCertificate[_user].push(_tokenId);
    }

    function findCertificateIndex(address _receiver, uint256 _tokenId) external override view returns (int) {
        uint256[] storage list = mapUserCertificate[_receiver];
        for (uint i = 0; i < list.length; i++) {
            if (list[i] == _tokenId) {
                return int(i);
            }
        }
        return - 1;
    }

    function removeCertificateList(address _receiver, int _index, address _sender, string memory _role) external override  {
        require(InterfaceNFTPermission(NFTPermissionAddress).checkBurnerRole(_sender),"only burner role");
        require(InterfaceNFTPermission(NFTPermissionAddress).checkTokenAccessRole(_sender, _role) || InterfaceNFTPermission(NFTPermissionAddress).checkAdminRole(_sender),"Invalid token access role.");
        require(_index >= 0, "not found index");
        uint256 [] storage mapList = mapUserCertificate[_receiver];
        require(uint(_index) < mapList.length, "not found index");
        if (balanceOf(_receiver, mapList[uint(_index)]) == 0) {
            for (uint i = uint(_index); i < mapList.length - 1; i++) {
                mapList[i] = mapList[i + 1];
            }
            mapList.pop();
            mapUserCertificate[_receiver] = mapList;
        }
    }

    function listUserCertificate(address _wallet) public view returns (uint256[] memory){
        return mapUserCertificate[_wallet];
    }





}

// File: contracts\NFT_Badge_V1.sol


pragma solidity ^0.8.7;
contract NFTBadgeV1 is Initializable{

    struct Attribute {
        string key; // ex. 1
        string id; // linear_id
        string label; // ex. Skill
        string name; // ex. L
        string description; // ex. Learning
        uint256 sequence; // ex. 1
    }
    // Learning Hour
    struct Badge {
        uint256 tokenId; // ex. 1 (ERC 1155)
        string id; // linear_id
        string idCardMasking;
        string name; // ex. DMK
        string description; // ex. Digital Marketing
        string ownerName; // ex. John Doe (optional)
        string tokenType; // BADGE
        uint256 amount; // ex. 5
        string state; // ex. A (Active), I (Inactive)
        address issueBy; // Issuer wallet address
        uint256 issueDate;
        uint256 expireDate;
    }

    address NFTPermissionAddress;
    address NFTTokenAddress;

    using SafeMathUpgradeable for uint256;

    // external id -> token
    mapping(string => uint256) public mapId;
    // token -> badge
    mapping(uint256 => Badge) private mapBadge;
    // token -> type
    mapping(uint256 => string) private mapTokenType;
    // badge -> attribute
    mapping(uint256 => Attribute[]) private mapAttribute;
    // external id => role
    mapping(uint256 => string) public mapTokenRole;


    string private badgeType;

    /// @custom:oz-upgrades-unsafe-allow constructor
    constructor() {
        _disableInitializers();
    }

    function initialize(address _nftPermissionAddress, address _nftTokenAddress) initializer external  {
        badgeType = "BADGE";
        NFTPermissionAddress = _nftPermissionAddress;
        NFTTokenAddress = _nftTokenAddress;
    }

    Attribute [] private attribute;

    event IssueBadgeEvent(Badge,Attribute[]);
    event VoidTokenEvent(uint256 tokenId, uint256 amount, string tokenType, string reason);

    function safeTransferBadgeFrom(address from, address to, uint256 id, uint256 amount, bytes memory data) public  {
        require(InterfaceNFTPermission(NFTPermissionAddress).checkTokenAccessRole(msg.sender, mapTokenRole[id]) || InterfaceNFTPermission(NFTPermissionAddress).checkAdminRole(msg.sender),"Invalid token access role.");
        require(InterfaceNFTPermission(NFTPermissionAddress).checkTransferRole(msg.sender),"only transfer role");

        InterfaceCertificateToken(NFTTokenAddress).safeTransferTokenFrom(from, to, id, amount, data, msg.sender, mapTokenRole[id]);
        userTransfer(id,from, to);
    }

    function safeBatchTransferBadgeFrom(address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data) public  {
        require(InterfaceNFTPermission(NFTPermissionAddress).checkTransferRole(msg.sender),"only transfer role");
        for (uint i = 0; i < ids.length; i++) {
            require(InterfaceNFTPermission(NFTPermissionAddress).checkTokenAccessRole(msg.sender, mapTokenRole[ids[i]]) || InterfaceNFTPermission(NFTPermissionAddress).checkAdminRole(msg.sender),"Invalid token access role.");
            require(ids[i] > 0, "token 0 isn't exist.");
        }
        InterfaceCertificateToken(NFTTokenAddress).safeBatchTransferTokenFrom(from, to, ids, amounts, data, msg.sender, InterfaceNFTPermission(NFTPermissionAddress).getAddressRole(msg.sender));
        for (uint i = 0; i < ids.length; i++) {
            userTransfer(ids[i],from, to);
        }

    }


    function userTransfer(uint256 id, address from, address to) private {

        InterfaceCertificateToken(NFTTokenAddress).removeBadgeList(from, InterfaceCertificateToken(NFTTokenAddress).findBadgeIndex(from, id), msg.sender, mapTokenRole[id]);
        if (InterfaceCertificateToken(NFTTokenAddress).findBadgeIndex(to, id) < int(0)) {
            InterfaceCertificateToken(NFTTokenAddress).addUserBadge(to, id,  msg.sender);
        }
    }

    function issueBadge(address _receiverAddress, Badge memory _badge, string memory _uri, Attribute [] memory _attributes) public {
        require(mapId[_badge.id] == 0, "ID already exist.");
        require(_badge.amount > 0, "Cannot mint zero token");
        require(InterfaceNFTPermission(NFTPermissionAddress).checkMinterRole(msg.sender),"only minter role");
        require(InterfaceNFTPermission(NFTPermissionAddress).checkAccessRole(msg.sender),"Need token access role.");

        uint256 currentTokenId = InterfaceCertificateToken(NFTTokenAddress).currentTokenId();
        mapTokenType[currentTokenId] = badgeType;
        mapId[_badge.id] = currentTokenId;
        Attribute [] storage storageAttribute = attribute;
        for (uint i = 0; i < _attributes.length; i++) {
            storageAttribute.push(_attributes[i]);
        }
        mapAttribute[currentTokenId] = storageAttribute;
        delete attribute;

        _badge.issueBy = msg.sender;
        _badge.tokenId = currentTokenId;
        _badge.issueDate = block.timestamp;
        _badge.tokenType = badgeType;
        _badge.state = "A";

        InterfaceCertificateToken(NFTTokenAddress).mintToken(_receiverAddress, _badge.tokenId, _badge.amount, "", msg.sender, address(this), _badge.id, _uri, badgeType);

        InterfaceCertificateToken(NFTTokenAddress).addUserBadge(_receiverAddress,_badge.tokenId,  msg.sender);
        mapBadge[currentTokenId] = _badge;

        mapTokenRole[currentTokenId] = InterfaceNFTPermission(NFTPermissionAddress).getAddressRole(msg.sender);

        emit IssueBadgeEvent(_badge,_attributes);
    }

    function voidBadge(address _target, string memory _id, uint256 _amount, string memory _reason) public {
        require(mapId[_id] != 0, "Badge isn't exist");
        require(InterfaceNFTPermission(NFTPermissionAddress).checkBurnerRole(msg.sender),"only burner role");
        require(InterfaceNFTPermission(NFTPermissionAddress).checkTokenAccessRole(msg.sender, mapTokenRole[mapId[_id]]) || InterfaceNFTPermission(NFTPermissionAddress).checkAdminRole(msg.sender),"Invalid token access role.");

        mapBadge[mapId[_id]].amount.sub(_amount);
        mapBadge[mapId[_id]].state = "I";

        InterfaceCertificateToken(NFTTokenAddress).burnToken(_target, mapId[_id], _amount, msg.sender, mapTokenRole[mapId[_id]]);
        InterfaceCertificateToken(NFTTokenAddress).removeBadgeList(_target, InterfaceCertificateToken(NFTTokenAddress).findBadgeIndex(_target, mapId[_id]), msg.sender, mapTokenRole[mapId[_id]]);

        emit VoidTokenEvent(mapId[_id], _amount, mapTokenType[mapId[_id]], _reason);
    }

    function badgeInfo(uint256 _tokenId) public view returns (Badge memory){
        require(keccak256(abi.encode(mapTokenType[_tokenId])) == keccak256(abi.encode(badgeType)), "Not badge token.");
        return mapBadge[_tokenId];
    }

    function attributeInfo(uint256 _tokenId) public view returns (Attribute [] memory){
        require(keccak256(abi.encode(mapTokenType[_tokenId])) == keccak256(abi.encode(badgeType)), "Not badge token.");
        return mapAttribute[_tokenId];
    }

}
        

Contract ABI

[{"type":"constructor","stateMutability":"nonpayable","inputs":[]},{"type":"event","name":"Initialized","inputs":[{"type":"uint8","name":"version","internalType":"uint8","indexed":false}],"anonymous":false},{"type":"event","name":"IssueBadgeEvent","inputs":[{"type":"tuple","name":"","internalType":"struct NFTBadgeV1.Badge","indexed":false,"components":[{"type":"uint256","name":"tokenId","internalType":"uint256"},{"type":"string","name":"id","internalType":"string"},{"type":"string","name":"idCardMasking","internalType":"string"},{"type":"string","name":"name","internalType":"string"},{"type":"string","name":"description","internalType":"string"},{"type":"string","name":"ownerName","internalType":"string"},{"type":"string","name":"tokenType","internalType":"string"},{"type":"uint256","name":"amount","internalType":"uint256"},{"type":"string","name":"state","internalType":"string"},{"type":"address","name":"issueBy","internalType":"address"},{"type":"uint256","name":"issueDate","internalType":"uint256"},{"type":"uint256","name":"expireDate","internalType":"uint256"}]},{"type":"tuple[]","name":"","internalType":"struct NFTBadgeV1.Attribute[]","indexed":false,"components":[{"type":"string","name":"key","internalType":"string"},{"type":"string","name":"id","internalType":"string"},{"type":"string","name":"label","internalType":"string"},{"type":"string","name":"name","internalType":"string"},{"type":"string","name":"description","internalType":"string"},{"type":"uint256","name":"sequence","internalType":"uint256"}]}],"anonymous":false},{"type":"event","name":"VoidTokenEvent","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256","indexed":false},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false},{"type":"string","name":"tokenType","internalType":"string","indexed":false},{"type":"string","name":"reason","internalType":"string","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"tuple[]","name":"","internalType":"struct NFTBadgeV1.Attribute[]","components":[{"type":"string","name":"key","internalType":"string"},{"type":"string","name":"id","internalType":"string"},{"type":"string","name":"label","internalType":"string"},{"type":"string","name":"name","internalType":"string"},{"type":"string","name":"description","internalType":"string"},{"type":"uint256","name":"sequence","internalType":"uint256"}]}],"name":"attributeInfo","inputs":[{"type":"uint256","name":"_tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"tuple","name":"","internalType":"struct NFTBadgeV1.Badge","components":[{"type":"uint256","name":"tokenId","internalType":"uint256"},{"type":"string","name":"id","internalType":"string"},{"type":"string","name":"idCardMasking","internalType":"string"},{"type":"string","name":"name","internalType":"string"},{"type":"string","name":"description","internalType":"string"},{"type":"string","name":"ownerName","internalType":"string"},{"type":"string","name":"tokenType","internalType":"string"},{"type":"uint256","name":"amount","internalType":"uint256"},{"type":"string","name":"state","internalType":"string"},{"type":"address","name":"issueBy","internalType":"address"},{"type":"uint256","name":"issueDate","internalType":"uint256"},{"type":"uint256","name":"expireDate","internalType":"uint256"}]}],"name":"badgeInfo","inputs":[{"type":"uint256","name":"_tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"initialize","inputs":[{"type":"address","name":"_nftPermissionAddress","internalType":"address"},{"type":"address","name":"_nftTokenAddress","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"issueBadge","inputs":[{"type":"address","name":"_receiverAddress","internalType":"address"},{"type":"tuple","name":"_badge","internalType":"struct NFTBadgeV1.Badge","components":[{"type":"uint256","name":"tokenId","internalType":"uint256"},{"type":"string","name":"id","internalType":"string"},{"type":"string","name":"idCardMasking","internalType":"string"},{"type":"string","name":"name","internalType":"string"},{"type":"string","name":"description","internalType":"string"},{"type":"string","name":"ownerName","internalType":"string"},{"type":"string","name":"tokenType","internalType":"string"},{"type":"uint256","name":"amount","internalType":"uint256"},{"type":"string","name":"state","internalType":"string"},{"type":"address","name":"issueBy","internalType":"address"},{"type":"uint256","name":"issueDate","internalType":"uint256"},{"type":"uint256","name":"expireDate","internalType":"uint256"}]},{"type":"string","name":"_uri","internalType":"string"},{"type":"tuple[]","name":"_attributes","internalType":"struct NFTBadgeV1.Attribute[]","components":[{"type":"string","name":"key","internalType":"string"},{"type":"string","name":"id","internalType":"string"},{"type":"string","name":"label","internalType":"string"},{"type":"string","name":"name","internalType":"string"},{"type":"string","name":"description","internalType":"string"},{"type":"uint256","name":"sequence","internalType":"uint256"}]}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"mapId","inputs":[{"type":"string","name":"","internalType":"string"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"mapTokenRole","inputs":[{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"safeBatchTransferBadgeFrom","inputs":[{"type":"address","name":"from","internalType":"address"},{"type":"address","name":"to","internalType":"address"},{"type":"uint256[]","name":"ids","internalType":"uint256[]"},{"type":"uint256[]","name":"amounts","internalType":"uint256[]"},{"type":"bytes","name":"data","internalType":"bytes"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"safeTransferBadgeFrom","inputs":[{"type":"address","name":"from","internalType":"address"},{"type":"address","name":"to","internalType":"address"},{"type":"uint256","name":"id","internalType":"uint256"},{"type":"uint256","name":"amount","internalType":"uint256"},{"type":"bytes","name":"data","internalType":"bytes"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"voidBadge","inputs":[{"type":"address","name":"_target","internalType":"address"},{"type":"string","name":"_id","internalType":"string"},{"type":"uint256","name":"_amount","internalType":"uint256"},{"type":"string","name":"_reason","internalType":"string"}]}]
              

Contract Creation Code

0x60806040523480156200001157600080fd5b506200001c62000022565b620000e4565b600054610100900460ff16156200008f5760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840160405180910390fd5b60005460ff9081161015620000e2576000805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b61342d80620000f46000396000f3fe608060405234801561001057600080fd5b50600436106100925760003560e01c80635baef726116100665780635baef7261461011d57806381a4387d14610130578063c8da499c14610143578063e2d52e1d14610156578063f22f957a1461017657600080fd5b80629c24591461009757806321f20559146100d557806344c1f27e146100f5578063485cc9551461010a575b600080fd5b6100c26100a5366004612bbb565b805160208183018101805160028252928201919093012091525481565b6040519081526020015b60405180910390f35b6100e86100e3366004612c6f565b610196565b6040516100cc9190613188565b6101086101033660046129ab565b610230565b005b6101086101183660046127eb565b6109fd565b61010861012b36600461281e565b610b76565b61010861013e36600461292d565b610f53565b6101086101513660046128c8565b611518565b610169610164366004612c6f565b61179b565b6040516100cc91906131e5565b610189610184366004612c6f565b611d01565b6040516100cc9190613175565b600660205260009081526040902080546101af9061335f565b80601f01602080910402602001604051908101604052809291908181526020018280546101db9061335f565b80156102285780601f106101fd57610100808354040283529160200191610228565b820191906000526020600020905b81548152906001019060200180831161020b57829003601f168201915b505050505081565b600283602001516040516102449190612f6c565b90815260200160405180910390205460001461029b5760405162461bcd60e51b815260206004820152601160248201527024a21030b63932b0b23c9032bc34b9ba1760791b60448201526064015b60405180910390fd5b60008360e00151116102e85760405162461bcd60e51b815260206004820152601660248201527521b0b73737ba1036b4b73a103d32b937903a37b5b2b760511b6044820152606401610292565b6000546040516352935f3960e11b8152336004820152620100009091046001600160a01b03169063a526be729060240160206040518083038186803b15801561033057600080fd5b505afa158015610344573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103689190612b80565b6103a75760405162461bcd60e51b815260206004820152601060248201526f6f6e6c79206d696e74657220726f6c6560801b6044820152606401610292565b60005460405163155c217560e11b8152336004820152620100009091046001600160a01b031690632ab842ea9060240160206040518083038186803b1580156103ef57600080fd5b505afa158015610403573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104279190612b80565b6104735760405162461bcd60e51b815260206004820152601760248201527f4e65656420746f6b656e2061636365737320726f6c652e0000000000000000006044820152606401610292565b60015460408051629a9b7b60e01b815290516000926001600160a01b031691629a9b7b916004808301926020929190829003018186803b1580156104b657600080fd5b505afa1580156104ca573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104ee9190612ba2565b600081815260046020526040902060078054929350909161050e9061335f565b6105199291906122eb565b50806002856020015160405161052f9190612f6c565b90815260405190819003602001902055600860005b83518110156106265781848281518110610560576105606133cb565b60209081029190910181015182546001810184556000938452928290208151805192946006029091019261059992849290910190612376565b5060208281015180516105b29260018501920190612376565b50604082015180516105ce916002840191602090910190612376565b50606082015180516105ea916003840191602090910190612376565b5060808201518051610606916004840191602090910190612376565b5060a082015181600501555050808061061e9061339a565b915050610544565b5060008281526005602052604090208154610643919083906123ea565b50610650600860006124e3565b33610120860152818552426101408601526007805461066e9061335f565b80601f016020809104026020016040519081016040528092919081815260200182805461069a9061335f565b80156106e75780601f106106bc576101008083540402835291602001916106e7565b820191906000526020600020905b8154815290600101906020018083116106ca57829003601f168201915b505050505060c08601526040805180820182526001808252604160f81b60208084019190915261010089019290925254875160e0890151928901519351631c2f2dcd60e31b81526001600160a01b039092169363e1796e6893610759938c939233913091908d906007906004016130f9565b600060405180830381600087803b15801561077357600080fd5b505af1158015610787573d6000803e3d6000fd5b50506001548751604051631f888f5760e11b81526001600160a01b038b81166004830152602482019290925233604482015291169250633f111eae9150606401600060405180830381600087803b1580156107e157600080fd5b505af11580156107f5573d6000803e3d6000fd5b505050600083815260036020908152604090912087518155818801518051899450919261082a92600185019290910190612376565b5060408201518051610846916002840191602090910190612376565b5060608201518051610862916003840191602090910190612376565b506080820151805161087e916004840191602090910190612376565b5060a0820151805161089a916005840191602090910190612376565b5060c082015180516108b6916006840191602090910190612376565b5060e0820151600782015561010082015180516108dd916008840191602090910190612376565b506101208201516009820180546001600160a01b0319166001600160a01b03928316179055610140830151600a83015561016090920151600b90910155600054604051630577a59560e01b81523360048201526201000090910490911690630577a5959060240160006040518083038186803b15801561095c57600080fd5b505afa158015610970573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526109989190810190612bf8565b600083815260066020908152604090912082516109bb9391929190910190612376565b507ffd37ab6832588cc442f9335205ccfd918eca15dbb97f5f870737a62c37add0ee85846040516109ed9291906131f8565b60405180910390a1505050505050565b600054610100900460ff1615808015610a1d5750600054600160ff909116105b80610a375750303b158015610a37575060005460ff166001145b610a9a5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610292565b6000805460ff191660011790558015610abd576000805461ff0019166101001790555b60408051808201909152600580825264424144474560d81b6020909201918252610ae991600791612376565b506000805462010000600160b01b031916620100006001600160a01b038681169190910291909117909155600180546001600160a01b0319169184169190911790558015610b71576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b505050565b60005460405163094d62f960e01b8152336004820152620100009091046001600160a01b03169063094d62f99060240160206040518083038186803b158015610bbe57600080fd5b505afa158015610bd2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bf69190612b80565b610c375760405162461bcd60e51b81526020600482015260126024820152716f6e6c79207472616e7366657220726f6c6560701b6044820152606401610292565b60005b8351811015610e1557600060029054906101000a90046001600160a01b03166001600160a01b0316636b7a9dbd3360066000888681518110610c7e57610c7e6133cb565b602002602001015181526020019081526020016000206040518363ffffffff1660e01b8152600401610cb1929190613090565b60206040518083038186803b158015610cc957600080fd5b505afa158015610cdd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d019190612b80565b80610d8757506000546040516371c35f1760e11b8152336004820152620100009091046001600160a01b03169063e386be2e9060240160206040518083038186803b158015610d4f57600080fd5b505afa158015610d63573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d879190612b80565b610da35760405162461bcd60e51b8152600401610292906131ae565b6000848281518110610db757610db76133cb565b602002602001015111610e035760405162461bcd60e51b81526020600482015260146024820152733a37b5b2b710181034b9b713ba1032bc34b9ba1760611b6044820152606401610292565b80610e0d8161339a565b915050610c3a565b50600154600054604051630577a59560e01b815233600482018190526001600160a01b039384169363b00f8998938a938a938a938a938a936201000090910490911690630577a5959060240160006040518083038186803b158015610e7957600080fd5b505afa158015610e8d573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610eb59190810190612bf8565b6040518863ffffffff1660e01b8152600401610ed79796959493929190612f88565b600060405180830381600087803b158015610ef157600080fd5b505af1158015610f05573d6000803e3d6000fd5b5050505060005b8351811015610f4b57610f39848281518110610f2a57610f2a6133cb565b602002602001015187876120e7565b80610f438161339a565b915050610f0c565b505050505050565b600283604051610f639190612f6c565b90815260200160405180910390205460001415610fb65760405162461bcd60e51b815260206004820152601160248201527010985919d9481a5cdb89dd08195e1a5cdd607a1b6044820152606401610292565b60005460405163081c456360e41b8152336004820152620100009091046001600160a01b0316906381c456309060240160206040518083038186803b158015610ffe57600080fd5b505afa158015611012573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110369190612b80565b6110755760405162461bcd60e51b815260206004820152601060248201526f6f6e6c79206275726e657220726f6c6560801b6044820152606401610292565b600060029054906101000a90046001600160a01b03166001600160a01b0316636b7a9dbd33600660006002886040516110ae9190612f6c565b90815260200160405180910390205481526020019081526020016000206040518363ffffffff1660e01b81526004016110e8929190613090565b60206040518083038186803b15801561110057600080fd5b505afa158015611114573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111389190612b80565b806111be57506000546040516371c35f1760e11b8152336004820152620100009091046001600160a01b03169063e386be2e9060240160206040518083038186803b15801561118657600080fd5b505afa15801561119a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111be9190612b80565b6111da5760405162461bcd60e51b8152600401610292906131ae565b61122182600360006002876040516111f29190612f6c565b9081526020016040518091039020548152602001908152602001600020600701546122d890919063ffffffff16565b50604051806040016040528060018152602001604960f81b815250600360006002866040516112509190612f6c565b90815260200160405180910390205481526020019081526020016000206008019080519060200190611283929190612376565b506001546040516001600160a01b039091169063c72c91769086906002906112ac908890612f6c565b90815260200160405180910390205485336006600060028b6040516112d19190612f6c565b90815260200160405180910390205481526020019081526020016000206040518663ffffffff1660e01b815260040161130e9594939291906130b4565b600060405180830381600087803b15801561132857600080fd5b505af115801561133c573d6000803e3d6000fd5b50506001546040516001600160a01b039091169250631a87b5f19150869083906371ad9946908390600290611372908b90612f6c565b908152604051908190036020018120546001600160e01b031960e085901b1682526113b492916004016001600160a01b03929092168252602082015260400190565b60206040518083038186803b1580156113cc57600080fd5b505afa1580156113e0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114049190612ba2565b336006600060028a6040516114199190612f6c565b90815260200160405180910390205481526020019081526020016000206040518563ffffffff1660e01b81526004016114559493929190613053565b600060405180830381600087803b15801561146f57600080fd5b505af1158015611483573d6000803e3d6000fd5b505050507fe412c3ed3bc86003762d5c5869c3941b074905a1fb7cdf94338731e407850ef46002846040516114b89190612f6c565b90815260200160405180910390205483600460006002886040516114dc9190612f6c565b90815260200160405180910390205481526020019081526020016000208460405161150a949392919061321d565b60405180910390a150505050565b6000805484825260066020526040918290209151636b7a9dbd60e01b8152620100009091046001600160a01b031691636b7a9dbd9161155b913391600401613090565b60206040518083038186803b15801561157357600080fd5b505afa158015611587573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115ab9190612b80565b8061163157506000546040516371c35f1760e11b8152336004820152620100009091046001600160a01b03169063e386be2e9060240160206040518083038186803b1580156115f957600080fd5b505afa15801561160d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116319190612b80565b61164d5760405162461bcd60e51b8152600401610292906131ae565b60005460405163094d62f960e01b8152336004820152620100009091046001600160a01b03169063094d62f99060240160206040518083038186803b15801561169557600080fd5b505afa1580156116a9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116cd9190612b80565b61170e5760405162461bcd60e51b81526020600482015260126024820152716f6e6c79207472616e7366657220726f6c6560701b6044820152606401610292565b60015460008481526006602052604090819020905163c34850ab60e01b81526001600160a01b039092169163c34850ab9161175791899189918991899189913391600401613003565b600060405180830381600087803b15801561177157600080fd5b505af1158015611785573d6000803e3d6000fd5b505050506117948386866120e7565b5050505050565b61180860405180610180016040528060008152602001606081526020016060815260200160608152602001606081526020016060815260200160608152602001600081526020016060815260200160006001600160a01b0316815260200160008152602001600081525090565b600760405160200161181a919061319b565b60408051601f19818403018152828252805160209182012060008681526004835292909220919261184c92910161319b565b60405160208183030381529060405280519060200120146118a25760405162461bcd60e51b815260206004820152601060248201526f2737ba103130b233b2903a37b5b2b71760811b6044820152606401610292565b6003600083815260200190815260200160002060405180610180016040529081600082015481526020016001820180546118db9061335f565b80601f01602080910402602001604051908101604052809291908181526020018280546119079061335f565b80156119545780601f1061192957610100808354040283529160200191611954565b820191906000526020600020905b81548152906001019060200180831161193757829003601f168201915b5050505050815260200160028201805461196d9061335f565b80601f01602080910402602001604051908101604052809291908181526020018280546119999061335f565b80156119e65780601f106119bb576101008083540402835291602001916119e6565b820191906000526020600020905b8154815290600101906020018083116119c957829003601f168201915b505050505081526020016003820180546119ff9061335f565b80601f0160208091040260200160405190810160405280929190818152602001828054611a2b9061335f565b8015611a785780601f10611a4d57610100808354040283529160200191611a78565b820191906000526020600020905b815481529060010190602001808311611a5b57829003601f168201915b50505050508152602001600482018054611a919061335f565b80601f0160208091040260200160405190810160405280929190818152602001828054611abd9061335f565b8015611b0a5780601f10611adf57610100808354040283529160200191611b0a565b820191906000526020600020905b815481529060010190602001808311611aed57829003601f168201915b50505050508152602001600582018054611b239061335f565b80601f0160208091040260200160405190810160405280929190818152602001828054611b4f9061335f565b8015611b9c5780601f10611b7157610100808354040283529160200191611b9c565b820191906000526020600020905b815481529060010190602001808311611b7f57829003601f168201915b50505050508152602001600682018054611bb59061335f565b80601f0160208091040260200160405190810160405280929190818152602001828054611be19061335f565b8015611c2e5780601f10611c0357610100808354040283529160200191611c2e565b820191906000526020600020905b815481529060010190602001808311611c1157829003601f168201915b5050505050815260200160078201548152602001600882018054611c519061335f565b80601f0160208091040260200160405190810160405280929190818152602001828054611c7d9061335f565b8015611cca5780601f10611c9f57610100808354040283529160200191611cca565b820191906000526020600020905b815481529060010190602001808311611cad57829003601f168201915b505050918352505060098201546001600160a01b03166020820152600a8201546040820152600b9091015460609091015292915050565b60606007604051602001611d15919061319b565b60408051601f198184030181528282528051602091820120600086815260048352929092209192611d4792910161319b565b6040516020818303038152906040528051906020012014611d9d5760405162461bcd60e51b815260206004820152601060248201526f2737ba103130b233b2903a37b5b2b71760811b6044820152606401610292565b600082815260056020908152604080832080548251818502810185019093528083529193909284015b828210156120dc57838290600052602060002090600602016040518060c0016040529081600082018054611df99061335f565b80601f0160208091040260200160405190810160405280929190818152602001828054611e259061335f565b8015611e725780601f10611e4757610100808354040283529160200191611e72565b820191906000526020600020905b815481529060010190602001808311611e5557829003601f168201915b50505050508152602001600182018054611e8b9061335f565b80601f0160208091040260200160405190810160405280929190818152602001828054611eb79061335f565b8015611f045780601f10611ed957610100808354040283529160200191611f04565b820191906000526020600020905b815481529060010190602001808311611ee757829003601f168201915b50505050508152602001600282018054611f1d9061335f565b80601f0160208091040260200160405190810160405280929190818152602001828054611f499061335f565b8015611f965780601f10611f6b57610100808354040283529160200191611f96565b820191906000526020600020905b815481529060010190602001808311611f7957829003601f168201915b50505050508152602001600382018054611faf9061335f565b80601f0160208091040260200160405190810160405280929190818152602001828054611fdb9061335f565b80156120285780601f10611ffd57610100808354040283529160200191612028565b820191906000526020600020905b81548152906001019060200180831161200b57829003601f168201915b505050505081526020016004820180546120419061335f565b80601f016020809104026020016040519081016040528092919081815260200182805461206d9061335f565b80156120ba5780601f1061208f576101008083540402835291602001916120ba565b820191906000526020600020905b81548152906001019060200180831161209d57829003601f168201915b5050505050815260200160058201548152505081526020019060010190611dc6565b505050509050919050565b6001546040516338d6cca360e11b81526001600160a01b0384811660048301526024820186905290911690631a87b5f190849083906371ad99469060440160206040518083038186803b15801561213d57600080fd5b505afa158015612151573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121759190612ba2565b6000878152600660205260409081902090516001600160e01b031960e086901b1681526121a89392913391600401613053565b600060405180830381600087803b1580156121c257600080fd5b505af11580156121d6573d6000803e3d6000fd5b50506001546040516338d6cca360e11b81526001600160a01b038581166004830152602482018890526000945090911691506371ad99469060440160206040518083038186803b15801561222957600080fd5b505afa15801561223d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122619190612ba2565b1215610b7157600154604051631f888f5760e11b81526001600160a01b0383811660048301526024820186905233604483015290911690633f111eae90606401600060405180830381600087803b1580156122bb57600080fd5b505af11580156122cf573d6000803e3d6000fd5b50505050505050565b60006122e48284613318565b9392505050565b8280546122f79061335f565b90600052602060002090601f0160209004810192826123195760008555612366565b82601f1061232a5780548555612366565b8280016001018555821561236657600052602060002091601f016020900482015b8281111561236657825482559160010191906001019061234b565b50612372929150612507565b5090565b8280546123829061335f565b90600052602060002090601f0160209004810192826123a45760008555612366565b82601f106123bd57805160ff1916838001178555612366565b82800160010185558215612366579182015b828111156123665782518255916020019190600101906123cf565b8280548282559060005260206000209060060281019282156124d75760005260206000209160060282015b828111156124d757825483908390819083906124309061335f565b61243b9291906122eb565b5060018201816001019080546124509061335f565b61245b9291906122eb565b5060028201816002019080546124709061335f565b61247b9291906122eb565b5060038201816003019080546124909061335f565b61249b9291906122eb565b5060048201816004019080546124b09061335f565b6124bb9291906122eb565b5060058201548160050155505091600601919060060190612415565b5061237292915061251c565b5080546000825560060290600052602060002090810190612504919061251c565b50565b5b808211156123725760008155600101612508565b808211156123725760006125308282612578565b61253e600183016000612578565b61254c600283016000612578565b61255a600383016000612578565b612568600483016000612578565b506000600582015560060161251c565b5080546125849061335f565b6000825580601f10612594575050565b601f0160209004906000526020600020908101906125049190612507565b80356001600160a01b03811681146125c957600080fd5b919050565b600082601f8301126125df57600080fd5b813560206125f46125ef836132cc565b61329b565b80838252828201915082860187848660051b890101111561261457600080fd5b60005b8581101561272d57813567ffffffffffffffff8082111561263757600080fd5b9089019060c0828c03601f190181131561265057600080fd5b61265861324e565b888401358381111561266957600080fd5b6126778e8b8388010161279a565b82525060408401358381111561268c57600080fd5b61269a8e8b8388010161279a565b8a83015250606080850135848111156126b257600080fd5b6126c08f8c8389010161279a565b6040840152506080850135848111156126d857600080fd5b6126e68f8c8389010161279a565b82840152505060a0840135838111156126fe57600080fd5b61270c8e8b8388010161279a565b60808301525092013560a08301525084529284019290840190600101612617565b5090979650505050505050565b600082601f83011261274b57600080fd5b8135602061275b6125ef836132cc565b80838252828201915082860187848660051b890101111561277b57600080fd5b60005b8581101561272d5781358452928401929084019060010161277e565b600082601f8301126127ab57600080fd5b81356127b96125ef826132f0565b8181528460208386010111156127ce57600080fd5b816020850160208301376000918101602001919091529392505050565b600080604083850312156127fe57600080fd5b612807836125b2565b9150612815602084016125b2565b90509250929050565b600080600080600060a0868803121561283657600080fd5b61283f866125b2565b945061284d602087016125b2565b9350604086013567ffffffffffffffff8082111561286a57600080fd5b61287689838a0161273a565b9450606088013591508082111561288c57600080fd5b61289889838a0161273a565b935060808801359150808211156128ae57600080fd5b506128bb8882890161279a565b9150509295509295909350565b600080600080600060a086880312156128e057600080fd5b6128e9866125b2565b94506128f7602087016125b2565b93506040860135925060608601359150608086013567ffffffffffffffff81111561292157600080fd5b6128bb8882890161279a565b6000806000806080858703121561294357600080fd5b61294c856125b2565b9350602085013567ffffffffffffffff8082111561296957600080fd5b6129758883890161279a565b945060408701359350606087013591508082111561299257600080fd5b5061299f8782880161279a565b91505092959194509250565b600080600080608085870312156129c157600080fd5b6129ca856125b2565b9350602085013567ffffffffffffffff808211156129e757600080fd5b9086019061018082890312156129fc57600080fd5b612a04613277565b82358152602083013582811115612a1a57600080fd5b612a268a82860161279a565b602083015250604083013582811115612a3e57600080fd5b612a4a8a82860161279a565b604083015250606083013582811115612a6257600080fd5b612a6e8a82860161279a565b606083015250608083013582811115612a8657600080fd5b612a928a82860161279a565b60808301525060a083013582811115612aaa57600080fd5b612ab68a82860161279a565b60a08301525060c083013582811115612ace57600080fd5b612ada8a82860161279a565b60c08301525060e083013560e08201526101008084013583811115612afe57600080fd5b612b0a8b82870161279a565b828401525050610120612b1e8185016125b2565b908201526101408381013590820152610160928301359281019290925290935060408601359080821115612b5157600080fd5b612b5d8883890161279a565b93506060870135915080821115612b7357600080fd5b5061299f878288016125ce565b600060208284031215612b9257600080fd5b815180151581146122e457600080fd5b600060208284031215612bb457600080fd5b5051919050565b600060208284031215612bcd57600080fd5b813567ffffffffffffffff811115612be457600080fd5b612bf08482850161279a565b949350505050565b600060208284031215612c0a57600080fd5b815167ffffffffffffffff811115612c2157600080fd5b8201601f81018413612c3257600080fd5b8051612c406125ef826132f0565b818152856020838501011115612c5557600080fd5b612c6682602083016020860161332f565b95945050505050565b600060208284031215612c8157600080fd5b5035919050565b600081518084526020808501808196508360051b8101915082860160005b85811015612d52578284038952815160c08151818752612cc882880182612d9a565b9150508682015186820388880152612ce08282612d9a565b91505060408083015187830382890152612cfa8382612d9a565b9250505060608083015187830382890152612d158382612d9a565b9250505060808083015187830382890152612d308382612d9a565b60a0948501519890940197909752505098850198935090840190600101612ca6565b5091979650505050505050565b600081518084526020808501945080840160005b83811015612d8f57815187529582019590820190600101612d73565b509495945050505050565b60008151808452612db281602086016020860161332f565b601f01601f19169290920160200192915050565b8054600090600181811c9080831680612de057607f831692505b6020808410821415612e0257634e487b7160e01b600052602260045260246000fd5b83885260208801828015612e1d5760018114612e2e57612e59565b60ff19871682528282019750612e59565b60008981526020902060005b87811015612e5357815484820152908601908401612e3a565b83019850505b5050505050505092915050565b6000610180825184526020830151816020860152612e8682860182612d9a565b91505060408301518482036040860152612ea08282612d9a565b91505060608301518482036060860152612eba8282612d9a565b91505060808301518482036080860152612ed48282612d9a565b91505060a083015184820360a0860152612eee8282612d9a565b91505060c083015184820360c0860152612f088282612d9a565b91505060e083015160e08501526101008084015185830382870152612f2d8382612d9a565b9250505061012080840151612f4c828701826001600160a01b03169052565b505061014083810151908501526101609283015192909301919091525090565b60008251612f7e81846020870161332f565b9190910192915050565b600060018060a01b03808a168352808916602084015260e06040840152612fb260e0840189612d5f565b8381036060850152612fc48189612d5f565b90508381036080850152612fd88188612d9a565b905081861660a085015283810360c0850152612ff48186612d9a565b9b9a5050505050505050505050565b600060018060a01b03808a168352808916602084015287604084015286606084015260e0608084015261303960e0840187612d9a565b81861660a085015283810360c0850152612ff48186612dc6565b6001600160a01b038581168252602082018590528316604082015260806060820181905260009061308690830184612dc6565b9695505050505050565b6001600160a01b0383168152604060208201819052600090612bf090830184612dc6565b6001600160a01b03868116825260208201869052604082018590528316606082015260a0608082018190526000906130ee90830184612dc6565b979650505050505050565b6001600160a01b0389811682526020820189905260408201889052610120606083018190526000908301819052878216608084015290861660a083015261014060c0830181905261314c81840187612d9a565b905082810360e08401526131608186612d9a565b9050828103610100840152612ff48185612dc6565b6020815260006122e46020830184612c88565b6020815260006122e46020830184612d9a565b6020815260006122e46020830184612dc6565b6020808252601a908201527f496e76616c696420746f6b656e2061636365737320726f6c652e000000000000604082015260600190565b6020815260006122e46020830184612e66565b60408152600061320b6040830185612e66565b8281036020840152612c668185612c88565b84815283602082015260806040820152600061323c6080830185612dc6565b82810360608401526130ee8185612d9a565b60405160c0810167ffffffffffffffff81118282101715613271576132716133e1565b60405290565b604051610180810167ffffffffffffffff81118282101715613271576132716133e1565b604051601f8201601f1916810167ffffffffffffffff811182821017156132c4576132c46133e1565b604052919050565b600067ffffffffffffffff8211156132e6576132e66133e1565b5060051b60200190565b600067ffffffffffffffff82111561330a5761330a6133e1565b50601f01601f191660200190565b60008282101561332a5761332a6133b5565b500390565b60005b8381101561334a578181015183820152602001613332565b83811115613359576000848401525b50505050565b600181811c9082168061337357607f821691505b6020821081141561339457634e487b7160e01b600052602260045260246000fd5b50919050565b60006000198214156133ae576133ae6133b5565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fdfea26469706673582212203c8a33be88171c1f5a1f697c476a6d65fb4220f9d04c9c3bd86a0fefdf9dd5cb64736f6c63430008070033

Deployed ByteCode

0x608060405234801561001057600080fd5b50600436106100925760003560e01c80635baef726116100665780635baef7261461011d57806381a4387d14610130578063c8da499c14610143578063e2d52e1d14610156578063f22f957a1461017657600080fd5b80629c24591461009757806321f20559146100d557806344c1f27e146100f5578063485cc9551461010a575b600080fd5b6100c26100a5366004612bbb565b805160208183018101805160028252928201919093012091525481565b6040519081526020015b60405180910390f35b6100e86100e3366004612c6f565b610196565b6040516100cc9190613188565b6101086101033660046129ab565b610230565b005b6101086101183660046127eb565b6109fd565b61010861012b36600461281e565b610b76565b61010861013e36600461292d565b610f53565b6101086101513660046128c8565b611518565b610169610164366004612c6f565b61179b565b6040516100cc91906131e5565b610189610184366004612c6f565b611d01565b6040516100cc9190613175565b600660205260009081526040902080546101af9061335f565b80601f01602080910402602001604051908101604052809291908181526020018280546101db9061335f565b80156102285780601f106101fd57610100808354040283529160200191610228565b820191906000526020600020905b81548152906001019060200180831161020b57829003601f168201915b505050505081565b600283602001516040516102449190612f6c565b90815260200160405180910390205460001461029b5760405162461bcd60e51b815260206004820152601160248201527024a21030b63932b0b23c9032bc34b9ba1760791b60448201526064015b60405180910390fd5b60008360e00151116102e85760405162461bcd60e51b815260206004820152601660248201527521b0b73737ba1036b4b73a103d32b937903a37b5b2b760511b6044820152606401610292565b6000546040516352935f3960e11b8152336004820152620100009091046001600160a01b03169063a526be729060240160206040518083038186803b15801561033057600080fd5b505afa158015610344573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103689190612b80565b6103a75760405162461bcd60e51b815260206004820152601060248201526f6f6e6c79206d696e74657220726f6c6560801b6044820152606401610292565b60005460405163155c217560e11b8152336004820152620100009091046001600160a01b031690632ab842ea9060240160206040518083038186803b1580156103ef57600080fd5b505afa158015610403573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104279190612b80565b6104735760405162461bcd60e51b815260206004820152601760248201527f4e65656420746f6b656e2061636365737320726f6c652e0000000000000000006044820152606401610292565b60015460408051629a9b7b60e01b815290516000926001600160a01b031691629a9b7b916004808301926020929190829003018186803b1580156104b657600080fd5b505afa1580156104ca573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104ee9190612ba2565b600081815260046020526040902060078054929350909161050e9061335f565b6105199291906122eb565b50806002856020015160405161052f9190612f6c565b90815260405190819003602001902055600860005b83518110156106265781848281518110610560576105606133cb565b60209081029190910181015182546001810184556000938452928290208151805192946006029091019261059992849290910190612376565b5060208281015180516105b29260018501920190612376565b50604082015180516105ce916002840191602090910190612376565b50606082015180516105ea916003840191602090910190612376565b5060808201518051610606916004840191602090910190612376565b5060a082015181600501555050808061061e9061339a565b915050610544565b5060008281526005602052604090208154610643919083906123ea565b50610650600860006124e3565b33610120860152818552426101408601526007805461066e9061335f565b80601f016020809104026020016040519081016040528092919081815260200182805461069a9061335f565b80156106e75780601f106106bc576101008083540402835291602001916106e7565b820191906000526020600020905b8154815290600101906020018083116106ca57829003601f168201915b505050505060c08601526040805180820182526001808252604160f81b60208084019190915261010089019290925254875160e0890151928901519351631c2f2dcd60e31b81526001600160a01b039092169363e1796e6893610759938c939233913091908d906007906004016130f9565b600060405180830381600087803b15801561077357600080fd5b505af1158015610787573d6000803e3d6000fd5b50506001548751604051631f888f5760e11b81526001600160a01b038b81166004830152602482019290925233604482015291169250633f111eae9150606401600060405180830381600087803b1580156107e157600080fd5b505af11580156107f5573d6000803e3d6000fd5b505050600083815260036020908152604090912087518155818801518051899450919261082a92600185019290910190612376565b5060408201518051610846916002840191602090910190612376565b5060608201518051610862916003840191602090910190612376565b506080820151805161087e916004840191602090910190612376565b5060a0820151805161089a916005840191602090910190612376565b5060c082015180516108b6916006840191602090910190612376565b5060e0820151600782015561010082015180516108dd916008840191602090910190612376565b506101208201516009820180546001600160a01b0319166001600160a01b03928316179055610140830151600a83015561016090920151600b90910155600054604051630577a59560e01b81523360048201526201000090910490911690630577a5959060240160006040518083038186803b15801561095c57600080fd5b505afa158015610970573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526109989190810190612bf8565b600083815260066020908152604090912082516109bb9391929190910190612376565b507ffd37ab6832588cc442f9335205ccfd918eca15dbb97f5f870737a62c37add0ee85846040516109ed9291906131f8565b60405180910390a1505050505050565b600054610100900460ff1615808015610a1d5750600054600160ff909116105b80610a375750303b158015610a37575060005460ff166001145b610a9a5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610292565b6000805460ff191660011790558015610abd576000805461ff0019166101001790555b60408051808201909152600580825264424144474560d81b6020909201918252610ae991600791612376565b506000805462010000600160b01b031916620100006001600160a01b038681169190910291909117909155600180546001600160a01b0319169184169190911790558015610b71576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b505050565b60005460405163094d62f960e01b8152336004820152620100009091046001600160a01b03169063094d62f99060240160206040518083038186803b158015610bbe57600080fd5b505afa158015610bd2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bf69190612b80565b610c375760405162461bcd60e51b81526020600482015260126024820152716f6e6c79207472616e7366657220726f6c6560701b6044820152606401610292565b60005b8351811015610e1557600060029054906101000a90046001600160a01b03166001600160a01b0316636b7a9dbd3360066000888681518110610c7e57610c7e6133cb565b602002602001015181526020019081526020016000206040518363ffffffff1660e01b8152600401610cb1929190613090565b60206040518083038186803b158015610cc957600080fd5b505afa158015610cdd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d019190612b80565b80610d8757506000546040516371c35f1760e11b8152336004820152620100009091046001600160a01b03169063e386be2e9060240160206040518083038186803b158015610d4f57600080fd5b505afa158015610d63573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d879190612b80565b610da35760405162461bcd60e51b8152600401610292906131ae565b6000848281518110610db757610db76133cb565b602002602001015111610e035760405162461bcd60e51b81526020600482015260146024820152733a37b5b2b710181034b9b713ba1032bc34b9ba1760611b6044820152606401610292565b80610e0d8161339a565b915050610c3a565b50600154600054604051630577a59560e01b815233600482018190526001600160a01b039384169363b00f8998938a938a938a938a938a936201000090910490911690630577a5959060240160006040518083038186803b158015610e7957600080fd5b505afa158015610e8d573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610eb59190810190612bf8565b6040518863ffffffff1660e01b8152600401610ed79796959493929190612f88565b600060405180830381600087803b158015610ef157600080fd5b505af1158015610f05573d6000803e3d6000fd5b5050505060005b8351811015610f4b57610f39848281518110610f2a57610f2a6133cb565b602002602001015187876120e7565b80610f438161339a565b915050610f0c565b505050505050565b600283604051610f639190612f6c565b90815260200160405180910390205460001415610fb65760405162461bcd60e51b815260206004820152601160248201527010985919d9481a5cdb89dd08195e1a5cdd607a1b6044820152606401610292565b60005460405163081c456360e41b8152336004820152620100009091046001600160a01b0316906381c456309060240160206040518083038186803b158015610ffe57600080fd5b505afa158015611012573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110369190612b80565b6110755760405162461bcd60e51b815260206004820152601060248201526f6f6e6c79206275726e657220726f6c6560801b6044820152606401610292565b600060029054906101000a90046001600160a01b03166001600160a01b0316636b7a9dbd33600660006002886040516110ae9190612f6c565b90815260200160405180910390205481526020019081526020016000206040518363ffffffff1660e01b81526004016110e8929190613090565b60206040518083038186803b15801561110057600080fd5b505afa158015611114573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111389190612b80565b806111be57506000546040516371c35f1760e11b8152336004820152620100009091046001600160a01b03169063e386be2e9060240160206040518083038186803b15801561118657600080fd5b505afa15801561119a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111be9190612b80565b6111da5760405162461bcd60e51b8152600401610292906131ae565b61122182600360006002876040516111f29190612f6c565b9081526020016040518091039020548152602001908152602001600020600701546122d890919063ffffffff16565b50604051806040016040528060018152602001604960f81b815250600360006002866040516112509190612f6c565b90815260200160405180910390205481526020019081526020016000206008019080519060200190611283929190612376565b506001546040516001600160a01b039091169063c72c91769086906002906112ac908890612f6c565b90815260200160405180910390205485336006600060028b6040516112d19190612f6c565b90815260200160405180910390205481526020019081526020016000206040518663ffffffff1660e01b815260040161130e9594939291906130b4565b600060405180830381600087803b15801561132857600080fd5b505af115801561133c573d6000803e3d6000fd5b50506001546040516001600160a01b039091169250631a87b5f19150869083906371ad9946908390600290611372908b90612f6c565b908152604051908190036020018120546001600160e01b031960e085901b1682526113b492916004016001600160a01b03929092168252602082015260400190565b60206040518083038186803b1580156113cc57600080fd5b505afa1580156113e0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114049190612ba2565b336006600060028a6040516114199190612f6c565b90815260200160405180910390205481526020019081526020016000206040518563ffffffff1660e01b81526004016114559493929190613053565b600060405180830381600087803b15801561146f57600080fd5b505af1158015611483573d6000803e3d6000fd5b505050507fe412c3ed3bc86003762d5c5869c3941b074905a1fb7cdf94338731e407850ef46002846040516114b89190612f6c565b90815260200160405180910390205483600460006002886040516114dc9190612f6c565b90815260200160405180910390205481526020019081526020016000208460405161150a949392919061321d565b60405180910390a150505050565b6000805484825260066020526040918290209151636b7a9dbd60e01b8152620100009091046001600160a01b031691636b7a9dbd9161155b913391600401613090565b60206040518083038186803b15801561157357600080fd5b505afa158015611587573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115ab9190612b80565b8061163157506000546040516371c35f1760e11b8152336004820152620100009091046001600160a01b03169063e386be2e9060240160206040518083038186803b1580156115f957600080fd5b505afa15801561160d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116319190612b80565b61164d5760405162461bcd60e51b8152600401610292906131ae565b60005460405163094d62f960e01b8152336004820152620100009091046001600160a01b03169063094d62f99060240160206040518083038186803b15801561169557600080fd5b505afa1580156116a9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116cd9190612b80565b61170e5760405162461bcd60e51b81526020600482015260126024820152716f6e6c79207472616e7366657220726f6c6560701b6044820152606401610292565b60015460008481526006602052604090819020905163c34850ab60e01b81526001600160a01b039092169163c34850ab9161175791899189918991899189913391600401613003565b600060405180830381600087803b15801561177157600080fd5b505af1158015611785573d6000803e3d6000fd5b505050506117948386866120e7565b5050505050565b61180860405180610180016040528060008152602001606081526020016060815260200160608152602001606081526020016060815260200160608152602001600081526020016060815260200160006001600160a01b0316815260200160008152602001600081525090565b600760405160200161181a919061319b565b60408051601f19818403018152828252805160209182012060008681526004835292909220919261184c92910161319b565b60405160208183030381529060405280519060200120146118a25760405162461bcd60e51b815260206004820152601060248201526f2737ba103130b233b2903a37b5b2b71760811b6044820152606401610292565b6003600083815260200190815260200160002060405180610180016040529081600082015481526020016001820180546118db9061335f565b80601f01602080910402602001604051908101604052809291908181526020018280546119079061335f565b80156119545780601f1061192957610100808354040283529160200191611954565b820191906000526020600020905b81548152906001019060200180831161193757829003601f168201915b5050505050815260200160028201805461196d9061335f565b80601f01602080910402602001604051908101604052809291908181526020018280546119999061335f565b80156119e65780601f106119bb576101008083540402835291602001916119e6565b820191906000526020600020905b8154815290600101906020018083116119c957829003601f168201915b505050505081526020016003820180546119ff9061335f565b80601f0160208091040260200160405190810160405280929190818152602001828054611a2b9061335f565b8015611a785780601f10611a4d57610100808354040283529160200191611a78565b820191906000526020600020905b815481529060010190602001808311611a5b57829003601f168201915b50505050508152602001600482018054611a919061335f565b80601f0160208091040260200160405190810160405280929190818152602001828054611abd9061335f565b8015611b0a5780601f10611adf57610100808354040283529160200191611b0a565b820191906000526020600020905b815481529060010190602001808311611aed57829003601f168201915b50505050508152602001600582018054611b239061335f565b80601f0160208091040260200160405190810160405280929190818152602001828054611b4f9061335f565b8015611b9c5780601f10611b7157610100808354040283529160200191611b9c565b820191906000526020600020905b815481529060010190602001808311611b7f57829003601f168201915b50505050508152602001600682018054611bb59061335f565b80601f0160208091040260200160405190810160405280929190818152602001828054611be19061335f565b8015611c2e5780601f10611c0357610100808354040283529160200191611c2e565b820191906000526020600020905b815481529060010190602001808311611c1157829003601f168201915b5050505050815260200160078201548152602001600882018054611c519061335f565b80601f0160208091040260200160405190810160405280929190818152602001828054611c7d9061335f565b8015611cca5780601f10611c9f57610100808354040283529160200191611cca565b820191906000526020600020905b815481529060010190602001808311611cad57829003601f168201915b505050918352505060098201546001600160a01b03166020820152600a8201546040820152600b9091015460609091015292915050565b60606007604051602001611d15919061319b565b60408051601f198184030181528282528051602091820120600086815260048352929092209192611d4792910161319b565b6040516020818303038152906040528051906020012014611d9d5760405162461bcd60e51b815260206004820152601060248201526f2737ba103130b233b2903a37b5b2b71760811b6044820152606401610292565b600082815260056020908152604080832080548251818502810185019093528083529193909284015b828210156120dc57838290600052602060002090600602016040518060c0016040529081600082018054611df99061335f565b80601f0160208091040260200160405190810160405280929190818152602001828054611e259061335f565b8015611e725780601f10611e4757610100808354040283529160200191611e72565b820191906000526020600020905b815481529060010190602001808311611e5557829003601f168201915b50505050508152602001600182018054611e8b9061335f565b80601f0160208091040260200160405190810160405280929190818152602001828054611eb79061335f565b8015611f045780601f10611ed957610100808354040283529160200191611f04565b820191906000526020600020905b815481529060010190602001808311611ee757829003601f168201915b50505050508152602001600282018054611f1d9061335f565b80601f0160208091040260200160405190810160405280929190818152602001828054611f499061335f565b8015611f965780601f10611f6b57610100808354040283529160200191611f96565b820191906000526020600020905b815481529060010190602001808311611f7957829003601f168201915b50505050508152602001600382018054611faf9061335f565b80601f0160208091040260200160405190810160405280929190818152602001828054611fdb9061335f565b80156120285780601f10611ffd57610100808354040283529160200191612028565b820191906000526020600020905b81548152906001019060200180831161200b57829003601f168201915b505050505081526020016004820180546120419061335f565b80601f016020809104026020016040519081016040528092919081815260200182805461206d9061335f565b80156120ba5780601f1061208f576101008083540402835291602001916120ba565b820191906000526020600020905b81548152906001019060200180831161209d57829003601f168201915b5050505050815260200160058201548152505081526020019060010190611dc6565b505050509050919050565b6001546040516338d6cca360e11b81526001600160a01b0384811660048301526024820186905290911690631a87b5f190849083906371ad99469060440160206040518083038186803b15801561213d57600080fd5b505afa158015612151573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121759190612ba2565b6000878152600660205260409081902090516001600160e01b031960e086901b1681526121a89392913391600401613053565b600060405180830381600087803b1580156121c257600080fd5b505af11580156121d6573d6000803e3d6000fd5b50506001546040516338d6cca360e11b81526001600160a01b038581166004830152602482018890526000945090911691506371ad99469060440160206040518083038186803b15801561222957600080fd5b505afa15801561223d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122619190612ba2565b1215610b7157600154604051631f888f5760e11b81526001600160a01b0383811660048301526024820186905233604483015290911690633f111eae90606401600060405180830381600087803b1580156122bb57600080fd5b505af11580156122cf573d6000803e3d6000fd5b50505050505050565b60006122e48284613318565b9392505050565b8280546122f79061335f565b90600052602060002090601f0160209004810192826123195760008555612366565b82601f1061232a5780548555612366565b8280016001018555821561236657600052602060002091601f016020900482015b8281111561236657825482559160010191906001019061234b565b50612372929150612507565b5090565b8280546123829061335f565b90600052602060002090601f0160209004810192826123a45760008555612366565b82601f106123bd57805160ff1916838001178555612366565b82800160010185558215612366579182015b828111156123665782518255916020019190600101906123cf565b8280548282559060005260206000209060060281019282156124d75760005260206000209160060282015b828111156124d757825483908390819083906124309061335f565b61243b9291906122eb565b5060018201816001019080546124509061335f565b61245b9291906122eb565b5060028201816002019080546124709061335f565b61247b9291906122eb565b5060038201816003019080546124909061335f565b61249b9291906122eb565b5060048201816004019080546124b09061335f565b6124bb9291906122eb565b5060058201548160050155505091600601919060060190612415565b5061237292915061251c565b5080546000825560060290600052602060002090810190612504919061251c565b50565b5b808211156123725760008155600101612508565b808211156123725760006125308282612578565b61253e600183016000612578565b61254c600283016000612578565b61255a600383016000612578565b612568600483016000612578565b506000600582015560060161251c565b5080546125849061335f565b6000825580601f10612594575050565b601f0160209004906000526020600020908101906125049190612507565b80356001600160a01b03811681146125c957600080fd5b919050565b600082601f8301126125df57600080fd5b813560206125f46125ef836132cc565b61329b565b80838252828201915082860187848660051b890101111561261457600080fd5b60005b8581101561272d57813567ffffffffffffffff8082111561263757600080fd5b9089019060c0828c03601f190181131561265057600080fd5b61265861324e565b888401358381111561266957600080fd5b6126778e8b8388010161279a565b82525060408401358381111561268c57600080fd5b61269a8e8b8388010161279a565b8a83015250606080850135848111156126b257600080fd5b6126c08f8c8389010161279a565b6040840152506080850135848111156126d857600080fd5b6126e68f8c8389010161279a565b82840152505060a0840135838111156126fe57600080fd5b61270c8e8b8388010161279a565b60808301525092013560a08301525084529284019290840190600101612617565b5090979650505050505050565b600082601f83011261274b57600080fd5b8135602061275b6125ef836132cc565b80838252828201915082860187848660051b890101111561277b57600080fd5b60005b8581101561272d5781358452928401929084019060010161277e565b600082601f8301126127ab57600080fd5b81356127b96125ef826132f0565b8181528460208386010111156127ce57600080fd5b816020850160208301376000918101602001919091529392505050565b600080604083850312156127fe57600080fd5b612807836125b2565b9150612815602084016125b2565b90509250929050565b600080600080600060a0868803121561283657600080fd5b61283f866125b2565b945061284d602087016125b2565b9350604086013567ffffffffffffffff8082111561286a57600080fd5b61287689838a0161273a565b9450606088013591508082111561288c57600080fd5b61289889838a0161273a565b935060808801359150808211156128ae57600080fd5b506128bb8882890161279a565b9150509295509295909350565b600080600080600060a086880312156128e057600080fd5b6128e9866125b2565b94506128f7602087016125b2565b93506040860135925060608601359150608086013567ffffffffffffffff81111561292157600080fd5b6128bb8882890161279a565b6000806000806080858703121561294357600080fd5b61294c856125b2565b9350602085013567ffffffffffffffff8082111561296957600080fd5b6129758883890161279a565b945060408701359350606087013591508082111561299257600080fd5b5061299f8782880161279a565b91505092959194509250565b600080600080608085870312156129c157600080fd5b6129ca856125b2565b9350602085013567ffffffffffffffff808211156129e757600080fd5b9086019061018082890312156129fc57600080fd5b612a04613277565b82358152602083013582811115612a1a57600080fd5b612a268a82860161279a565b602083015250604083013582811115612a3e57600080fd5b612a4a8a82860161279a565b604083015250606083013582811115612a6257600080fd5b612a6e8a82860161279a565b606083015250608083013582811115612a8657600080fd5b612a928a82860161279a565b60808301525060a083013582811115612aaa57600080fd5b612ab68a82860161279a565b60a08301525060c083013582811115612ace57600080fd5b612ada8a82860161279a565b60c08301525060e083013560e08201526101008084013583811115612afe57600080fd5b612b0a8b82870161279a565b828401525050610120612b1e8185016125b2565b908201526101408381013590820152610160928301359281019290925290935060408601359080821115612b5157600080fd5b612b5d8883890161279a565b93506060870135915080821115612b7357600080fd5b5061299f878288016125ce565b600060208284031215612b9257600080fd5b815180151581146122e457600080fd5b600060208284031215612bb457600080fd5b5051919050565b600060208284031215612bcd57600080fd5b813567ffffffffffffffff811115612be457600080fd5b612bf08482850161279a565b949350505050565b600060208284031215612c0a57600080fd5b815167ffffffffffffffff811115612c2157600080fd5b8201601f81018413612c3257600080fd5b8051612c406125ef826132f0565b818152856020838501011115612c5557600080fd5b612c6682602083016020860161332f565b95945050505050565b600060208284031215612c8157600080fd5b5035919050565b600081518084526020808501808196508360051b8101915082860160005b85811015612d52578284038952815160c08151818752612cc882880182612d9a565b9150508682015186820388880152612ce08282612d9a565b91505060408083015187830382890152612cfa8382612d9a565b9250505060608083015187830382890152612d158382612d9a565b9250505060808083015187830382890152612d308382612d9a565b60a0948501519890940197909752505098850198935090840190600101612ca6565b5091979650505050505050565b600081518084526020808501945080840160005b83811015612d8f57815187529582019590820190600101612d73565b509495945050505050565b60008151808452612db281602086016020860161332f565b601f01601f19169290920160200192915050565b8054600090600181811c9080831680612de057607f831692505b6020808410821415612e0257634e487b7160e01b600052602260045260246000fd5b83885260208801828015612e1d5760018114612e2e57612e59565b60ff19871682528282019750612e59565b60008981526020902060005b87811015612e5357815484820152908601908401612e3a565b83019850505b5050505050505092915050565b6000610180825184526020830151816020860152612e8682860182612d9a565b91505060408301518482036040860152612ea08282612d9a565b91505060608301518482036060860152612eba8282612d9a565b91505060808301518482036080860152612ed48282612d9a565b91505060a083015184820360a0860152612eee8282612d9a565b91505060c083015184820360c0860152612f088282612d9a565b91505060e083015160e08501526101008084015185830382870152612f2d8382612d9a565b9250505061012080840151612f4c828701826001600160a01b03169052565b505061014083810151908501526101609283015192909301919091525090565b60008251612f7e81846020870161332f565b9190910192915050565b600060018060a01b03808a168352808916602084015260e06040840152612fb260e0840189612d5f565b8381036060850152612fc48189612d5f565b90508381036080850152612fd88188612d9a565b905081861660a085015283810360c0850152612ff48186612d9a565b9b9a5050505050505050505050565b600060018060a01b03808a168352808916602084015287604084015286606084015260e0608084015261303960e0840187612d9a565b81861660a085015283810360c0850152612ff48186612dc6565b6001600160a01b038581168252602082018590528316604082015260806060820181905260009061308690830184612dc6565b9695505050505050565b6001600160a01b0383168152604060208201819052600090612bf090830184612dc6565b6001600160a01b03868116825260208201869052604082018590528316606082015260a0608082018190526000906130ee90830184612dc6565b979650505050505050565b6001600160a01b0389811682526020820189905260408201889052610120606083018190526000908301819052878216608084015290861660a083015261014060c0830181905261314c81840187612d9a565b905082810360e08401526131608186612d9a565b9050828103610100840152612ff48185612dc6565b6020815260006122e46020830184612c88565b6020815260006122e46020830184612d9a565b6020815260006122e46020830184612dc6565b6020808252601a908201527f496e76616c696420746f6b656e2061636365737320726f6c652e000000000000604082015260600190565b6020815260006122e46020830184612e66565b60408152600061320b6040830185612e66565b8281036020840152612c668185612c88565b84815283602082015260806040820152600061323c6080830185612dc6565b82810360608401526130ee8185612d9a565b60405160c0810167ffffffffffffffff81118282101715613271576132716133e1565b60405290565b604051610180810167ffffffffffffffff81118282101715613271576132716133e1565b604051601f8201601f1916810167ffffffffffffffff811182821017156132c4576132c46133e1565b604052919050565b600067ffffffffffffffff8211156132e6576132e66133e1565b5060051b60200190565b600067ffffffffffffffff82111561330a5761330a6133e1565b50601f01601f191660200190565b60008282101561332a5761332a6133b5565b500390565b60005b8381101561334a578181015183820152602001613332565b83811115613359576000848401525b50505050565b600181811c9082168061337357607f821691505b6020821081141561339457634e487b7160e01b600052602260045260246000fd5b50919050565b60006000198214156133ae576133ae6133b5565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fdfea26469706673582212203c8a33be88171c1f5a1f697c476a6d65fb4220f9d04c9c3bd86a0fefdf9dd5cb64736f6c63430008070033