POL Price: $0.125632 (-3.28%)
 

More Info

Private Name Tags

Multichain Info

No addresses found
Transaction Hash
Block
From
To
Mint Tokens819020702026-01-20 15:48:324 days ago1768924112IN
0x776023A4...C2bef516E
0 POL0.14081749578.35818303
Mint Tokens818640172026-01-19 18:40:064 days ago1768848006IN
0x776023A4...C2bef516E
0 POL0.0109553845.00128306
Mint Tokens818638812026-01-19 18:35:344 days ago1768847734IN
0x776023A4...C2bef516E
0 POL0.0112252946.10774686
Mint Tokens816615222026-01-15 2:10:169 days ago1768443016IN
0x776023A4...C2bef516E
0 POL0.89586158527.06235539
Mint Tokens816613112026-01-15 2:03:149 days ago1768442594IN
0x776023A4...C2bef516E
0 POL0.82037971519.52491194
Mint Tokens816608092026-01-15 1:46:309 days ago1768441590IN
0x776023A4...C2bef516E
0 POL5.09493018826.85006064
Mint Tokens816607232026-01-15 1:43:389 days ago1768441418IN
0x776023A4...C2bef516E
0 POL0.09332233949.65229403
Mint Tokens816571632026-01-14 23:44:589 days ago1768434298IN
0x776023A4...C2bef516E
0 POL0.66178186494.61858568
Mint Tokens816571242026-01-14 23:43:409 days ago1768434220IN
0x776023A4...C2bef516E
0 POL0.03113481531.492288
Mint Tokens816265422026-01-14 6:44:1610 days ago1768373056IN
0x776023A4...C2bef516E
0 POL0.12037996476.20541337
Mint Tokens813251822026-01-07 7:07:0317 days ago1767769623IN
0x776023A4...C2bef516E
0 POL0.0363032149.09527941
Permit Funds And...812998392026-01-06 17:02:1717 days ago1767718937IN
0x776023A4...C2bef516E
0 POL0.05005186600.42302705
Permit Funds And...812997582026-01-06 16:59:3517 days ago1767718775IN
0x776023A4...C2bef516E
0 POL0.03349464401.89878282
Permit Funds And...790175892025-11-14 17:07:5670 days ago1763140076IN
0x776023A4...C2bef516E
0 POL0.03250389116.61300562
Permit Funds And...790151412025-11-14 15:46:2071 days ago1763135180IN
0x776023A4...C2bef516E
0 POL0.10249117367.64573204
Permit Funds And...788377202025-11-10 13:12:0475 days ago1762780324IN
0x776023A4...C2bef516E
0 POL0.04658457164.26328605
Permit Funds And...788367852025-11-10 12:40:5475 days ago1762778454IN
0x776023A4...C2bef516E
0 POL0.0270781895.49467875
Permit Funds And...788303942025-11-10 9:07:5275 days ago1762765672IN
0x776023A4...C2bef516E
0 POL0.1135584400.46693154
Permit Funds And...787914732025-11-09 11:30:2776 days ago1762687827IN
0x776023A4...C2bef516E
0 POL0.06301617222.22832178
Permit Funds And...787562302025-11-08 15:55:4176 days ago1762617341IN
0x776023A4...C2bef516E
0 POL0.1003833339.28752765
Permit Funds And...786048892025-11-05 3:50:4180 days ago1762314641IN
0x776023A4...C2bef516E
0 POL0.04158752146.6595956
Permit Funds And...786048622025-11-05 3:49:4780 days ago1762314587IN
0x776023A4...C2bef516E
0 POL0.00763989141.56867355
Permit Funds And...785987342025-11-05 0:25:3180 days ago1762302331IN
0x776023A4...C2bef516E
0 POL0.03078037108.53562614
Permit Funds And...784065182025-10-31 13:37:5685 days ago1761917876IN
0x776023A4...C2bef516E
0 POL0.0232447381.97900075
Permit Funds And...783863882025-10-31 2:26:4585 days ago1761877605IN
0x776023A4...C2bef516E
0 POL0.0084550528.12192374
View all transactions

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

Contract Source Code Verified (Exact Match)

Contract Name:
TokenVendingMachine

Compiler Version
v0.8.7+commit.e28d00a7

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 19 : TokenVendingMachine.sol
// SPDX-FileCopyrightText: © Courtyard Inc. (https://courtyard.io)
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "./TokenMintCheckoutBase.sol";

/**
 * @title TokenVendingMachine is a base implementation of TokenMintCheckoutBase.
 */ 
contract TokenVendingMachine is TokenMintCheckoutBase {

    constructor(string memory name) TokenMintCheckoutBase(name) {}

}

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

pragma solidity ^0.8.0;

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

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

    mapping(bytes32 => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

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

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

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

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

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

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

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

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

        _revokeRole(role, account);
    }

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

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

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

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/AccessControlEnumerable.sol)

pragma solidity ^0.8.0;

import "./IAccessControlEnumerable.sol";
import "./AccessControl.sol";
import "../utils/structs/EnumerableSet.sol";

/**
 * @dev Extension of {AccessControl} that allows enumerating the members of each role.
 */
abstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {
    using EnumerableSet for EnumerableSet.AddressSet;

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControlEnumerable.sol)

pragma solidity ^0.8.0;

import "./IAccessControl.sol";

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

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/Pausable.sol)

pragma solidity ^0.8.0;

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

/**
 * @dev Contract module which allows children to implement an emergency stop
 * mechanism that can be triggered by an authorized account.
 *
 * This module is used through inheritance. It will make available the
 * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
 * the functions of your contract. Note that they will not be pausable by
 * simply including this module, only once the modifiers are put in place.
 */
abstract contract Pausable is Context {
    /**
     * @dev Emitted when the pause is triggered by `account`.
     */
    event Paused(address account);

    /**
     * @dev Emitted when the pause is lifted by `account`.
     */
    event Unpaused(address account);

    bool private _paused;

    /**
     * @dev Initializes the contract in unpaused state.
     */
    constructor() {
        _paused = false;
    }

    /**
     * @dev Returns true if the contract is paused, and false otherwise.
     */
    function paused() public view virtual returns (bool) {
        return _paused;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is not paused.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    modifier whenNotPaused() {
        require(!paused(), "Pausable: paused");
        _;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is paused.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    modifier whenPaused() {
        require(paused(), "Pausable: not paused");
        _;
    }

    /**
     * @dev Triggers stopped state.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    function _pause() internal virtual whenNotPaused {
        _paused = true;
        emit Paused(_msgSender());
    }

    /**
     * @dev Returns to normal state.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    function _unpause() internal virtual whenPaused {
        _paused = false;
        emit Unpaused(_msgSender());
    }
}

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

pragma solidity ^0.8.0;

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

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

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

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

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

        _;

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

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

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

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

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

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

    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";
import "../../../utils/Address.sol";

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

    function safeTransfer(
        IERC20 token,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    function safeTransferFrom(
        IERC20 token,
        address from,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

    /**
     * @dev Deprecated. This function has issues similar to the ones found in
     * {IERC20-approve}, and its usage is discouraged.
     *
     * Whenever possible, use {safeIncreaseAllowance} and
     * {safeDecreaseAllowance} instead.
     */
    function safeApprove(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        require(
            (value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
    }

    function safeIncreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        uint256 newAllowance = token.allowance(address(this), spender) + value;
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            uint256 newAllowance = oldAllowance - value;
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
        }
    }

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

        bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
        if (returndata.length > 0) {
            // Return data is optional
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

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

pragma solidity ^0.8.0;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

pragma solidity ^0.8.0;

import "../Strings.sol";

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

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

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

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

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

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

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

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

        return (signer, RecoverError.NoError);
    }

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

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

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

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

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

pragma solidity ^0.8.0;

import "./IERC165.sol";

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165Checker.sol)

pragma solidity ^0.8.0;

import "./IERC165.sol";

/**
 * @dev Library used to query support of an interface declared via {IERC165}.
 *
 * Note that these functions return the actual result of the query: they do not
 * `revert` if an interface is not supported. It is up to the caller to decide
 * what to do in these cases.
 */
library ERC165Checker {
    // As per the EIP-165 spec, no interface should ever match 0xffffffff
    bytes4 private constant _INTERFACE_ID_INVALID = 0xffffffff;

    /**
     * @dev Returns true if `account` supports the {IERC165} interface,
     */
    function supportsERC165(address account) internal view returns (bool) {
        // Any contract that implements ERC165 must explicitly indicate support of
        // InterfaceId_ERC165 and explicitly indicate non-support of InterfaceId_Invalid
        return
            _supportsERC165Interface(account, type(IERC165).interfaceId) &&
            !_supportsERC165Interface(account, _INTERFACE_ID_INVALID);
    }

    /**
     * @dev Returns true if `account` supports the interface defined by
     * `interfaceId`. Support for {IERC165} itself is queried automatically.
     *
     * See {IERC165-supportsInterface}.
     */
    function supportsInterface(address account, bytes4 interfaceId) internal view returns (bool) {
        // query support of both ERC165 as per the spec and support of _interfaceId
        return supportsERC165(account) && _supportsERC165Interface(account, interfaceId);
    }

    /**
     * @dev Returns a boolean array where each value corresponds to the
     * interfaces passed in and whether they're supported or not. This allows
     * you to batch check interfaces for a contract where your expectation
     * is that some interfaces may not be supported.
     *
     * See {IERC165-supportsInterface}.
     *
     * _Available since v3.4._
     */
    function getSupportedInterfaces(address account, bytes4[] memory interfaceIds)
        internal
        view
        returns (bool[] memory)
    {
        // an array of booleans corresponding to interfaceIds and whether they're supported or not
        bool[] memory interfaceIdsSupported = new bool[](interfaceIds.length);

        // query support of ERC165 itself
        if (supportsERC165(account)) {
            // query support of each interface in interfaceIds
            for (uint256 i = 0; i < interfaceIds.length; i++) {
                interfaceIdsSupported[i] = _supportsERC165Interface(account, interfaceIds[i]);
            }
        }

        return interfaceIdsSupported;
    }

    /**
     * @dev Returns true if `account` supports all the interfaces defined in
     * `interfaceIds`. Support for {IERC165} itself is queried automatically.
     *
     * Batch-querying can lead to gas savings by skipping repeated checks for
     * {IERC165} support.
     *
     * See {IERC165-supportsInterface}.
     */
    function supportsAllInterfaces(address account, bytes4[] memory interfaceIds) internal view returns (bool) {
        // query support of ERC165 itself
        if (!supportsERC165(account)) {
            return false;
        }

        // query support of each interface in _interfaceIds
        for (uint256 i = 0; i < interfaceIds.length; i++) {
            if (!_supportsERC165Interface(account, interfaceIds[i])) {
                return false;
            }
        }

        // all interfaces supported
        return true;
    }

    /**
     * @notice Query if a contract implements an interface, does not check ERC165 support
     * @param account The address of the contract to query for support of an interface
     * @param interfaceId The interface identifier, as specified in ERC-165
     * @return true if the contract at account indicates support of the interface with
     * identifier interfaceId, false otherwise
     * @dev Assumes that account contains a contract that supports ERC165, otherwise
     * the behavior of this method is undefined. This precondition can be checked
     * with {supportsERC165}.
     * Interface identification is specified in ERC-165.
     */
    function _supportsERC165Interface(address account, bytes4 interfaceId) private view returns (bool) {
        bytes memory encodedParams = abi.encodeWithSelector(IERC165.supportsInterface.selector, interfaceId);
        (bool success, bytes memory result) = account.staticcall{gas: 30000}(encodedParams);
        if (result.length < 32) return false;
        return success && abi.decode(result, (bool));
    }
}

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

pragma solidity ^0.8.0;

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

            return true;
        } else {
            return false;
        }
    }

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

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

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

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

    // Bytes32Set

    struct Bytes32Set {
        Set _inner;
    }

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

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

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

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

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

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

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

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

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

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

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

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

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

        assembly {
            result := store
        }

        return result;
    }

    // UintSet

    struct UintSet {
        Set _inner;
    }

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

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

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

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

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

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

        assembly {
            result := store
        }

        return result;
    }
}

// SPDX-FileCopyrightText: © Courtyard Inc. (https://courtyard.io)
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../utils/ERC20PaymentProcessorV2.sol";
import "@openzeppelin/contracts/access/AccessControlEnumerable.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol";

/**
 * @author The Courtyard Team
 * @title {TokenMintCheckoutBase} allows checkouts to mint NFTs using a particular ERC20 token (ex: USDC) for the payment.
 * 
 * It works as follows:
 * 
 *  1. A user starts the checkout process in a front-end application off-chain and is ready to pay.
 * 
 *  2. Upon receiving a checkout request, a back-end service would typically generate a {signature} containing the
 *     following information:
 * 
 *      - {operatingContract}: the address of the appropriate checkout contract.
 *      - {checkoutId}: a unique identifier for that checkout. The {checkoutId} is used to guarantee that each checkout
 *        would not be processed multiple times accidentally.
 *      - {expirationTimestamp}: timestamp in seconds from epoch after which the checkout cannot be completed anymore.
 *      - {paymentRecipient}: the account (i.e. address) that will receive the proceeds of the payment.
 *      - {paymentToken}: the payment token (must be an ERC20 token).
 *      - {paymentValue}: a uint256 representing the payment value in the smallest unit of the payment currency.
 *      - {tokenRecipient}: the recipient for the purchased tokens that will be minted.
 *      - {tokenRegistry}: the registry where the purchased tokens will be minted.
 *      - {tokenHashes}: AN array of the hashex (hex proofs) of the tokens that will be minted.
 * 
 *  4. The backend sends the signed data along with a checkout signature back to the front-end application so the transaction
 *     can be executed.
 * 
 *  5. On the front end:
 * 
 *      - If necessary, the user is first prompted to approve the appropriate token allowance to the checkout contract.
 *      - The user is then prompted to sign the checkout transaction.
 * 
 *  6. During the on-chain transaction:
 * 
 *      - If everything is in order according to the checkout contract processing the request, the funds are withdrawn
 *        and sent to the receiver wallet.
 *      - Then the tokens are minted.
 *      - Finally, the {checkoutId} is marked as processed and a {CheckoutSuccess} event is emitted.
 *  
 *  7. The user now has a successful transaction hash that is a "proof of payment" that can be used to retrieve the 
 *    full transaction result on a block explorer, containing all the information relevant to the checkout, including
 *    the emitted events. This is alike a transaction receipt.
 */

interface TokenRegistryInterface {
    function mintToken(address to, bytes32 proofOfIntegrity) external returns (uint256);
}

/**
 * Contract code.
 */
abstract contract TokenMintCheckoutBase is ReentrancyGuard, AccessControlEnumerable, Pausable, ERC20PaymentProcessorV2 {

    event CheckoutSuccess(address indexed caller, string checkoutId);
    event TokenPurchasedAndMinted(
        address indexed mintedToAddress,
        address mintedTokenAddress,
        uint256 mintedTokenId,
        address paymentTokenAddress,
        uint256 paymentAmount
    );

    /**
     * @dev using a struct to encapsulate all the data that is used to encode a checkout signature.
     */
    struct CheckoutRequest {
        address operatingContract;      // the contract that is supposed to process the given request (which should be this.address for a valid request)
        string checkoutId;              // the id of the checkout.
        uint256 expirationTimestamp;    // expiration timestamp of the request.
        address paymentRecipient;       // the recipient of the payment.
        address paymentToken;           // the payment token (must be an ERC20 token).
        uint256 paymentValue;           // the payment value in the smallest unit of the associated currency.
        address tokenRecipient;         // the recipient of the tokens to mint.
        address tokenRegistry;          // the registry where to mint the tokens.
        bytes32[] tokenHashes;          // the bytes32 ids (hex proofs) of the tokens to mint to the recipient.
    }

    string public name;                     // the name of this contract.
    mapping(bytes32 => bool) processed;     // mapping of all the checkouts that were processed to avoid duplicate charges.


    /* ========================================== CONSTRUCTOR AND SETTERS ========================================== */

    /**
     * @dev constructor.
     */
    constructor(string memory _name) ERC20PaymentProcessorV2() {
        // Set the admin
        AccessControlEnumerable._grantRole(DEFAULT_ADMIN_ROLE, _msgSender());

        // Set the name
        name = _name;
        
        // The contract starts its lifetime in the paused state.
        _pause();
    }


    /* =================================== ROLE HELPERS AND FUNCTIONS OVERRIDES =================================== */

    /**
     * @dev remove external access to {AccessControl.grantRole}.
     */
    function grantRole(bytes32, address) public pure override {
        revert("TokenMintCheckoutBase: A role can only be granted using the corresponding specialized function");
    }

    /**
     * @dev remove external access to {AccessControl.revokeRole}.
     */
    function revokeRole(bytes32, address) public pure override {
        revert("TokenMintCheckoutBase: A role can only be revoked using the corresponding specialized function");
    }

    /**
     * @dev list the addresses that have a particular role.
     */
    function listRoleMembers(bytes32 role) public view returns (address[] memory) {
        uint256 memberCount = getRoleMemberCount(role);
        address[] memory members = new address[](memberCount);
        for (uint ii = 0; ii < memberCount; ii++) {
            members[ii] = getRoleMember(role, ii);
        }
        return members;
    }


    /* ================================================ ADMIN ROLE ================================================ */


    /**
     * @dev Modifier that checks that the sender has the {DEFAULT_ADMIN_ROLE} role. 
     */
    modifier onlyAdmin() {
        require(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), "TokenMintCheckoutBase: Caller is missing role ADMIN.");
        _;
    }

    /**
     * @dev transfer the {DEFAULT_ADMIN_ROLE} role to another wallet.
     * 
     * note: because {grantRole} and {revokeRole} are not accessible externally, this function ensures that there
     * can only be a single admin for this contract at any time.
     */
    function transferAdmin(address _to) public onlyAdmin() {
        super.grantRole(DEFAULT_ADMIN_ROLE, _to);
        super.revokeRole(DEFAULT_ADMIN_ROLE, _msgSender());
    }

    /**
     * @dev returns the address of the admin of this registry.
     */
    function admin() public view returns (address) {
        return getRoleMember(DEFAULT_ADMIN_ROLE, 0);
    }

    /**
     * @dev same as {admin()}, to support Dapps that use {owner()} rather than {admin()} to check the ownership of 
     * a contract.
     */
    function owner() public view returns (address) {
        return admin();
    }


    /* ====================================== TRUSTED FORWARDER ROLE AND HELPERS ====================================== */

    /**
     * @dev the trusted forwarder role.
     * An "trused forwarder" has the ability to execute transactions on behalf of an account as if the account was executing
     * those transactions. This is helpful to allow a relayer to run transactions on behalf of an account.
     */
    function TRUSTED_FORWARDER_ROLE() internal pure returns(bytes32) {
        return keccak256("TRUSTED_FORWARDER_ROLE");
    } 

    /**
     * @dev grant the TRUSTED_FORWARDER_ROLE role.
     */
    function addTrustedForwarder(address account) public onlyAdmin() {
        super.grantRole(TRUSTED_FORWARDER_ROLE(), account);
    }

    /**
     * @dev revoke the TRUSTED_FORWARDER_ROLE role.
     */
    function removeTrustedForwarder(address account) public onlyAdmin() {
        super.revokeRole(TRUSTED_FORWARDER_ROLE(), account);
    }

    /**
     * @dev check if an address has the {TRUSTED_FORWARDER_ROLE} role.
     */
    function isTrustedForwarder(address account) public view returns (bool) {
        return hasRole(TRUSTED_FORWARDER_ROLE(), account);
    }

    /**
     * @dev list the addresses that have the {TRUSTED_FORWARDER_ROLE} role.
     */
    function listTrustedForwarders() public view returns (address[] memory) {
        return listRoleMembers(TRUSTED_FORWARDER_ROLE());
    }

    /**
     * @dev Override of {_msgSender()} that supports a trusted forwarder.
     * Heavily inspired from {openzeppelin/contracts/metatx/ERC2771Context.sol:ERC2771Context}.
     */
    function _msgSender() internal view virtual override returns (address sender) {
        if (isTrustedForwarder(msg.sender)) {
            // The assembly code is more direct than the Solidity version using `abi.decode`.
            assembly {
                sender := shr(96, calldataload(sub(calldatasize(), 20)))
            }
        } else {
            return super._msgSender();
        }
    }

    /**
     * @dev Override of {_msgData()} that supports a trusted forwarder.
     * Heavily inspired from {openzeppelin/contracts/metatx/ERC2771Context.sol:ERC2771Context}.
     */
    function _msgData() internal view virtual override returns (bytes calldata) {
        if (isTrustedForwarder(msg.sender)) {
            return msg.data[:msg.data.length - 20];
        } else {
            return super._msgData();
        }
    }


    /* ================================================ CHECKOUT ORACLE ROLE ================================================ */

    /**
     * @dev the trusted checkout oracle role. 
     */
    function TRUSTED_CHECKOUT_ORACLE_ROLE() internal pure returns(bytes32) {
        return keccak256("TRUSTED_CHECKOUT_ORACLE_ROLE");
    } 

    /**
     * @dev @dev Check that a specific address is a trusted checkout oracle.
     */
    modifier onlyTrustedCheckoutOracle(address account) {
        require(hasRole(TRUSTED_CHECKOUT_ORACLE_ROLE(), msg.sender), "TokenMintCheckoutBase: Caller is missing role TRUSTED_CHECKOUT_ORACLE_ROLE.");
        _ ;
    }

    /**
     * @dev grant the TRUSTED_CHECKOUT_ORACLE_ROLE role that allows an account to provide minting signatures for minting tokens.
     */
    function addTrustedCheckoutOracle(address account) public onlyAdmin {
        super.grantRole(TRUSTED_CHECKOUT_ORACLE_ROLE(), account);
    }

    /**
     * @dev revoke the TRUSTED_CHECKOUT_ORACLE_ROLE role.
     */
    function removeTrustedCheckoutOracle(address account) public onlyAdmin {
        super.revokeRole(TRUSTED_CHECKOUT_ORACLE_ROLE(), account);
    }

    /**
     * @dev check if an address has the {TRUSTED_CHECKOUT_ORACLE_ROLE} role.
     */
    function isTrustedCheckoutOracle(address account) public view returns (bool) {
        return hasRole(TRUSTED_CHECKOUT_ORACLE_ROLE(), account);
    }

    /**
     * @dev list the addresses that have the {TRUSTED_CHECKOUT_ORACLE_ROLE} role.
     */
    function listTrustedCheckoutOracles() public view returns (address[] memory) {
        return listRoleMembers(TRUSTED_CHECKOUT_ORACLE_ROLE());
    }


    /* ============================================= PAUSABLE HELPERS ============================================= */

    /**
     * @dev pause the contract
     * 
     * Requirements:
     * 
     *      - Only the admin of the contract can pause it. 
     */
    function pause() public onlyAdmin {
        _pause();
    }

    /**
     * @dev unpause the contract
     * 
     * Requirements:
     * 
     *      - Only the admin of the contract can unpause it. 
     */
    function unpause() public onlyAdmin {
        _unpause();
    }


    /* ========================================= CHECKOUT REQUEST HELPERS ========================================= */

    /**
     * @dev modifier to ensure that a checkout request signature is valid.
     * @param requestData the checkout request as bytes.
     * @param signature the signature block of {requestData}, signed by a trusted checkout oracle.
     */
    modifier onlyValidCheckoutSignature(
        bytes memory requestData,
        bytes memory signature
    ) {
        bytes32 expectedSignedMessage = ECDSA.toEthSignedMessageHash(requestData);
        address recoveredSigner = ECDSA.recover(expectedSignedMessage, signature);
        require(isTrustedCheckoutOracle(recoveredSigner), "TokenMintCheckoutBase: Invalid signature.");
        _;
    }

    /**
     * @dev helper to check the eligibility of a checkout request.
     * @param request the checkout request data as bytes.
     * 
     * Requirements:
     * 
     *      - {request.operatingContract} must be this contract.
     *      - {request.checkoutId} must not have been marked as processed.
     *      - {request.expirationTimestamp} must not have passed. 
     */
    function _checkEligibility(CheckoutRequest memory request) private view {
        require(request.operatingContract == address(this), "TokenMintCheckoutBase: Contract is not authorized to process this request.");
        require(!exists(request.checkoutId), "TokenMintCheckoutBase: Checkout with checkoutId was already processed.");
        require(request.expirationTimestamp >= block.timestamp, "TokenMintCheckoutBase: Checkout time window has expired.");
    }


    /* ============================================ CHECKOUT ID HELPERS ============================================ */

    /**
     * @dev helper to compute the hash of a {checkoutId}.
     * @param checkoutId the checkout id.
     * @return a keccak256 hash of the checkout id.
     */
    function _checkoutIdHash(string memory checkoutId) private pure returns (bytes32) {
        return keccak256(abi.encode(checkoutId));
    }

    /**
     * @dev helper to check if a checkoutId exists, i.e. if the checkout for that id was completed.
     * @param checkoutId the checkout id.
     * @return true if {checkoutId} has been processed, false otherwise.
     */
    function exists(string memory checkoutId) public view returns (bool) {
        return processed[_checkoutIdHash(checkoutId)];
    }


    /* ============================================== ERC20 CHECKOUT ============================================== */

    /**
     * @dev creates and encode a {CheckoutRequest}.
     * The {CheckoutRequest} is returned in an encoded form (bytes) and must be signed by the {checkoutOracle} to
     * authorize a checkout. That signature is then fed to {erc20Checkout} along with the encoded {CheckoutRequest} 
     * to be validated before proceeding with the checkout.
     * @param checkoutId the checkout id.
     * @param expirationTimestamp the expiration timestamp after which this checkout request is no longer valid.
     * @param paymentRecipient the recipient of the payment.
     * @param paymentToken the payment token.
     * @param paymentValue the payment value in the smallest unit of the associated currency
     * @param expirationTimestamp the expiration timestamp after which this checkout request is no longer valid.
     * @param tokenRecipient the recipient of the tokens to be minted.
     * @param tokenHashes the bytes32 ids (hex proofs) of the tokens to mint to the recipient.
     * @return the encoded checkout request as bytes, ready to be signed by the checkout oracle.
     *
     * Notes:
     * 
     *      - The returned encoded {CheckoutRequest} needs to be signed by a trusted checkout oracle to be valid.
     *      - If {data} is the result of this function, checkoutOracleAddress.signMessage(ethers.utils.arrayify(data))
     *        must be called in order to properly encode the hash before signing it.
     */
    function encodeCheckoutRequest(
        string calldata checkoutId,
        uint256 expirationTimestamp,
        address paymentRecipient,
        address paymentToken,
        uint256 paymentValue,
        address tokenRecipient,
        address tokenRegistry,
        bytes32[] memory tokenHashes
    ) public view returns (bytes memory) {
        return abi.encode(
            CheckoutRequest(
                address(this),
                checkoutId,
                expirationTimestamp,
                paymentRecipient,
                paymentToken,
                paymentValue,
                tokenRecipient,
                tokenRegistry,
                tokenHashes
            )
        );  
    }


    /**
     * @dev Mint tokens according to a checkout request and signature.
     * 
     * Requirements:
     *  - the contract is not paused
     *  - the checkout request and signature must be valid
     */
    function mintTokens(
        bytes calldata checkoutRequestData,
        bytes calldata checkoutSignature
    ) external nonReentrant whenNotPaused onlyValidCheckoutSignature(checkoutRequestData, checkoutSignature) {
        address caller = _msgSender();
        CheckoutRequest memory request = abi.decode(checkoutRequestData, (CheckoutRequest));
        _checkEligibility(request);
        _processPayment(caller, request.paymentRecipient, request.paymentToken, request.paymentValue);
        for (uint ii = 0 ; ii < request.tokenHashes.length ; ii++ ) {
            uint256 mintedTokenId = TokenRegistryInterface(request.tokenRegistry).mintToken(request.tokenRecipient, request.tokenHashes[ii]);
            uint256 unitPrice = request.paymentValue / request.tokenHashes.length; // this is safe because tokenHashes is empty, we would not be in this loop.
            emit TokenPurchasedAndMinted(request.tokenRecipient, request.tokenRegistry, mintedTokenId, request.paymentToken, unitPrice);
        }
        processed[_checkoutIdHash(request.checkoutId)] = true;
        emit CheckoutSuccess(caller, request.checkoutId);
    }


    /**
     * @dev Permit a transaction and mint tokens according to a checkout request and signature.
     * 
     * Requirements:
     *  - the contract is not paused
     *  - the checkout request and signature must be valid
     *  - A permit signature is required to approve the funds spending during the transaction
     *  - The originating caller of this function (returned by _msgSender()) has to be the signer of the permit signature.
     *  - The signature has to correspond to the price provided in the checkout request.
     *  - {permitExpiration} must correspond to the expiration time encoded in the permit signature
     */
    function permitFundsAndMintTokens(
        bytes calldata checkoutRequestData, // the checkout request data
        bytes calldata checkoutSignature,   // the checkout signature
        uint256 permitExpiration,           // the expiration of the permit signature
        uint8 v, bytes32 r, bytes32 s       // the parameters of the permit signature
    ) external nonReentrant whenNotPaused onlyValidCheckoutSignature(checkoutRequestData, checkoutSignature) {
        address caller = _msgSender();
        CheckoutRequest memory request = abi.decode(checkoutRequestData, (CheckoutRequest));
        _checkEligibility(request);
        _permitAndProcessPayment(
            caller,                     // the executor of the call
            request.paymentRecipient,   // the recipient of the payment
            request.paymentToken,       // the payment token
            request.paymentValue,       // the final purchase value
            request.paymentValue,       // the amount that is supposed to be approved for this transaction (and encoded in the permit signature)
            permitExpiration,           // the expiration of the permit signature
            v, r, s                     // the parameters of the permit signature
        );
        for (uint ii = 0 ; ii < request.tokenHashes.length ; ii++ ) {
            uint256 mintedTokenId = TokenRegistryInterface(request.tokenRegistry).mintToken(request.tokenRecipient, request.tokenHashes[ii]);
            uint256 unitPrice = request.paymentValue / request.tokenHashes.length; // this is safe because tokenHashes is empty, we would not be in this loop.
            emit TokenPurchasedAndMinted(request.tokenRecipient, request.tokenRegistry, mintedTokenId, request.paymentToken, unitPrice);
        }
        processed[_checkoutIdHash(request.checkoutId)] = true;
        emit CheckoutSuccess(caller, request.checkoutId);
    }


}

// SPDX-FileCopyrightText: © Courtyard Inc. (https://courtyard.io)
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

/**
 * The IERC20Permit interface, used to permit funds to be transferred with a signature.
 */
interface IERC20Permit {
    function permit(address owner, address spender, uint256 value, uint256 expiration, uint8 v, bytes32 r, bytes32 s) external;
}

/**
 * @title processes payments in ERC20 and redirects them to a receiver address.
 * In comparison to the original version V2 supports defining the payment token and reviver address at the transaction time.
 */ 
abstract contract ERC20PaymentProcessorV2 {

    using SafeERC20 for IERC20;

    event PaymentProcessed(address indexed to, address indexed token, uint256 amount);

    constructor() {}

    /* ============================================ PAYMENT PROCESSING ============================================ */

    /**
     * @dev process the payment, assuming that {erc20Token} already knows that this contract is allowed to spend the funds on behalf of {from}.
     */
    function _processPayment(address fromAddress, address toAddress, address erc20Token, uint256 amount) internal {
        IERC20(erc20Token).safeTransferFrom(fromAddress, toAddress, amount);
        emit PaymentProcessed(toAddress, erc20Token, amount);
    }

    /**
     * @dev permit and process the payment of {erc20Token} by this contract on behalf of {fromAddress}.
     * Note that the
     *  - if requestAmount = permitAmount: the transaction would succeed
     *  - if requestAmount > permitAmount: the transaction would fail
     *  - if requestAmount < permitAmount: the transaction would succeed and the extra funds would be refunded to the payer. Note that this is 
     *    a deliberate choice to ensure that at the end of the transaction, there is no fund spending approval lingering around (since it is 
     *    not possible to self-cancel an approval on someone else behalf). The caveat is that if the authorizer permitted the spending of 
     *    funds they do not have in the first place, the transaction would fail, even if the requested amount is lower and the authorized does have that much funds.
     */
    function _permitAndProcessPayment(address fromAddress, address toAddress, address erc20Token, uint256 requestAmount, uint256 permitAmount, uint256 expiration, uint8 v, bytes32 r, bytes32 s) internal {
        // fail early if the requested amount is higher than the permitted amount.
        require(permitAmount >= requestAmount, "ERC20PaymentProcessor: request amount exceeds permit amount.");
        IERC20Permit(erc20Token).permit(fromAddress, address(this), permitAmount, expiration, v, r, s);
        // pull the funds.
        IERC20(erc20Token).safeTransferFrom(fromAddress, address(this), permitAmount);
        // pay the receiver.
        IERC20(erc20Token).safeTransfer(toAddress, requestAmount);
        // send the change back to the payer and cancel the approval in the process.
        IERC20(erc20Token).safeTransfer(fromAddress, permitAmount - requestAmount);
        emit PaymentProcessed(toAddress, erc20Token, requestAmount);
    }

}

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

Contract Security Audit

Contract ABI

API
[{"inputs":[{"internalType":"string","name":"name","type":"string"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":false,"internalType":"string","name":"checkoutId","type":"string"}],"name":"CheckoutSuccess","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"PaymentProcessed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"mintedToAddress","type":"address"},{"indexed":false,"internalType":"address","name":"mintedTokenAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"mintedTokenId","type":"uint256"},{"indexed":false,"internalType":"address","name":"paymentTokenAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"paymentAmount","type":"uint256"}],"name":"TokenPurchasedAndMinted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"addTrustedCheckoutOracle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"addTrustedForwarder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"admin","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"checkoutId","type":"string"},{"internalType":"uint256","name":"expirationTimestamp","type":"uint256"},{"internalType":"address","name":"paymentRecipient","type":"address"},{"internalType":"address","name":"paymentToken","type":"address"},{"internalType":"uint256","name":"paymentValue","type":"uint256"},{"internalType":"address","name":"tokenRecipient","type":"address"},{"internalType":"address","name":"tokenRegistry","type":"address"},{"internalType":"bytes32[]","name":"tokenHashes","type":"bytes32[]"}],"name":"encodeCheckoutRequest","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"checkoutId","type":"string"}],"name":"exists","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getRoleMember","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleMemberCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"},{"internalType":"address","name":"","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"isTrustedCheckoutOracle","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"isTrustedForwarder","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"listRoleMembers","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"listTrustedCheckoutOracles","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"listTrustedForwarders","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"checkoutRequestData","type":"bytes"},{"internalType":"bytes","name":"checkoutSignature","type":"bytes"}],"name":"mintTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"checkoutRequestData","type":"bytes"},{"internalType":"bytes","name":"checkoutSignature","type":"bytes"},{"internalType":"uint256","name":"permitExpiration","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"permitFundsAndMintTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"removeTrustedCheckoutOracle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"removeTrustedForwarder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"},{"internalType":"address","name":"","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"}],"name":"transferAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"}]

60806040523480156200001157600080fd5b50604051620032b0380380620032b08339810160408190526200003491620003b0565b600160009081556003805460ff1916905581906200006790620000566200008f565b620000c960201b6200115a1760201c565b80516200007c9060049060208401906200030a565b50620000876200010c565b5050620004df565b60006200009c33620001ac565b15620000af575060131936013560601c90565b620000c4620001ee60201b620011811760201c565b905090565b620000e08282620001f260201b620011851760201c565b6000828152600260209081526040909120620001079183906200120d6200029a821b17901c565b505050565b60035460ff1615620001575760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015260640160405180910390fd5b6003805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586200018f6200008f565b6040516001600160a01b03909116815260200160405180910390a1565b6001600160a01b03811660009081527fe280a3ef0659af2cb19173beaf50277ddc433bfcb56995bd246756e655639254602052604081205460ff165b92915050565b3390565b60008281526001602090815260408083206001600160a01b038516845290915290205460ff16620002965760008281526001602081815260408084206001600160a01b0386168552909152909120805460ff19169091179055620002556200008f565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45b5050565b6000620002b1836001600160a01b038416620002b8565b9392505050565b60008181526001830160205260408120546200030157508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155620001e8565b506000620001e8565b82805462000318906200048c565b90600052602060002090601f0160209004810192826200033c576000855562000387565b82601f106200035757805160ff191683800117855562000387565b8280016001018555821562000387579182015b82811115620003875782518255916020019190600101906200036a565b506200039592915062000399565b5090565b5b808211156200039557600081556001016200039a565b60006020808385031215620003c457600080fd5b82516001600160401b0380821115620003dc57600080fd5b818501915085601f830112620003f157600080fd5b815181811115620004065762000406620004c9565b604051601f8201601f19908116603f01168101908382118183101715620004315762000431620004c9565b8160405282815288868487010111156200044a57600080fd5b600093505b828410156200046e57848401860151818501870152928501926200044f565b82841115620004805760008684830101525b98975050505050505050565b600181811c90821680620004a157607f821691505b60208210811415620004c357634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052604160045260246000fd5b612dc180620004ef6000396000f3fe608060405234801561001057600080fd5b50600436106101cf5760003560e01c8063572b6c051161010457806391d14854116100a2578063ca15c87311610071578063ca15c873146103c2578063cd39bed7146103d5578063d547741f146103e8578063f851a440146103fb57600080fd5b806391d148541461038c578063a18b65e21461039f578063a217fddf146103b2578063a5fd737c146103ba57600080fd5b806375829def116100de57806375829def1461033e5780638456cb59146103515780638da5cb5b146103595780639010d07c1461037957600080fd5b8063572b6c051461030d5780635c975abb146103205780636776fbb11461032b57600080fd5b8063261a323e11610171578063324880a41161014b578063324880a4146102cc57806336568abe146102df5780633751d89c146102f25780633f4ba83a1461030557600080fd5b8063261a323e1461029357806326d00668146102a65780632f2ff15d146102b957600080fd5b80631678922a116101ad5780631678922a146102265780631a1269351461023957806320b429fe1461024e578063248a9ca31461026157600080fd5b806301ffc9a7146101d457806306fdde03146101fc5780630732c5fe14610211575b600080fd5b6101e76101e23660046124c8565b610403565b60405190151581526020015b60405180910390f35b61020461042e565b6040516101f391906129ac565b61022461021f36600461255d565b6104bc565b005b610224610234366004612424565b610822565b610241610867565b6040516101f3919061295f565b61022461025c366004612424565b610885565b61028561026f366004612461565b6000908152600160208190526040909120015490565b6040519081526020016101f3565b6101e76102a13660046126c1565b6108c7565b6102246102b4366004612424565b6108f0565b6102246102c736600461247a565b610930565b6101e76102da366004612424565b6109c4565b6102246102ed36600461247a565b6109df565b610224610300366004612424565b610a6d565b610224610aad565b6101e761031b366004612424565b610ae0565b60035460ff166101e7565b610204610339366004612600565b610af9565b61022461034c366004612424565b610bbd565b610224610c03565b610361610c34565b6040516001600160a01b0390911681526020016101f3565b6103616103873660046124a6565b610c3e565b6101e761039a36600461247a565b610c5d565b6102416103ad366004612461565b610c88565b610285600081565b610241610d36565b6102856103d0366004612461565b610d4f565b6102246103e33660046124f2565b610d66565b6102246103f636600461247a565b6110ba565b61036161114e565b60006001600160e01b03198216635a05180f60e01b1480610428575061042882611222565b92915050565b6004805461043b90612c5d565b80601f016020809104026020016040519081016040528092919081815260200182805461046790612c5d565b80156104b45780601f10610489576101008083540402835291602001916104b4565b820191906000526020600020905b81548152906001019060200180831161049757829003601f168201915b505050505081565b600260005414156105145760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064015b60405180910390fd5b600260005560035460ff161561053c5760405162461bcd60e51b815260040161050b90612a13565b87878080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050604080516020601f8b018190048102820181019092528981529250899150889081908401838280828437600092018290525092506105b19150849050611257565b905060006105bf8284611292565b90506105ca816109c4565b6105e65760405162461bcd60e51b815260040161050b90612a3d565b60006105f06112ae565b905060006106008d8f018f6126f5565b905061060b816112d0565b61062c82826060015183608001518460a001518560a001518f8f8f8f61146b565b60005b8161010001515181101561078f5760008260e001516001600160a01b03166363f8ec418460c00151856101000151858151811061066e5761066e612d1f565b60200260200101516040518363ffffffff1660e01b81526004016106a79291906001600160a01b03929092168252602082015260400190565b602060405180830381600087803b1580156106c157600080fd5b505af11580156106d5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106f991906127f3565b90506000836101000151518460a001516107139190612bd0565b60c085015160e0860151608080880151604080516001600160a01b0394851681526020810189905291841690820152606081018590529394509116917f3ac06088fd2f047b705cf81c76a5be8b7d378860415de575a9974868ca188980910160405180910390a25050808061078790612c98565b91505061062f565b506001600560006107a38460200151611608565b815260200190815260200160002060006101000a81548160ff021916908315150217905550816001600160a01b03167ffe05d3bcf926920facb1e668218f8c9939003d7bd7cde768cc3c4e9cfa854b2d826020015160405161080591906129ac565b60405180910390a250506001600055505050505050505050505050565b61082f600061039a6112ae565b61084b5760405162461bcd60e51b815260040161050b906129bf565b610864600080516020612d6c8339815191525b8261161b565b50565b6060610880600080516020612d4c833981519152610c88565b905090565b610892600061039a6112ae565b6108ae5760405162461bcd60e51b815260040161050b906129bf565b610864600080516020612d6c8339815191525b82611649565b6000600560006108d684611608565b815260208101919091526040016000205460ff1692915050565b6108fd600061039a6112ae565b6109195760405162461bcd60e51b815260040161050b906129bf565b610864600080516020612d4c8339815191526108c1565b60405162461bcd60e51b815260206004820152605e60248201527f546f6b656e4d696e74436865636b6f7574426173653a204120726f6c6520636160448201527f6e206f6e6c79206265206772616e746564207573696e672074686520636f727260648201527f6573706f6e64696e67207370656369616c697a65642066756e6374696f6e0000608482015260a40161050b565b6000610428600080516020612d6c8339815191525b83610c5d565b6109e76112ae565b6001600160a01b0316816001600160a01b031614610a5f5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b606482015260840161050b565b610a698282611672565b5050565b610a7a600061039a6112ae565b610a965760405162461bcd60e51b815260040161050b906129bf565b610864600080516020612d4c83398151915261085e565b610aba600061039a6112ae565b610ad65760405162461bcd60e51b815260040161050b906129bf565b610ade611694565b565b6000610428600080516020612d4c8339815191526109d9565b6060604051806101200160405280306001600160a01b031681526020018b8b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050509082525060208082018b90526001600160a01b03808b166040808501919091528a82166060850152608084018a905288821660a085015290871660c084015260e09092018590529051610b9f929101612a86565b60405160208183030381529060405290509998505050505050505050565b610bca600061039a6112ae565b610be65760405162461bcd60e51b815260040161050b906129bf565b610bf1600082611649565b6108646000610bfe6112ae565b61161b565b610c10600061039a6112ae565b610c2c5760405162461bcd60e51b815260040161050b906129bf565b610ade61172d565b600061088061114e565b6000828152600260205260408120610c569083611786565b9392505050565b60009182526001602090815260408084206001600160a01b0393909316845291905290205460ff1690565b60606000610c9583610d4f565b90506000816001600160401b03811115610cb157610cb1612d35565b604051908082528060200260200182016040528015610cda578160200160208202803683370190505b50905060005b82811015610d2e57610cf28582610c3e565b828281518110610d0457610d04612d1f565b6001600160a01b039092166020928302919091019091015280610d2681612c98565b915050610ce0565b509392505050565b6060610880600080516020612d6c833981519152610c88565b600081815260026020526040812061042890611792565b60026000541415610db95760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640161050b565b600260005560035460ff1615610de15760405162461bcd60e51b815260040161050b90612a13565b83838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050604080516020601f8701819004810282018101909252858152925085915084908190840183828082843760009201829052509250610e569150849050611257565b90506000610e648284611292565b9050610e6f816109c4565b610e8b5760405162461bcd60e51b815260040161050b90612a3d565b6000610e956112ae565b90506000610ea5898b018b6126f5565b9050610eb0816112d0565b610ec882826060015183608001518460a0015161179c565b60005b8161010001515181101561102b5760008260e001516001600160a01b03166363f8ec418460c001518561010001518581518110610f0a57610f0a612d1f565b60200260200101516040518363ffffffff1660e01b8152600401610f439291906001600160a01b03929092168252602082015260400190565b602060405180830381600087803b158015610f5d57600080fd5b505af1158015610f71573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f9591906127f3565b90506000836101000151518460a00151610faf9190612bd0565b60c085015160e0860151608080880151604080516001600160a01b0394851681526020810189905291841690820152606081018590529394509116917f3ac06088fd2f047b705cf81c76a5be8b7d378860415de575a9974868ca188980910160405180910390a25050808061102390612c98565b915050610ecb565b5060016005600061103f8460200151611608565b815260200190815260200160002060006101000a81548160ff021916908315150217905550816001600160a01b03167ffe05d3bcf926920facb1e668218f8c9939003d7bd7cde768cc3c4e9cfa854b2d82602001516040516110a191906129ac565b60405180910390a2505060016000555050505050505050565b60405162461bcd60e51b815260206004820152605e60248201527f546f6b656e4d696e74436865636b6f7574426173653a204120726f6c6520636160448201527f6e206f6e6c79206265207265766f6b6564207573696e672074686520636f727260648201527f6573706f6e64696e67207370656369616c697a65642066756e6374696f6e0000608482015260a40161050b565b60006108808180610c3e565b6111648282611185565b600082815260026020526040902061117c908261120d565b505050565b3390565b61118f8282610c5d565b610a695760008281526001602081815260408084206001600160a01b0386168552909152909120805460ff191690911790556111c96112ae565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000610c56836001600160a01b038416611804565b60006001600160e01b03198216637965db0b60e01b148061042857506301ffc9a760e01b6001600160e01b0319831614610428565b60006112638251611853565b8260405160200161127592919061288f565b604051602081830303815290604052805190602001209050919050565b60008060006112a18585611958565b91509150610d2e816119c8565b60006112b933610ae0565b156112cb575060131936013560601c90565b503390565b80516001600160a01b031630146113625760405162461bcd60e51b815260206004820152604a60248201527f546f6b656e4d696e74436865636b6f7574426173653a20436f6e74726163742060448201527f6973206e6f7420617574686f72697a656420746f2070726f636573732074686960648201526939903932b8bab2b9ba1760b11b608482015260a40161050b565b61136f81602001516108c7565b156113f15760405162461bcd60e51b815260206004820152604660248201527f546f6b656e4d696e74436865636b6f7574426173653a20436865636b6f75742060448201527f7769746820636865636b6f757449642077617320616c72656164792070726f6360648201526532b9b9b2b21760d11b608482015260a40161050b565b42816040015110156108645760405162461bcd60e51b815260206004820152603860248201527f546f6b656e4d696e74436865636b6f7574426173653a20436865636b6f75742060448201527f74696d652077696e646f772068617320657870697265642e0000000000000000606482015260840161050b565b858510156114e15760405162461bcd60e51b815260206004820152603c60248201527f45524332305061796d656e7450726f636573736f723a2072657175657374206160448201527f6d6f756e742065786365656473207065726d697420616d6f756e742e00000000606482015260840161050b565b60405163d505accf60e01b81526001600160a01b038a81166004830152306024830152604482018790526064820186905260ff8516608483015260a4820184905260c4820183905288169063d505accf9060e401600060405180830381600087803b15801561154f57600080fd5b505af1158015611563573d6000803e3d6000fd5b5061157d925050506001600160a01b0388168a3088611b83565b6115916001600160a01b0388168988611bf4565b6115b08961159f8888612c03565b6001600160a01b038a169190611bf4565b866001600160a01b0316886001600160a01b03167f0538ab32a957d2b55d0ec70a4029e73fdf19f500832839b1d7bafcfbca2a5630886040516115f591815260200190565b60405180910390a3505050505050505050565b60008160405160200161127591906129ac565b6000828152600160208190526040909120015461163f8161163a6112ae565b611c24565b61117c8383611672565b600082815260016020819052604090912001546116688161163a6112ae565b61117c838361115a565b61167c8282611c88565b600082815260026020526040902061117c9082611d0d565b60035460ff166116dd5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015260640161050b565b6003805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6117106112ae565b6040516001600160a01b03909116815260200160405180910390a1565b60035460ff16156117505760405162461bcd60e51b815260040161050b90612a13565b6003805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586117106112ae565b6000610c568383611d22565b6000610428825490565b6117b16001600160a01b038316858584611b83565b816001600160a01b0316836001600160a01b03167f0538ab32a957d2b55d0ec70a4029e73fdf19f500832839b1d7bafcfbca2a5630836040516117f691815260200190565b60405180910390a350505050565b600081815260018301602052604081205461184b57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610428565b506000610428565b6060816118775750506040805180820190915260018152600360fc1b602082015290565b8160005b81156118a1578061188b81612c98565b915061189a9050600a83612bd0565b915061187b565b6000816001600160401b038111156118bb576118bb612d35565b6040519080825280601f01601f1916602001820160405280156118e5576020820181803683370190505b5090505b8415611950576118fa600183612c03565b9150611907600a86612cb3565b611912906030612bb8565b60f81b81838151811061192757611927612d1f565b60200101906001600160f81b031916908160001a905350611949600a86612bd0565b94506118e9565b949350505050565b60008082516041141561198f5760208301516040840151606085015160001a61198387828585611d4c565b945094505050506119c1565b8251604014156119b957602083015160408401516119ae868383611e39565b9350935050506119c1565b506000905060025b9250929050565b60008160048111156119dc576119dc612cf3565b14156119e55750565b60018160048111156119f9576119f9612cf3565b1415611a475760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e61747572650000000000000000604482015260640161050b565b6002816004811115611a5b57611a5b612cf3565b1415611aa95760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e67746800604482015260640161050b565b6003816004811115611abd57611abd612cf3565b1415611b165760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b606482015260840161050b565b6004816004811115611b2a57611b2a612cf3565b14156108645760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b606482015260840161050b565b6040516001600160a01b0380851660248301528316604482015260648101829052611bee9085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152611e68565b50505050565b6040516001600160a01b03831660248201526044810182905261117c90849063a9059cbb60e01b90606401611bb7565b611c2e8282610c5d565b610a6957611c46816001600160a01b03166014611f3a565b611c51836020611f3a565b604051602001611c629291906128ea565b60408051601f198184030181529082905262461bcd60e51b825261050b916004016129ac565b611c928282610c5d565b15610a695760008281526001602090815260408083206001600160a01b03851684529091529020805460ff19169055611cc96112ae565b6001600160a01b0316816001600160a01b0316837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45050565b6000610c56836001600160a01b0384166120d5565b6000826000018281548110611d3957611d39612d1f565b9060005260206000200154905092915050565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831115611d835750600090506003611e30565b8460ff16601b14158015611d9b57508460ff16601c14155b15611dac5750600090506004611e30565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015611e00573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116611e2957600060019250925050611e30565b9150600090505b94509492505050565b6000806001600160ff1b03831660ff84901c601b01611e5a87828885611d4c565b935093505050935093915050565b6000611ebd826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166121c89092919063ffffffff16565b80519091501561117c5780806020019051810190611edb919061243f565b61117c5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161050b565b60606000611f49836002612be4565b611f54906002612bb8565b6001600160401b03811115611f6b57611f6b612d35565b6040519080825280601f01601f191660200182016040528015611f95576020820181803683370190505b509050600360fc1b81600081518110611fb057611fb0612d1f565b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110611fdf57611fdf612d1f565b60200101906001600160f81b031916908160001a9053506000612003846002612be4565b61200e906001612bb8565b90505b6001811115612086576f181899199a1a9b1b9c1cb0b131b232b360811b85600f166010811061204257612042612d1f565b1a60f81b82828151811061205857612058612d1f565b60200101906001600160f81b031916908160001a90535060049490941c9361207f81612c46565b9050612011565b508315610c565760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e74604482015260640161050b565b600081815260018301602052604081205480156121be5760006120f9600183612c03565b855490915060009061210d90600190612c03565b905081811461217257600086600001828154811061212d5761212d612d1f565b906000526020600020015490508087600001848154811061215057612150612d1f565b6000918252602080832090910192909255918252600188019052604090208390555b855486908061218357612183612d09565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610428565b6000915050610428565b6060611950848460008585843b6122215760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161050b565b600080866001600160a01b0316858760405161223d9190612873565b60006040518083038185875af1925050503d806000811461227a576040519150601f19603f3d011682016040523d82523d6000602084013e61227f565b606091505b509150915061228f82828661229a565b979650505050505050565b606083156122a9575081610c56565b8251156122b95782518084602001fd5b8160405162461bcd60e51b815260040161050b91906129ac565b80356001600160a01b03811681146122ea57600080fd5b919050565b600082601f83011261230057600080fd5b813560206001600160401b0382111561231b5761231b612d35565b8160051b61232a828201612b88565b83815282810190868401838801850189101561234557600080fd5b600093505b8584101561236857803583526001939093019291840191840161234a565b50979650505050505050565b60008083601f84011261238657600080fd5b5081356001600160401b0381111561239d57600080fd5b6020830191508360208285010111156119c157600080fd5b600082601f8301126123c657600080fd5b81356001600160401b038111156123df576123df612d35565b6123f2601f8201601f1916602001612b88565b81815284602083860101111561240757600080fd5b816020850160208301376000918101602001919091529392505050565b60006020828403121561243657600080fd5b610c56826122d3565b60006020828403121561245157600080fd5b81518015158114610c5657600080fd5b60006020828403121561247357600080fd5b5035919050565b6000806040838503121561248d57600080fd5b8235915061249d602084016122d3565b90509250929050565b600080604083850312156124b957600080fd5b50508035926020909101359150565b6000602082840312156124da57600080fd5b81356001600160e01b031981168114610c5657600080fd5b6000806000806040858703121561250857600080fd5b84356001600160401b038082111561251f57600080fd5b61252b88838901612374565b9096509450602087013591508082111561254457600080fd5b5061255187828801612374565b95989497509550505050565b60008060008060008060008060c0898b03121561257957600080fd5b88356001600160401b038082111561259057600080fd5b61259c8c838d01612374565b909a50985060208b01359150808211156125b557600080fd5b506125c28b828c01612374565b90975095505060408901359350606089013560ff811681146125e357600080fd5b979a969950949793969295929450505060808201359160a0013590565b60008060008060008060008060006101008a8c03121561261f57600080fd5b89356001600160401b038082111561263657600080fd5b6126428d838e01612374565b909b50995060208c0135985089915061265d60408d016122d3565b975061266b60608d016122d3565b965060808c0135955061268060a08d016122d3565b945061268e60c08d016122d3565b935060e08c01359150808211156126a457600080fd5b506126b18c828d016122ef565b9150509295985092959850929598565b6000602082840312156126d357600080fd5b81356001600160401b038111156126e957600080fd5b611950848285016123b5565b60006020828403121561270757600080fd5b81356001600160401b038082111561271e57600080fd5b90830190610120828603121561273357600080fd5b61273b612b5f565b612744836122d3565b815260208301358281111561275857600080fd5b612764878286016123b5565b60208301525060408301356040820152612780606084016122d3565b6060820152612791608084016122d3565b608082015260a083013560a08201526127ac60c084016122d3565b60c08201526127bd60e084016122d3565b60e082015261010080840135838111156127d657600080fd5b6127e2888287016122ef565b918301919091525095945050505050565b60006020828403121561280557600080fd5b5051919050565b600081518084526020808501945080840160005b8381101561283c57815187529582019590820190600101612820565b509495945050505050565b6000815180845261285f816020860160208601612c1a565b601f01601f19169290920160200192915050565b60008251612885818460208701612c1a565b9190910192915050565b7f19457468657265756d205369676e6564204d6573736167653a0a0000000000008152600083516128c781601a850160208801612c1a565b8351908301906128de81601a840160208801612c1a565b01601a01949350505050565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351612922816017850160208801612c1a565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351612953816028840160208801612c1a565b01602801949350505050565b6020808252825182820181905260009190848201906040850190845b818110156129a05783516001600160a01b03168352928401929184019160010161297b565b50909695505050505050565b602081526000610c566020830184612847565b60208082526034908201527f546f6b656e4d696e74436865636b6f7574426173653a2043616c6c65722069736040820152731036b4b9b9b4b733903937b6329020a226a4a71760611b606082015260800190565b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b60208082526029908201527f546f6b656e4d696e74436865636b6f7574426173653a20496e76616c6964207360408201526834b3b730ba3ab9329760b91b606082015260800190565b60208152612aa06020820183516001600160a01b03169052565b60006020830151610120806040850152612abe610140850183612847565b9150604085015160608501526060850151612ae460808601826001600160a01b03169052565b5060808501516001600160a01b03811660a08601525060a085015160c085015260c0850151612b1e60e08601826001600160a01b03169052565b5060e0850151610100612b3b818701836001600160a01b03169052565b860151858403601f1901838701529050612b55838261280c565b9695505050505050565b60405161012081016001600160401b0381118282101715612b8257612b82612d35565b60405290565b604051601f8201601f191681016001600160401b0381118282101715612bb057612bb0612d35565b604052919050565b60008219821115612bcb57612bcb612cc7565b500190565b600082612bdf57612bdf612cdd565b500490565b6000816000190483118215151615612bfe57612bfe612cc7565b500290565b600082821015612c1557612c15612cc7565b500390565b60005b83811015612c35578181015183820152602001612c1d565b83811115611bee5750506000910152565b600081612c5557612c55612cc7565b506000190190565b600181811c90821680612c7157607f821691505b60208210811415612c9257634e487b7160e01b600052602260045260246000fd5b50919050565b6000600019821415612cac57612cac612cc7565b5060010190565b600082612cc257612cc2612cdd565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052603160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fdfed3df22cd6a774f62b0ae21ffd602cc92e7f3390518eee8b33307fc70380da7d278b39ea7a001f73117bee7ffea7e1ca41ebcd8e6eb1250df020d1673fa827840a26469706673582212206371caccfa150171824abb3dae698d56293adbb0eae67c6b7eb188d84d87fa9a64736f6c634300080700330000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001243592056656e64696e67204d616368696e650000000000000000000000000000

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106101cf5760003560e01c8063572b6c051161010457806391d14854116100a2578063ca15c87311610071578063ca15c873146103c2578063cd39bed7146103d5578063d547741f146103e8578063f851a440146103fb57600080fd5b806391d148541461038c578063a18b65e21461039f578063a217fddf146103b2578063a5fd737c146103ba57600080fd5b806375829def116100de57806375829def1461033e5780638456cb59146103515780638da5cb5b146103595780639010d07c1461037957600080fd5b8063572b6c051461030d5780635c975abb146103205780636776fbb11461032b57600080fd5b8063261a323e11610171578063324880a41161014b578063324880a4146102cc57806336568abe146102df5780633751d89c146102f25780633f4ba83a1461030557600080fd5b8063261a323e1461029357806326d00668146102a65780632f2ff15d146102b957600080fd5b80631678922a116101ad5780631678922a146102265780631a1269351461023957806320b429fe1461024e578063248a9ca31461026157600080fd5b806301ffc9a7146101d457806306fdde03146101fc5780630732c5fe14610211575b600080fd5b6101e76101e23660046124c8565b610403565b60405190151581526020015b60405180910390f35b61020461042e565b6040516101f391906129ac565b61022461021f36600461255d565b6104bc565b005b610224610234366004612424565b610822565b610241610867565b6040516101f3919061295f565b61022461025c366004612424565b610885565b61028561026f366004612461565b6000908152600160208190526040909120015490565b6040519081526020016101f3565b6101e76102a13660046126c1565b6108c7565b6102246102b4366004612424565b6108f0565b6102246102c736600461247a565b610930565b6101e76102da366004612424565b6109c4565b6102246102ed36600461247a565b6109df565b610224610300366004612424565b610a6d565b610224610aad565b6101e761031b366004612424565b610ae0565b60035460ff166101e7565b610204610339366004612600565b610af9565b61022461034c366004612424565b610bbd565b610224610c03565b610361610c34565b6040516001600160a01b0390911681526020016101f3565b6103616103873660046124a6565b610c3e565b6101e761039a36600461247a565b610c5d565b6102416103ad366004612461565b610c88565b610285600081565b610241610d36565b6102856103d0366004612461565b610d4f565b6102246103e33660046124f2565b610d66565b6102246103f636600461247a565b6110ba565b61036161114e565b60006001600160e01b03198216635a05180f60e01b1480610428575061042882611222565b92915050565b6004805461043b90612c5d565b80601f016020809104026020016040519081016040528092919081815260200182805461046790612c5d565b80156104b45780601f10610489576101008083540402835291602001916104b4565b820191906000526020600020905b81548152906001019060200180831161049757829003601f168201915b505050505081565b600260005414156105145760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064015b60405180910390fd5b600260005560035460ff161561053c5760405162461bcd60e51b815260040161050b90612a13565b87878080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050604080516020601f8b018190048102820181019092528981529250899150889081908401838280828437600092018290525092506105b19150849050611257565b905060006105bf8284611292565b90506105ca816109c4565b6105e65760405162461bcd60e51b815260040161050b90612a3d565b60006105f06112ae565b905060006106008d8f018f6126f5565b905061060b816112d0565b61062c82826060015183608001518460a001518560a001518f8f8f8f61146b565b60005b8161010001515181101561078f5760008260e001516001600160a01b03166363f8ec418460c00151856101000151858151811061066e5761066e612d1f565b60200260200101516040518363ffffffff1660e01b81526004016106a79291906001600160a01b03929092168252602082015260400190565b602060405180830381600087803b1580156106c157600080fd5b505af11580156106d5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106f991906127f3565b90506000836101000151518460a001516107139190612bd0565b60c085015160e0860151608080880151604080516001600160a01b0394851681526020810189905291841690820152606081018590529394509116917f3ac06088fd2f047b705cf81c76a5be8b7d378860415de575a9974868ca188980910160405180910390a25050808061078790612c98565b91505061062f565b506001600560006107a38460200151611608565b815260200190815260200160002060006101000a81548160ff021916908315150217905550816001600160a01b03167ffe05d3bcf926920facb1e668218f8c9939003d7bd7cde768cc3c4e9cfa854b2d826020015160405161080591906129ac565b60405180910390a250506001600055505050505050505050505050565b61082f600061039a6112ae565b61084b5760405162461bcd60e51b815260040161050b906129bf565b610864600080516020612d6c8339815191525b8261161b565b50565b6060610880600080516020612d4c833981519152610c88565b905090565b610892600061039a6112ae565b6108ae5760405162461bcd60e51b815260040161050b906129bf565b610864600080516020612d6c8339815191525b82611649565b6000600560006108d684611608565b815260208101919091526040016000205460ff1692915050565b6108fd600061039a6112ae565b6109195760405162461bcd60e51b815260040161050b906129bf565b610864600080516020612d4c8339815191526108c1565b60405162461bcd60e51b815260206004820152605e60248201527f546f6b656e4d696e74436865636b6f7574426173653a204120726f6c6520636160448201527f6e206f6e6c79206265206772616e746564207573696e672074686520636f727260648201527f6573706f6e64696e67207370656369616c697a65642066756e6374696f6e0000608482015260a40161050b565b6000610428600080516020612d6c8339815191525b83610c5d565b6109e76112ae565b6001600160a01b0316816001600160a01b031614610a5f5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b606482015260840161050b565b610a698282611672565b5050565b610a7a600061039a6112ae565b610a965760405162461bcd60e51b815260040161050b906129bf565b610864600080516020612d4c83398151915261085e565b610aba600061039a6112ae565b610ad65760405162461bcd60e51b815260040161050b906129bf565b610ade611694565b565b6000610428600080516020612d4c8339815191526109d9565b6060604051806101200160405280306001600160a01b031681526020018b8b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050509082525060208082018b90526001600160a01b03808b166040808501919091528a82166060850152608084018a905288821660a085015290871660c084015260e09092018590529051610b9f929101612a86565b60405160208183030381529060405290509998505050505050505050565b610bca600061039a6112ae565b610be65760405162461bcd60e51b815260040161050b906129bf565b610bf1600082611649565b6108646000610bfe6112ae565b61161b565b610c10600061039a6112ae565b610c2c5760405162461bcd60e51b815260040161050b906129bf565b610ade61172d565b600061088061114e565b6000828152600260205260408120610c569083611786565b9392505050565b60009182526001602090815260408084206001600160a01b0393909316845291905290205460ff1690565b60606000610c9583610d4f565b90506000816001600160401b03811115610cb157610cb1612d35565b604051908082528060200260200182016040528015610cda578160200160208202803683370190505b50905060005b82811015610d2e57610cf28582610c3e565b828281518110610d0457610d04612d1f565b6001600160a01b039092166020928302919091019091015280610d2681612c98565b915050610ce0565b509392505050565b6060610880600080516020612d6c833981519152610c88565b600081815260026020526040812061042890611792565b60026000541415610db95760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640161050b565b600260005560035460ff1615610de15760405162461bcd60e51b815260040161050b90612a13565b83838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050604080516020601f8701819004810282018101909252858152925085915084908190840183828082843760009201829052509250610e569150849050611257565b90506000610e648284611292565b9050610e6f816109c4565b610e8b5760405162461bcd60e51b815260040161050b90612a3d565b6000610e956112ae565b90506000610ea5898b018b6126f5565b9050610eb0816112d0565b610ec882826060015183608001518460a0015161179c565b60005b8161010001515181101561102b5760008260e001516001600160a01b03166363f8ec418460c001518561010001518581518110610f0a57610f0a612d1f565b60200260200101516040518363ffffffff1660e01b8152600401610f439291906001600160a01b03929092168252602082015260400190565b602060405180830381600087803b158015610f5d57600080fd5b505af1158015610f71573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f9591906127f3565b90506000836101000151518460a00151610faf9190612bd0565b60c085015160e0860151608080880151604080516001600160a01b0394851681526020810189905291841690820152606081018590529394509116917f3ac06088fd2f047b705cf81c76a5be8b7d378860415de575a9974868ca188980910160405180910390a25050808061102390612c98565b915050610ecb565b5060016005600061103f8460200151611608565b815260200190815260200160002060006101000a81548160ff021916908315150217905550816001600160a01b03167ffe05d3bcf926920facb1e668218f8c9939003d7bd7cde768cc3c4e9cfa854b2d82602001516040516110a191906129ac565b60405180910390a2505060016000555050505050505050565b60405162461bcd60e51b815260206004820152605e60248201527f546f6b656e4d696e74436865636b6f7574426173653a204120726f6c6520636160448201527f6e206f6e6c79206265207265766f6b6564207573696e672074686520636f727260648201527f6573706f6e64696e67207370656369616c697a65642066756e6374696f6e0000608482015260a40161050b565b60006108808180610c3e565b6111648282611185565b600082815260026020526040902061117c908261120d565b505050565b3390565b61118f8282610c5d565b610a695760008281526001602081815260408084206001600160a01b0386168552909152909120805460ff191690911790556111c96112ae565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000610c56836001600160a01b038416611804565b60006001600160e01b03198216637965db0b60e01b148061042857506301ffc9a760e01b6001600160e01b0319831614610428565b60006112638251611853565b8260405160200161127592919061288f565b604051602081830303815290604052805190602001209050919050565b60008060006112a18585611958565b91509150610d2e816119c8565b60006112b933610ae0565b156112cb575060131936013560601c90565b503390565b80516001600160a01b031630146113625760405162461bcd60e51b815260206004820152604a60248201527f546f6b656e4d696e74436865636b6f7574426173653a20436f6e74726163742060448201527f6973206e6f7420617574686f72697a656420746f2070726f636573732074686960648201526939903932b8bab2b9ba1760b11b608482015260a40161050b565b61136f81602001516108c7565b156113f15760405162461bcd60e51b815260206004820152604660248201527f546f6b656e4d696e74436865636b6f7574426173653a20436865636b6f75742060448201527f7769746820636865636b6f757449642077617320616c72656164792070726f6360648201526532b9b9b2b21760d11b608482015260a40161050b565b42816040015110156108645760405162461bcd60e51b815260206004820152603860248201527f546f6b656e4d696e74436865636b6f7574426173653a20436865636b6f75742060448201527f74696d652077696e646f772068617320657870697265642e0000000000000000606482015260840161050b565b858510156114e15760405162461bcd60e51b815260206004820152603c60248201527f45524332305061796d656e7450726f636573736f723a2072657175657374206160448201527f6d6f756e742065786365656473207065726d697420616d6f756e742e00000000606482015260840161050b565b60405163d505accf60e01b81526001600160a01b038a81166004830152306024830152604482018790526064820186905260ff8516608483015260a4820184905260c4820183905288169063d505accf9060e401600060405180830381600087803b15801561154f57600080fd5b505af1158015611563573d6000803e3d6000fd5b5061157d925050506001600160a01b0388168a3088611b83565b6115916001600160a01b0388168988611bf4565b6115b08961159f8888612c03565b6001600160a01b038a169190611bf4565b866001600160a01b0316886001600160a01b03167f0538ab32a957d2b55d0ec70a4029e73fdf19f500832839b1d7bafcfbca2a5630886040516115f591815260200190565b60405180910390a3505050505050505050565b60008160405160200161127591906129ac565b6000828152600160208190526040909120015461163f8161163a6112ae565b611c24565b61117c8383611672565b600082815260016020819052604090912001546116688161163a6112ae565b61117c838361115a565b61167c8282611c88565b600082815260026020526040902061117c9082611d0d565b60035460ff166116dd5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015260640161050b565b6003805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6117106112ae565b6040516001600160a01b03909116815260200160405180910390a1565b60035460ff16156117505760405162461bcd60e51b815260040161050b90612a13565b6003805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586117106112ae565b6000610c568383611d22565b6000610428825490565b6117b16001600160a01b038316858584611b83565b816001600160a01b0316836001600160a01b03167f0538ab32a957d2b55d0ec70a4029e73fdf19f500832839b1d7bafcfbca2a5630836040516117f691815260200190565b60405180910390a350505050565b600081815260018301602052604081205461184b57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610428565b506000610428565b6060816118775750506040805180820190915260018152600360fc1b602082015290565b8160005b81156118a1578061188b81612c98565b915061189a9050600a83612bd0565b915061187b565b6000816001600160401b038111156118bb576118bb612d35565b6040519080825280601f01601f1916602001820160405280156118e5576020820181803683370190505b5090505b8415611950576118fa600183612c03565b9150611907600a86612cb3565b611912906030612bb8565b60f81b81838151811061192757611927612d1f565b60200101906001600160f81b031916908160001a905350611949600a86612bd0565b94506118e9565b949350505050565b60008082516041141561198f5760208301516040840151606085015160001a61198387828585611d4c565b945094505050506119c1565b8251604014156119b957602083015160408401516119ae868383611e39565b9350935050506119c1565b506000905060025b9250929050565b60008160048111156119dc576119dc612cf3565b14156119e55750565b60018160048111156119f9576119f9612cf3565b1415611a475760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e61747572650000000000000000604482015260640161050b565b6002816004811115611a5b57611a5b612cf3565b1415611aa95760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e67746800604482015260640161050b565b6003816004811115611abd57611abd612cf3565b1415611b165760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b606482015260840161050b565b6004816004811115611b2a57611b2a612cf3565b14156108645760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b606482015260840161050b565b6040516001600160a01b0380851660248301528316604482015260648101829052611bee9085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152611e68565b50505050565b6040516001600160a01b03831660248201526044810182905261117c90849063a9059cbb60e01b90606401611bb7565b611c2e8282610c5d565b610a6957611c46816001600160a01b03166014611f3a565b611c51836020611f3a565b604051602001611c629291906128ea565b60408051601f198184030181529082905262461bcd60e51b825261050b916004016129ac565b611c928282610c5d565b15610a695760008281526001602090815260408083206001600160a01b03851684529091529020805460ff19169055611cc96112ae565b6001600160a01b0316816001600160a01b0316837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45050565b6000610c56836001600160a01b0384166120d5565b6000826000018281548110611d3957611d39612d1f565b9060005260206000200154905092915050565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831115611d835750600090506003611e30565b8460ff16601b14158015611d9b57508460ff16601c14155b15611dac5750600090506004611e30565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015611e00573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116611e2957600060019250925050611e30565b9150600090505b94509492505050565b6000806001600160ff1b03831660ff84901c601b01611e5a87828885611d4c565b935093505050935093915050565b6000611ebd826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166121c89092919063ffffffff16565b80519091501561117c5780806020019051810190611edb919061243f565b61117c5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161050b565b60606000611f49836002612be4565b611f54906002612bb8565b6001600160401b03811115611f6b57611f6b612d35565b6040519080825280601f01601f191660200182016040528015611f95576020820181803683370190505b509050600360fc1b81600081518110611fb057611fb0612d1f565b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110611fdf57611fdf612d1f565b60200101906001600160f81b031916908160001a9053506000612003846002612be4565b61200e906001612bb8565b90505b6001811115612086576f181899199a1a9b1b9c1cb0b131b232b360811b85600f166010811061204257612042612d1f565b1a60f81b82828151811061205857612058612d1f565b60200101906001600160f81b031916908160001a90535060049490941c9361207f81612c46565b9050612011565b508315610c565760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e74604482015260640161050b565b600081815260018301602052604081205480156121be5760006120f9600183612c03565b855490915060009061210d90600190612c03565b905081811461217257600086600001828154811061212d5761212d612d1f565b906000526020600020015490508087600001848154811061215057612150612d1f565b6000918252602080832090910192909255918252600188019052604090208390555b855486908061218357612183612d09565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610428565b6000915050610428565b6060611950848460008585843b6122215760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161050b565b600080866001600160a01b0316858760405161223d9190612873565b60006040518083038185875af1925050503d806000811461227a576040519150601f19603f3d011682016040523d82523d6000602084013e61227f565b606091505b509150915061228f82828661229a565b979650505050505050565b606083156122a9575081610c56565b8251156122b95782518084602001fd5b8160405162461bcd60e51b815260040161050b91906129ac565b80356001600160a01b03811681146122ea57600080fd5b919050565b600082601f83011261230057600080fd5b813560206001600160401b0382111561231b5761231b612d35565b8160051b61232a828201612b88565b83815282810190868401838801850189101561234557600080fd5b600093505b8584101561236857803583526001939093019291840191840161234a565b50979650505050505050565b60008083601f84011261238657600080fd5b5081356001600160401b0381111561239d57600080fd5b6020830191508360208285010111156119c157600080fd5b600082601f8301126123c657600080fd5b81356001600160401b038111156123df576123df612d35565b6123f2601f8201601f1916602001612b88565b81815284602083860101111561240757600080fd5b816020850160208301376000918101602001919091529392505050565b60006020828403121561243657600080fd5b610c56826122d3565b60006020828403121561245157600080fd5b81518015158114610c5657600080fd5b60006020828403121561247357600080fd5b5035919050565b6000806040838503121561248d57600080fd5b8235915061249d602084016122d3565b90509250929050565b600080604083850312156124b957600080fd5b50508035926020909101359150565b6000602082840312156124da57600080fd5b81356001600160e01b031981168114610c5657600080fd5b6000806000806040858703121561250857600080fd5b84356001600160401b038082111561251f57600080fd5b61252b88838901612374565b9096509450602087013591508082111561254457600080fd5b5061255187828801612374565b95989497509550505050565b60008060008060008060008060c0898b03121561257957600080fd5b88356001600160401b038082111561259057600080fd5b61259c8c838d01612374565b909a50985060208b01359150808211156125b557600080fd5b506125c28b828c01612374565b90975095505060408901359350606089013560ff811681146125e357600080fd5b979a969950949793969295929450505060808201359160a0013590565b60008060008060008060008060006101008a8c03121561261f57600080fd5b89356001600160401b038082111561263657600080fd5b6126428d838e01612374565b909b50995060208c0135985089915061265d60408d016122d3565b975061266b60608d016122d3565b965060808c0135955061268060a08d016122d3565b945061268e60c08d016122d3565b935060e08c01359150808211156126a457600080fd5b506126b18c828d016122ef565b9150509295985092959850929598565b6000602082840312156126d357600080fd5b81356001600160401b038111156126e957600080fd5b611950848285016123b5565b60006020828403121561270757600080fd5b81356001600160401b038082111561271e57600080fd5b90830190610120828603121561273357600080fd5b61273b612b5f565b612744836122d3565b815260208301358281111561275857600080fd5b612764878286016123b5565b60208301525060408301356040820152612780606084016122d3565b6060820152612791608084016122d3565b608082015260a083013560a08201526127ac60c084016122d3565b60c08201526127bd60e084016122d3565b60e082015261010080840135838111156127d657600080fd5b6127e2888287016122ef565b918301919091525095945050505050565b60006020828403121561280557600080fd5b5051919050565b600081518084526020808501945080840160005b8381101561283c57815187529582019590820190600101612820565b509495945050505050565b6000815180845261285f816020860160208601612c1a565b601f01601f19169290920160200192915050565b60008251612885818460208701612c1a565b9190910192915050565b7f19457468657265756d205369676e6564204d6573736167653a0a0000000000008152600083516128c781601a850160208801612c1a565b8351908301906128de81601a840160208801612c1a565b01601a01949350505050565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351612922816017850160208801612c1a565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351612953816028840160208801612c1a565b01602801949350505050565b6020808252825182820181905260009190848201906040850190845b818110156129a05783516001600160a01b03168352928401929184019160010161297b565b50909695505050505050565b602081526000610c566020830184612847565b60208082526034908201527f546f6b656e4d696e74436865636b6f7574426173653a2043616c6c65722069736040820152731036b4b9b9b4b733903937b6329020a226a4a71760611b606082015260800190565b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b60208082526029908201527f546f6b656e4d696e74436865636b6f7574426173653a20496e76616c6964207360408201526834b3b730ba3ab9329760b91b606082015260800190565b60208152612aa06020820183516001600160a01b03169052565b60006020830151610120806040850152612abe610140850183612847565b9150604085015160608501526060850151612ae460808601826001600160a01b03169052565b5060808501516001600160a01b03811660a08601525060a085015160c085015260c0850151612b1e60e08601826001600160a01b03169052565b5060e0850151610100612b3b818701836001600160a01b03169052565b860151858403601f1901838701529050612b55838261280c565b9695505050505050565b60405161012081016001600160401b0381118282101715612b8257612b82612d35565b60405290565b604051601f8201601f191681016001600160401b0381118282101715612bb057612bb0612d35565b604052919050565b60008219821115612bcb57612bcb612cc7565b500190565b600082612bdf57612bdf612cdd565b500490565b6000816000190483118215151615612bfe57612bfe612cc7565b500290565b600082821015612c1557612c15612cc7565b500390565b60005b83811015612c35578181015183820152602001612c1d565b83811115611bee5750506000910152565b600081612c5557612c55612cc7565b506000190190565b600181811c90821680612c7157607f821691505b60208210811415612c9257634e487b7160e01b600052602260045260246000fd5b50919050565b6000600019821415612cac57612cac612cc7565b5060010190565b600082612cc257612cc2612cdd565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052603160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fdfed3df22cd6a774f62b0ae21ffd602cc92e7f3390518eee8b33307fc70380da7d278b39ea7a001f73117bee7ffea7e1ca41ebcd8e6eb1250df020d1673fa827840a26469706673582212206371caccfa150171824abb3dae698d56293adbb0eae67c6b7eb188d84d87fa9a64736f6c63430008070033

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

0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001243592056656e64696e67204d616368696e650000000000000000000000000000

-----Decoded View---------------
Arg [0] : name (string): CY Vending Machine

-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 0000000000000000000000000000000000000000000000000000000000000020
Arg [1] : 0000000000000000000000000000000000000000000000000000000000000012
Arg [2] : 43592056656e64696e67204d616368696e650000000000000000000000000000


Block Transaction Gas Used Reward
view all blocks produced

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

Validator Index Block Amount
View All Withdrawals

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

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