ETH Price: $3,252.94 (+4.15%)
Gas: 2 Gwei

Token

Kondux kNFT (KNFT)
 

Overview

Max Total Supply

1,540 KNFT

Holders

160

Market

Volume (24H)

N/A

Min Price (24H)

N/A

Max Price (24H)

N/A
Balance
5 KNFT
0xe1d452f3779847dbee248108dd1f9f028cd563f4
Loading...
Loading
Loading...
Loading
Loading...
Loading

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

Contract Source Code Verified (Exact Match)

Contract Name:
Kondux

Compiler Version
v0.8.23+commit.f704f362

Optimization Enabled:
Yes with 800 runs

Other Settings:
paris EvmVersion
File 1 of 26 : AccessControl.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)

pragma solidity ^0.8.20;

import {IAccessControl} from "./IAccessControl.sol";
import {Context} from "../utils/Context.sol";
import {ERC165} from "../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:
 *
 * ```solidity
 * 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}:
 *
 * ```solidity
 * 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. We recommend using {AccessControlDefaultAdminRules}
 * to enforce additional security measures for this role.
 */
abstract contract AccessControl is Context, IAccessControl, ERC165 {
    struct RoleData {
        mapping(address account => bool) hasRole;
        bytes32 adminRole;
    }

    mapping(bytes32 role => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

    /**
     * @dev Modifier that checks that an account has a specific role. Reverts
     * with an {AccessControlUnauthorizedAccount} error including the required role.
     */
    modifier onlyRole(bytes32 role) {
        _checkRole(role);
        _;
    }

    /**
     * @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 virtual returns (bool) {
        return _roles[role].hasRole[account];
    }

    /**
     * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`
     * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.
     */
    function _checkRole(bytes32 role) internal view virtual {
        _checkRole(role, _msgSender());
    }

    /**
     * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`
     * is missing `role`.
     */
    function _checkRole(bytes32 role, address account) internal view virtual {
        if (!hasRole(role, account)) {
            revert AccessControlUnauthorizedAccount(account, role);
        }
    }

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

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

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     *
     * May emit a {RoleRevoked} event.
     */
    function revokeRole(bytes32 role, address account) public virtual 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 `callerConfirmation`.
     *
     * May emit a {RoleRevoked} event.
     */
    function renounceRole(bytes32 role, address callerConfirmation) public virtual {
        if (callerConfirmation != _msgSender()) {
            revert AccessControlBadConfirmation();
        }

        _revokeRole(role, callerConfirmation);
    }

    /**
     * @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 Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleGranted} event.
     */
    function _grantRole(bytes32 role, address account) internal virtual returns (bool) {
        if (!hasRole(role, account)) {
            _roles[role].hasRole[account] = true;
            emit RoleGranted(role, account, _msgSender());
            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleRevoked} event.
     */
    function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {
        if (hasRole(role, account)) {
            _roles[role].hasRole[account] = false;
            emit RoleRevoked(role, account, _msgSender());
            return true;
        } else {
            return false;
        }
    }
}

File 2 of 26 : IAccessControl.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)

pragma solidity ^0.8.20;

/**
 * @dev External interface of AccessControl declared to support ERC165 detection.
 */
interface IAccessControl {
    /**
     * @dev The `account` is missing a role.
     */
    error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);

    /**
     * @dev The caller of a function is not the expected one.
     *
     * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.
     */
    error AccessControlBadConfirmation();

    /**
     * @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.
     */
    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 `callerConfirmation`.
     */
    function renounceRole(bytes32 role, address callerConfirmation) external;
}

File 3 of 26 : draft-IERC6093.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC6093.sol)
pragma solidity ^0.8.20;

/**
 * @dev Standard ERC20 Errors
 * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC20 tokens.
 */
interface IERC20Errors {
    /**
     * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     * @param balance Current balance for the interacting account.
     * @param needed Minimum amount required to perform a transfer.
     */
    error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);

    /**
     * @dev Indicates a failure with the token `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     */
    error ERC20InvalidSender(address sender);

    /**
     * @dev Indicates a failure with the token `receiver`. Used in transfers.
     * @param receiver Address to which tokens are being transferred.
     */
    error ERC20InvalidReceiver(address receiver);

    /**
     * @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers.
     * @param spender Address that may be allowed to operate on tokens without being their owner.
     * @param allowance Amount of tokens a `spender` is allowed to operate with.
     * @param needed Minimum amount required to perform a transfer.
     */
    error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);

    /**
     * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
     * @param approver Address initiating an approval operation.
     */
    error ERC20InvalidApprover(address approver);

    /**
     * @dev Indicates a failure with the `spender` to be approved. Used in approvals.
     * @param spender Address that may be allowed to operate on tokens without being their owner.
     */
    error ERC20InvalidSpender(address spender);
}

/**
 * @dev Standard ERC721 Errors
 * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC721 tokens.
 */
interface IERC721Errors {
    /**
     * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in EIP-20.
     * Used in balance queries.
     * @param owner Address of the current owner of a token.
     */
    error ERC721InvalidOwner(address owner);

    /**
     * @dev Indicates a `tokenId` whose `owner` is the zero address.
     * @param tokenId Identifier number of a token.
     */
    error ERC721NonexistentToken(uint256 tokenId);

    /**
     * @dev Indicates an error related to the ownership over a particular token. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     * @param tokenId Identifier number of a token.
     * @param owner Address of the current owner of a token.
     */
    error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);

    /**
     * @dev Indicates a failure with the token `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     */
    error ERC721InvalidSender(address sender);

    /**
     * @dev Indicates a failure with the token `receiver`. Used in transfers.
     * @param receiver Address to which tokens are being transferred.
     */
    error ERC721InvalidReceiver(address receiver);

    /**
     * @dev Indicates a failure with the `operator`’s approval. Used in transfers.
     * @param operator Address that may be allowed to operate on tokens without being their owner.
     * @param tokenId Identifier number of a token.
     */
    error ERC721InsufficientApproval(address operator, uint256 tokenId);

    /**
     * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
     * @param approver Address initiating an approval operation.
     */
    error ERC721InvalidApprover(address approver);

    /**
     * @dev Indicates a failure with the `operator` to be approved. Used in approvals.
     * @param operator Address that may be allowed to operate on tokens without being their owner.
     */
    error ERC721InvalidOperator(address operator);
}

/**
 * @dev Standard ERC1155 Errors
 * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC1155 tokens.
 */
interface IERC1155Errors {
    /**
     * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     * @param balance Current balance for the interacting account.
     * @param needed Minimum amount required to perform a transfer.
     * @param tokenId Identifier number of a token.
     */
    error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);

    /**
     * @dev Indicates a failure with the token `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     */
    error ERC1155InvalidSender(address sender);

    /**
     * @dev Indicates a failure with the token `receiver`. Used in transfers.
     * @param receiver Address to which tokens are being transferred.
     */
    error ERC1155InvalidReceiver(address receiver);

    /**
     * @dev Indicates a failure with the `operator`’s approval. Used in transfers.
     * @param operator Address that may be allowed to operate on tokens without being their owner.
     * @param owner Address of the current owner of a token.
     */
    error ERC1155MissingApprovalForAll(address operator, address owner);

    /**
     * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
     * @param approver Address initiating an approval operation.
     */
    error ERC1155InvalidApprover(address approver);

    /**
     * @dev Indicates a failure with the `operator` to be approved. Used in approvals.
     * @param operator Address that may be allowed to operate on tokens without being their owner.
     */
    error ERC1155InvalidOperator(address operator);

    /**
     * @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.
     * Used in batch transfers.
     * @param idsLength Length of the array of token identifiers
     * @param valuesLength Length of the array of token amounts
     */
    error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);
}

File 4 of 26 : IERC2981.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC2981.sol)

pragma solidity ^0.8.20;

import {IERC165} from "../utils/introspection/IERC165.sol";

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

File 5 of 26 : ERC2981.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/common/ERC2981.sol)

pragma solidity ^0.8.20;

import {IERC2981} from "../../interfaces/IERC2981.sol";
import {IERC165, ERC165} from "../../utils/introspection/ERC165.sol";

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

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

    /**
     * @dev The default royalty set is invalid (eg. (numerator / denominator) >= 1).
     */
    error ERC2981InvalidDefaultRoyalty(uint256 numerator, uint256 denominator);

    /**
     * @dev The default royalty receiver is invalid.
     */
    error ERC2981InvalidDefaultRoyaltyReceiver(address receiver);

    /**
     * @dev The royalty set for an specific `tokenId` is invalid (eg. (numerator / denominator) >= 1).
     */
    error ERC2981InvalidTokenRoyalty(uint256 tokenId, uint256 numerator, uint256 denominator);

    /**
     * @dev The royalty receiver for `tokenId` is invalid.
     */
    error ERC2981InvalidTokenRoyaltyReceiver(uint256 tokenId, address receiver);

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

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

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

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

        return (royalty.receiver, royaltyAmount);
    }

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

    /**
     * @dev Sets the royalty information that all ids in this contract will default to.
     *
     * Requirements:
     *
     * - `receiver` cannot be the zero address.
     * - `feeNumerator` cannot be greater than the fee denominator.
     */
    function _setDefaultRoyalty(address receiver, uint96 feeNumerator) internal virtual {
        uint256 denominator = _feeDenominator();
        if (feeNumerator > denominator) {
            // Royalty fee will exceed the sale price
            revert ERC2981InvalidDefaultRoyalty(feeNumerator, denominator);
        }
        if (receiver == address(0)) {
            revert ERC2981InvalidDefaultRoyaltyReceiver(address(0));
        }

        _defaultRoyaltyInfo = RoyaltyInfo(receiver, feeNumerator);
    }

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

    /**
     * @dev Sets the royalty information for a specific token id, overriding the global default.
     *
     * Requirements:
     *
     * - `receiver` cannot be the zero address.
     * - `feeNumerator` cannot be greater than the fee denominator.
     */
    function _setTokenRoyalty(uint256 tokenId, address receiver, uint96 feeNumerator) internal virtual {
        uint256 denominator = _feeDenominator();
        if (feeNumerator > denominator) {
            // Royalty fee will exceed the sale price
            revert ERC2981InvalidTokenRoyalty(tokenId, feeNumerator, denominator);
        }
        if (receiver == address(0)) {
            revert ERC2981InvalidTokenRoyaltyReceiver(tokenId, address(0));
        }

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

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

File 6 of 26 : ERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/ERC721.sol)

pragma solidity ^0.8.20;

import {IERC721} from "./IERC721.sol";
import {IERC721Receiver} from "./IERC721Receiver.sol";
import {IERC721Metadata} from "./extensions/IERC721Metadata.sol";
import {Context} from "../../utils/Context.sol";
import {Strings} from "../../utils/Strings.sol";
import {IERC165, ERC165} from "../../utils/introspection/ERC165.sol";
import {IERC721Errors} from "../../interfaces/draft-IERC6093.sol";

/**
 * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
 * the Metadata extension, but not including the Enumerable extension, which is available separately as
 * {ERC721Enumerable}.
 */
abstract contract ERC721 is Context, ERC165, IERC721, IERC721Metadata, IERC721Errors {
    using Strings for uint256;

    // Token name
    string private _name;

    // Token symbol
    string private _symbol;

    mapping(uint256 tokenId => address) private _owners;

    mapping(address owner => uint256) private _balances;

    mapping(uint256 tokenId => address) private _tokenApprovals;

    mapping(address owner => mapping(address operator => bool)) private _operatorApprovals;

    /**
     * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
     */
    constructor(string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
    }

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

    /**
     * @dev See {IERC721-balanceOf}.
     */
    function balanceOf(address owner) public view virtual returns (uint256) {
        if (owner == address(0)) {
            revert ERC721InvalidOwner(address(0));
        }
        return _balances[owner];
    }

    /**
     * @dev See {IERC721-ownerOf}.
     */
    function ownerOf(uint256 tokenId) public view virtual returns (address) {
        return _requireOwned(tokenId);
    }

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

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

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

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

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

    /**
     * @dev See {IERC721-approve}.
     */
    function approve(address to, uint256 tokenId) public virtual {
        _approve(to, tokenId, _msgSender());
    }

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

        return _getApproved(tokenId);
    }

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

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

    /**
     * @dev See {IERC721-transferFrom}.
     */
    function transferFrom(address from, address to, uint256 tokenId) public virtual {
        if (to == address(0)) {
            revert ERC721InvalidReceiver(address(0));
        }
        // Setting an "auth" arguments enables the `_isAuthorized` check which verifies that the token exists
        // (from != 0). Therefore, it is not needed to verify that the return value is not 0 here.
        address previousOwner = _update(to, tokenId, _msgSender());
        if (previousOwner != from) {
            revert ERC721IncorrectOwner(from, tokenId, previousOwner);
        }
    }

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

    /**
     * @dev See {IERC721-safeTransferFrom}.
     */
    function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public virtual {
        transferFrom(from, to, tokenId);
        _checkOnERC721Received(from, to, tokenId, data);
    }

    /**
     * @dev Returns the owner of the `tokenId`. Does NOT revert if token doesn't exist
     *
     * IMPORTANT: Any overrides to this function that add ownership of tokens not tracked by the
     * core ERC721 logic MUST be matched with the use of {_increaseBalance} to keep balances
     * consistent with ownership. The invariant to preserve is that for any address `a` the value returned by
     * `balanceOf(a)` must be equal to the number of tokens such that `_ownerOf(tokenId)` is `a`.
     */
    function _ownerOf(uint256 tokenId) internal view virtual returns (address) {
        return _owners[tokenId];
    }

    /**
     * @dev Returns the approved address for `tokenId`. Returns 0 if `tokenId` is not minted.
     */
    function _getApproved(uint256 tokenId) internal view virtual returns (address) {
        return _tokenApprovals[tokenId];
    }

    /**
     * @dev Returns whether `spender` is allowed to manage `owner`'s tokens, or `tokenId` in
     * particular (ignoring whether it is owned by `owner`).
     *
     * WARNING: This function assumes that `owner` is the actual owner of `tokenId` and does not verify this
     * assumption.
     */
    function _isAuthorized(address owner, address spender, uint256 tokenId) internal view virtual returns (bool) {
        return
            spender != address(0) &&
            (owner == spender || isApprovedForAll(owner, spender) || _getApproved(tokenId) == spender);
    }

    /**
     * @dev Checks if `spender` can operate on `tokenId`, assuming the provided `owner` is the actual owner.
     * Reverts if `spender` does not have approval from the provided `owner` for the given token or for all its assets
     * the `spender` for the specific `tokenId`.
     *
     * WARNING: This function assumes that `owner` is the actual owner of `tokenId` and does not verify this
     * assumption.
     */
    function _checkAuthorized(address owner, address spender, uint256 tokenId) internal view virtual {
        if (!_isAuthorized(owner, spender, tokenId)) {
            if (owner == address(0)) {
                revert ERC721NonexistentToken(tokenId);
            } else {
                revert ERC721InsufficientApproval(spender, tokenId);
            }
        }
    }

    /**
     * @dev Unsafe write access to the balances, used by extensions that "mint" tokens using an {ownerOf} override.
     *
     * NOTE: the value is limited to type(uint128).max. This protect against _balance overflow. It is unrealistic that
     * a uint256 would ever overflow from increments when these increments are bounded to uint128 values.
     *
     * WARNING: Increasing an account's balance using this function tends to be paired with an override of the
     * {_ownerOf} function to resolve the ownership of the corresponding tokens so that balances and ownership
     * remain consistent with one another.
     */
    function _increaseBalance(address account, uint128 value) internal virtual {
        unchecked {
            _balances[account] += value;
        }
    }

    /**
     * @dev Transfers `tokenId` from its current owner to `to`, or alternatively mints (or burns) if the current owner
     * (or `to`) is the zero address. Returns the owner of the `tokenId` before the update.
     *
     * The `auth` argument is optional. If the value passed is non 0, then this function will check that
     * `auth` is either the owner of the token, or approved to operate on the token (by the owner).
     *
     * Emits a {Transfer} event.
     *
     * NOTE: If overriding this function in a way that tracks balances, see also {_increaseBalance}.
     */
    function _update(address to, uint256 tokenId, address auth) internal virtual returns (address) {
        address from = _ownerOf(tokenId);

        // Perform (optional) operator check
        if (auth != address(0)) {
            _checkAuthorized(from, auth, tokenId);
        }

        // Execute the update
        if (from != address(0)) {
            // Clear approval. No need to re-authorize or emit the Approval event
            _approve(address(0), tokenId, address(0), false);

            unchecked {
                _balances[from] -= 1;
            }
        }

        if (to != address(0)) {
            unchecked {
                _balances[to] += 1;
            }
        }

        _owners[tokenId] = to;

        emit Transfer(from, to, tokenId);

        return from;
    }

    /**
     * @dev Mints `tokenId` and transfers it to `to`.
     *
     * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
     *
     * Requirements:
     *
     * - `tokenId` must not exist.
     * - `to` cannot be the zero address.
     *
     * Emits a {Transfer} event.
     */
    function _mint(address to, uint256 tokenId) internal {
        if (to == address(0)) {
            revert ERC721InvalidReceiver(address(0));
        }
        address previousOwner = _update(to, tokenId, address(0));
        if (previousOwner != address(0)) {
            revert ERC721InvalidSender(address(0));
        }
    }

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

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

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

    /**
     * @dev Transfers `tokenId` from `from` to `to`.
     *  As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     *
     * Emits a {Transfer} event.
     */
    function _transfer(address from, address to, uint256 tokenId) internal {
        if (to == address(0)) {
            revert ERC721InvalidReceiver(address(0));
        }
        address previousOwner = _update(to, tokenId, address(0));
        if (previousOwner == address(0)) {
            revert ERC721NonexistentToken(tokenId);
        } else if (previousOwner != from) {
            revert ERC721IncorrectOwner(from, tokenId, previousOwner);
        }
    }

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

    /**
     * @dev Same as {xref-ERC721-_safeTransfer-address-address-uint256-}[`_safeTransfer`], with an additional `data` parameter which is
     * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
     */
    function _safeTransfer(address from, address to, uint256 tokenId, bytes memory data) internal virtual {
        _transfer(from, to, tokenId);
        _checkOnERC721Received(from, to, tokenId, data);
    }

    /**
     * @dev Approve `to` to operate on `tokenId`
     *
     * The `auth` argument is optional. If the value passed is non 0, then this function will check that `auth` is
     * either the owner of the token, or approved to operate on all tokens held by this owner.
     *
     * Emits an {Approval} event.
     *
     * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.
     */
    function _approve(address to, uint256 tokenId, address auth) internal {
        _approve(to, tokenId, auth, true);
    }

    /**
     * @dev Variant of `_approve` with an optional flag to enable or disable the {Approval} event. The event is not
     * emitted in the context of transfers.
     */
    function _approve(address to, uint256 tokenId, address auth, bool emitEvent) internal virtual {
        // Avoid reading the owner unless necessary
        if (emitEvent || auth != address(0)) {
            address owner = _requireOwned(tokenId);

            // We do not use _isAuthorized because single-token approvals should not be able to call approve
            if (auth != address(0) && owner != auth && !isApprovedForAll(owner, auth)) {
                revert ERC721InvalidApprover(auth);
            }

            if (emitEvent) {
                emit Approval(owner, to, tokenId);
            }
        }

        _tokenApprovals[tokenId] = to;
    }

    /**
     * @dev Approve `operator` to operate on all of `owner` tokens
     *
     * Requirements:
     * - operator can't be the address zero.
     *
     * Emits an {ApprovalForAll} event.
     */
    function _setApprovalForAll(address owner, address operator, bool approved) internal virtual {
        if (operator == address(0)) {
            revert ERC721InvalidOperator(operator);
        }
        _operatorApprovals[owner][operator] = approved;
        emit ApprovalForAll(owner, operator, approved);
    }

    /**
     * @dev Reverts if the `tokenId` doesn't have a current owner (it hasn't been minted, or it has been burned).
     * Returns the owner.
     *
     * Overrides to ownership logic should be done to {_ownerOf}.
     */
    function _requireOwned(uint256 tokenId) internal view returns (address) {
        address owner = _ownerOf(tokenId);
        if (owner == address(0)) {
            revert ERC721NonexistentToken(tokenId);
        }
        return owner;
    }

    /**
     * @dev Private function to invoke {IERC721Receiver-onERC721Received} on a target address. This will revert if the
     * recipient doesn't accept the token transfer. The call is not executed if the target address is not a contract.
     *
     * @param from address representing the previous owner of the given token ID
     * @param to target address that will receive the tokens
     * @param tokenId uint256 ID of the token to be transferred
     * @param data bytes optional data to send along with the call
     */
    function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory data) private {
        if (to.code.length > 0) {
            try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) {
                if (retval != IERC721Receiver.onERC721Received.selector) {
                    revert ERC721InvalidReceiver(to);
                }
            } catch (bytes memory reason) {
                if (reason.length == 0) {
                    revert ERC721InvalidReceiver(to);
                } else {
                    /// @solidity memory-safe-assembly
                    assembly {
                        revert(add(32, reason), mload(reason))
                    }
                }
            }
        }
    }
}

File 7 of 26 : ERC721Burnable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/extensions/ERC721Burnable.sol)

pragma solidity ^0.8.20;

import {ERC721} from "../ERC721.sol";
import {Context} from "../../../utils/Context.sol";

/**
 * @title ERC721 Burnable Token
 * @dev ERC721 Token that can be burned (destroyed).
 */
abstract contract ERC721Burnable is Context, ERC721 {
    /**
     * @dev Burns `tokenId`. See {ERC721-_burn}.
     *
     * Requirements:
     *
     * - The caller must own `tokenId` or be an approved operator.
     */
    function burn(uint256 tokenId) public virtual {
        // Setting an "auth" arguments enables the `_isAuthorized` check which verifies that the token exists
        // (from != 0). Therefore, it is not needed to verify that the return value is not 0 here.
        _update(address(0), tokenId, _msgSender());
    }
}

File 8 of 26 : ERC721Enumerable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/extensions/ERC721Enumerable.sol)

pragma solidity ^0.8.20;

import {ERC721} from "../ERC721.sol";
import {IERC721Enumerable} from "./IERC721Enumerable.sol";
import {IERC165} from "../../../utils/introspection/ERC165.sol";

/**
 * @dev This implements an optional extension of {ERC721} defined in the EIP that adds enumerability
 * of all the token ids in the contract as well as all token ids owned by each account.
 *
 * CAUTION: `ERC721` extensions that implement custom `balanceOf` logic, such as `ERC721Consecutive`,
 * interfere with enumerability and should not be used together with `ERC721Enumerable`.
 */
abstract contract ERC721Enumerable is ERC721, IERC721Enumerable {
    mapping(address owner => mapping(uint256 index => uint256)) private _ownedTokens;
    mapping(uint256 tokenId => uint256) private _ownedTokensIndex;

    uint256[] private _allTokens;
    mapping(uint256 tokenId => uint256) private _allTokensIndex;

    /**
     * @dev An `owner`'s token query was out of bounds for `index`.
     *
     * NOTE: The owner being `address(0)` indicates a global out of bounds index.
     */
    error ERC721OutOfBoundsIndex(address owner, uint256 index);

    /**
     * @dev Batch mint is not allowed.
     */
    error ERC721EnumerableForbiddenBatchMint();

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

    /**
     * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
     */
    function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual returns (uint256) {
        if (index >= balanceOf(owner)) {
            revert ERC721OutOfBoundsIndex(owner, index);
        }
        return _ownedTokens[owner][index];
    }

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

    /**
     * @dev See {IERC721Enumerable-tokenByIndex}.
     */
    function tokenByIndex(uint256 index) public view virtual returns (uint256) {
        if (index >= totalSupply()) {
            revert ERC721OutOfBoundsIndex(address(0), index);
        }
        return _allTokens[index];
    }

    /**
     * @dev See {ERC721-_update}.
     */
    function _update(address to, uint256 tokenId, address auth) internal virtual override returns (address) {
        address previousOwner = super._update(to, tokenId, auth);

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

        return previousOwner;
    }

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

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

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

        uint256 lastTokenIndex = balanceOf(from);
        uint256 tokenIndex = _ownedTokensIndex[tokenId];

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

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

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

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

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

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

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

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

    /**
     * See {ERC721-_increaseBalance}. We need that to account tokens that were minted in batch
     */
    function _increaseBalance(address account, uint128 amount) internal virtual override {
        if (amount > 0) {
            revert ERC721EnumerableForbiddenBatchMint();
        }
        super._increaseBalance(account, amount);
    }
}

File 9 of 26 : ERC721Royalty.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/extensions/ERC721Royalty.sol)

pragma solidity ^0.8.20;

import {ERC721} from "../ERC721.sol";
import {ERC2981} from "../../common/ERC2981.sol";

/**
 * @dev Extension of ERC721 with the ERC2981 NFT Royalty Standard, a standardized way to retrieve royalty payment
 * information.
 *
 * Royalty information can be specified globally for all token ids via {ERC2981-_setDefaultRoyalty}, and/or individually
 * for specific token ids via {ERC2981-_setTokenRoyalty}. The latter takes precedence over the first.
 *
 * IMPORTANT: ERC-2981 only specifies a way to signal royalty information and does not enforce its payment. See
 * https://eips.ethereum.org/EIPS/eip-2981#optional-royalty-payments[Rationale] in the EIP. Marketplaces are expected to
 * voluntarily pay royalties together with sales, but note that this standard is not yet widely supported.
 */
abstract contract ERC721Royalty is ERC2981, ERC721 {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721, ERC2981) returns (bool) {
        return super.supportsInterface(interfaceId);
    }
}

File 10 of 26 : IERC721Enumerable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/extensions/IERC721Enumerable.sol)

pragma solidity ^0.8.20;

import {IERC721} from "../IERC721.sol";

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

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

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

File 11 of 26 : IERC721Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/extensions/IERC721Metadata.sol)

pragma solidity ^0.8.20;

import {IERC721} from "../IERC721.sol";

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

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

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

File 12 of 26 : IERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721.sol)

pragma solidity ^0.8.20;

import {IERC165} from "../../utils/introspection/IERC165.sol";

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

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

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

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

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

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

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

    /**
     * @dev Transfers `tokenId` token from `from` to `to`.
     *
     * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721
     * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
     * understand this adds an external call which potentially creates a reentrancy vulnerability.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address from, address to, uint256 tokenId) external;

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

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

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

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

File 13 of 26 : IERC721Receiver.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721Receiver.sol)

pragma solidity ^0.8.20;

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

File 14 of 26 : Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)

pragma solidity ^0.8.20;

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

    function _contextSuffixLength() internal view virtual returns (uint256) {
        return 0;
    }
}

File 15 of 26 : MerkleProof.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/MerkleProof.sol)

pragma solidity ^0.8.20;

/**
 * @dev These functions deal with verification of Merkle Tree proofs.
 *
 * The tree and the proofs can be generated using our
 * https://github.com/OpenZeppelin/merkle-tree[JavaScript library].
 * You will find a quickstart guide in the readme.
 *
 * WARNING: You should avoid using leaf values that are 64 bytes long prior to
 * hashing, or use a hash function other than keccak256 for hashing leaves.
 * This is because the concatenation of a sorted pair of internal nodes in
 * the Merkle tree could be reinterpreted as a leaf value.
 * OpenZeppelin's JavaScript library generates Merkle trees that are safe
 * against this attack out of the box.
 */
library MerkleProof {
    /**
     *@dev The multiproof provided is not valid.
     */
    error MerkleProofInvalidMultiproof();

    /**
     * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
     * defined by `root`. For this, a `proof` must be provided, containing
     * sibling hashes on the branch from the leaf to the root of the tree. Each
     * pair of leaves and each pair of pre-images are assumed to be sorted.
     */
    function verify(bytes32[] memory proof, bytes32 root, bytes32 leaf) internal pure returns (bool) {
        return processProof(proof, leaf) == root;
    }

    /**
     * @dev Calldata version of {verify}
     */
    function verifyCalldata(bytes32[] calldata proof, bytes32 root, bytes32 leaf) internal pure returns (bool) {
        return processProofCalldata(proof, leaf) == root;
    }

    /**
     * @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
     * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
     * hash matches the root of the tree. When processing the proof, the pairs
     * of leafs & pre-images are assumed to be sorted.
     */
    function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) {
        bytes32 computedHash = leaf;
        for (uint256 i = 0; i < proof.length; i++) {
            computedHash = _hashPair(computedHash, proof[i]);
        }
        return computedHash;
    }

    /**
     * @dev Calldata version of {processProof}
     */
    function processProofCalldata(bytes32[] calldata proof, bytes32 leaf) internal pure returns (bytes32) {
        bytes32 computedHash = leaf;
        for (uint256 i = 0; i < proof.length; i++) {
            computedHash = _hashPair(computedHash, proof[i]);
        }
        return computedHash;
    }

    /**
     * @dev Returns true if the `leaves` can be simultaneously proven to be a part of a Merkle tree defined by
     * `root`, according to `proof` and `proofFlags` as described in {processMultiProof}.
     *
     * CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details.
     */
    function multiProofVerify(
        bytes32[] memory proof,
        bool[] memory proofFlags,
        bytes32 root,
        bytes32[] memory leaves
    ) internal pure returns (bool) {
        return processMultiProof(proof, proofFlags, leaves) == root;
    }

    /**
     * @dev Calldata version of {multiProofVerify}
     *
     * CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details.
     */
    function multiProofVerifyCalldata(
        bytes32[] calldata proof,
        bool[] calldata proofFlags,
        bytes32 root,
        bytes32[] memory leaves
    ) internal pure returns (bool) {
        return processMultiProofCalldata(proof, proofFlags, leaves) == root;
    }

    /**
     * @dev Returns the root of a tree reconstructed from `leaves` and sibling nodes in `proof`. The reconstruction
     * proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another
     * leaf/inner node or a proof sibling node, depending on whether each `proofFlags` item is true or false
     * respectively.
     *
     * CAUTION: Not all Merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree
     * is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the
     * tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer).
     */
    function processMultiProof(
        bytes32[] memory proof,
        bool[] memory proofFlags,
        bytes32[] memory leaves
    ) internal pure returns (bytes32 merkleRoot) {
        // This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by
        // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
        // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
        // the Merkle tree.
        uint256 leavesLen = leaves.length;
        uint256 proofLen = proof.length;
        uint256 totalHashes = proofFlags.length;

        // Check proof validity.
        if (leavesLen + proofLen != totalHashes + 1) {
            revert MerkleProofInvalidMultiproof();
        }

        // The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
        // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
        bytes32[] memory hashes = new bytes32[](totalHashes);
        uint256 leafPos = 0;
        uint256 hashPos = 0;
        uint256 proofPos = 0;
        // At each step, we compute the next hash using two values:
        // - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
        //   get the next hash.
        // - depending on the flag, either another value from the "main queue" (merging branches) or an element from the
        //   `proof` array.
        for (uint256 i = 0; i < totalHashes; i++) {
            bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
            bytes32 b = proofFlags[i]
                ? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++])
                : proof[proofPos++];
            hashes[i] = _hashPair(a, b);
        }

        if (totalHashes > 0) {
            if (proofPos != proofLen) {
                revert MerkleProofInvalidMultiproof();
            }
            unchecked {
                return hashes[totalHashes - 1];
            }
        } else if (leavesLen > 0) {
            return leaves[0];
        } else {
            return proof[0];
        }
    }

    /**
     * @dev Calldata version of {processMultiProof}.
     *
     * CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details.
     */
    function processMultiProofCalldata(
        bytes32[] calldata proof,
        bool[] calldata proofFlags,
        bytes32[] memory leaves
    ) internal pure returns (bytes32 merkleRoot) {
        // This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by
        // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
        // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
        // the Merkle tree.
        uint256 leavesLen = leaves.length;
        uint256 proofLen = proof.length;
        uint256 totalHashes = proofFlags.length;

        // Check proof validity.
        if (leavesLen + proofLen != totalHashes + 1) {
            revert MerkleProofInvalidMultiproof();
        }

        // The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
        // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
        bytes32[] memory hashes = new bytes32[](totalHashes);
        uint256 leafPos = 0;
        uint256 hashPos = 0;
        uint256 proofPos = 0;
        // At each step, we compute the next hash using two values:
        // - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
        //   get the next hash.
        // - depending on the flag, either another value from the "main queue" (merging branches) or an element from the
        //   `proof` array.
        for (uint256 i = 0; i < totalHashes; i++) {
            bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
            bytes32 b = proofFlags[i]
                ? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++])
                : proof[proofPos++];
            hashes[i] = _hashPair(a, b);
        }

        if (totalHashes > 0) {
            if (proofPos != proofLen) {
                revert MerkleProofInvalidMultiproof();
            }
            unchecked {
                return hashes[totalHashes - 1];
            }
        } else if (leavesLen > 0) {
            return leaves[0];
        } else {
            return proof[0];
        }
    }

    /**
     * @dev Sorts the pair (a, b) and hashes the result.
     */
    function _hashPair(bytes32 a, bytes32 b) private pure returns (bytes32) {
        return a < b ? _efficientHash(a, b) : _efficientHash(b, a);
    }

    /**
     * @dev Implementation of keccak256(abi.encode(a, b)) that doesn't allocate or expand memory.
     */
    function _efficientHash(bytes32 a, bytes32 b) private pure returns (bytes32 value) {
        /// @solidity memory-safe-assembly
        assembly {
            mstore(0x00, a)
            mstore(0x20, b)
            value := keccak256(0x00, 0x40)
        }
    }
}

File 16 of 26 : ERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)

pragma solidity ^0.8.20;

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

File 17 of 26 : IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)

pragma solidity ^0.8.20;

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

File 18 of 26 : Math.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol)

pragma solidity ^0.8.20;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    /**
     * @dev Muldiv operation overflow.
     */
    error MathOverflowedMulDiv();

    enum Rounding {
        Floor, // Toward negative infinity
        Ceil, // Toward positive infinity
        Trunc, // Toward zero
        Expand // Away from zero
    }

    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            uint256 c = a + b;
            if (c < a) return (false, 0);
            return (true, c);
        }
    }

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

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

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

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

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

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

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

    /**
     * @dev Returns the ceiling of the division of two numbers.
     *
     * This differs from standard division with `/` in that it rounds towards infinity instead
     * of rounding towards zero.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        if (b == 0) {
            // Guarantee the same behavior as in a regular Solidity division.
            return a / b;
        }

        // (a + b - 1) / b can overflow on addition, so we distribute.
        return a == 0 ? 0 : (a - 1) / b + 1;
    }

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

            // Handle non-overflow cases, 256 by 256 division.
            if (prod1 == 0) {
                // Solidity will revert if denominator == 0, unlike the div opcode on its own.
                // The surrounding unchecked block does not change this fact.
                // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
                return prod0 / denominator;
            }

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            if (denominator <= prod1) {
                revert MathOverflowedMulDiv();
            }

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

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

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

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

            uint256 twos = denominator & (0 - denominator);
            assembly {
                // Divide denominator by twos.
                denominator := div(denominator, twos)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    /**
     * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.
     */
    function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {
        return uint8(rounding) % 2 == 1;
    }
}

File 19 of 26 : SafeCast.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SafeCast.sol)
// This file was procedurally generated from scripts/generate/templates/SafeCast.js.

pragma solidity ^0.8.20;

/**
 * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow
 * checks.
 *
 * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can
 * easily result in undesired exploitation or bugs, since developers usually
 * assume that overflows raise errors. `SafeCast` restores this intuition by
 * reverting the transaction when such an operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */
library SafeCast {
    /**
     * @dev Value doesn't fit in an uint of `bits` size.
     */
    error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value);

    /**
     * @dev An int value doesn't fit in an uint of `bits` size.
     */
    error SafeCastOverflowedIntToUint(int256 value);

    /**
     * @dev Value doesn't fit in an int of `bits` size.
     */
    error SafeCastOverflowedIntDowncast(uint8 bits, int256 value);

    /**
     * @dev An uint value doesn't fit in an int of `bits` size.
     */
    error SafeCastOverflowedUintToInt(uint256 value);

    /**
     * @dev Returns the downcasted uint248 from uint256, reverting on
     * overflow (when the input is greater than largest uint248).
     *
     * Counterpart to Solidity's `uint248` operator.
     *
     * Requirements:
     *
     * - input must fit into 248 bits
     */
    function toUint248(uint256 value) internal pure returns (uint248) {
        if (value > type(uint248).max) {
            revert SafeCastOverflowedUintDowncast(248, value);
        }
        return uint248(value);
    }

    /**
     * @dev Returns the downcasted uint240 from uint256, reverting on
     * overflow (when the input is greater than largest uint240).
     *
     * Counterpart to Solidity's `uint240` operator.
     *
     * Requirements:
     *
     * - input must fit into 240 bits
     */
    function toUint240(uint256 value) internal pure returns (uint240) {
        if (value > type(uint240).max) {
            revert SafeCastOverflowedUintDowncast(240, value);
        }
        return uint240(value);
    }

    /**
     * @dev Returns the downcasted uint232 from uint256, reverting on
     * overflow (when the input is greater than largest uint232).
     *
     * Counterpart to Solidity's `uint232` operator.
     *
     * Requirements:
     *
     * - input must fit into 232 bits
     */
    function toUint232(uint256 value) internal pure returns (uint232) {
        if (value > type(uint232).max) {
            revert SafeCastOverflowedUintDowncast(232, value);
        }
        return uint232(value);
    }

    /**
     * @dev Returns the downcasted uint224 from uint256, reverting on
     * overflow (when the input is greater than largest uint224).
     *
     * Counterpart to Solidity's `uint224` operator.
     *
     * Requirements:
     *
     * - input must fit into 224 bits
     */
    function toUint224(uint256 value) internal pure returns (uint224) {
        if (value > type(uint224).max) {
            revert SafeCastOverflowedUintDowncast(224, value);
        }
        return uint224(value);
    }

    /**
     * @dev Returns the downcasted uint216 from uint256, reverting on
     * overflow (when the input is greater than largest uint216).
     *
     * Counterpart to Solidity's `uint216` operator.
     *
     * Requirements:
     *
     * - input must fit into 216 bits
     */
    function toUint216(uint256 value) internal pure returns (uint216) {
        if (value > type(uint216).max) {
            revert SafeCastOverflowedUintDowncast(216, value);
        }
        return uint216(value);
    }

    /**
     * @dev Returns the downcasted uint208 from uint256, reverting on
     * overflow (when the input is greater than largest uint208).
     *
     * Counterpart to Solidity's `uint208` operator.
     *
     * Requirements:
     *
     * - input must fit into 208 bits
     */
    function toUint208(uint256 value) internal pure returns (uint208) {
        if (value > type(uint208).max) {
            revert SafeCastOverflowedUintDowncast(208, value);
        }
        return uint208(value);
    }

    /**
     * @dev Returns the downcasted uint200 from uint256, reverting on
     * overflow (when the input is greater than largest uint200).
     *
     * Counterpart to Solidity's `uint200` operator.
     *
     * Requirements:
     *
     * - input must fit into 200 bits
     */
    function toUint200(uint256 value) internal pure returns (uint200) {
        if (value > type(uint200).max) {
            revert SafeCastOverflowedUintDowncast(200, value);
        }
        return uint200(value);
    }

    /**
     * @dev Returns the downcasted uint192 from uint256, reverting on
     * overflow (when the input is greater than largest uint192).
     *
     * Counterpart to Solidity's `uint192` operator.
     *
     * Requirements:
     *
     * - input must fit into 192 bits
     */
    function toUint192(uint256 value) internal pure returns (uint192) {
        if (value > type(uint192).max) {
            revert SafeCastOverflowedUintDowncast(192, value);
        }
        return uint192(value);
    }

    /**
     * @dev Returns the downcasted uint184 from uint256, reverting on
     * overflow (when the input is greater than largest uint184).
     *
     * Counterpart to Solidity's `uint184` operator.
     *
     * Requirements:
     *
     * - input must fit into 184 bits
     */
    function toUint184(uint256 value) internal pure returns (uint184) {
        if (value > type(uint184).max) {
            revert SafeCastOverflowedUintDowncast(184, value);
        }
        return uint184(value);
    }

    /**
     * @dev Returns the downcasted uint176 from uint256, reverting on
     * overflow (when the input is greater than largest uint176).
     *
     * Counterpart to Solidity's `uint176` operator.
     *
     * Requirements:
     *
     * - input must fit into 176 bits
     */
    function toUint176(uint256 value) internal pure returns (uint176) {
        if (value > type(uint176).max) {
            revert SafeCastOverflowedUintDowncast(176, value);
        }
        return uint176(value);
    }

    /**
     * @dev Returns the downcasted uint168 from uint256, reverting on
     * overflow (when the input is greater than largest uint168).
     *
     * Counterpart to Solidity's `uint168` operator.
     *
     * Requirements:
     *
     * - input must fit into 168 bits
     */
    function toUint168(uint256 value) internal pure returns (uint168) {
        if (value > type(uint168).max) {
            revert SafeCastOverflowedUintDowncast(168, value);
        }
        return uint168(value);
    }

    /**
     * @dev Returns the downcasted uint160 from uint256, reverting on
     * overflow (when the input is greater than largest uint160).
     *
     * Counterpart to Solidity's `uint160` operator.
     *
     * Requirements:
     *
     * - input must fit into 160 bits
     */
    function toUint160(uint256 value) internal pure returns (uint160) {
        if (value > type(uint160).max) {
            revert SafeCastOverflowedUintDowncast(160, value);
        }
        return uint160(value);
    }

    /**
     * @dev Returns the downcasted uint152 from uint256, reverting on
     * overflow (when the input is greater than largest uint152).
     *
     * Counterpart to Solidity's `uint152` operator.
     *
     * Requirements:
     *
     * - input must fit into 152 bits
     */
    function toUint152(uint256 value) internal pure returns (uint152) {
        if (value > type(uint152).max) {
            revert SafeCastOverflowedUintDowncast(152, value);
        }
        return uint152(value);
    }

    /**
     * @dev Returns the downcasted uint144 from uint256, reverting on
     * overflow (when the input is greater than largest uint144).
     *
     * Counterpart to Solidity's `uint144` operator.
     *
     * Requirements:
     *
     * - input must fit into 144 bits
     */
    function toUint144(uint256 value) internal pure returns (uint144) {
        if (value > type(uint144).max) {
            revert SafeCastOverflowedUintDowncast(144, value);
        }
        return uint144(value);
    }

    /**
     * @dev Returns the downcasted uint136 from uint256, reverting on
     * overflow (when the input is greater than largest uint136).
     *
     * Counterpart to Solidity's `uint136` operator.
     *
     * Requirements:
     *
     * - input must fit into 136 bits
     */
    function toUint136(uint256 value) internal pure returns (uint136) {
        if (value > type(uint136).max) {
            revert SafeCastOverflowedUintDowncast(136, value);
        }
        return uint136(value);
    }

    /**
     * @dev Returns the downcasted uint128 from uint256, reverting on
     * overflow (when the input is greater than largest uint128).
     *
     * Counterpart to Solidity's `uint128` operator.
     *
     * Requirements:
     *
     * - input must fit into 128 bits
     */
    function toUint128(uint256 value) internal pure returns (uint128) {
        if (value > type(uint128).max) {
            revert SafeCastOverflowedUintDowncast(128, value);
        }
        return uint128(value);
    }

    /**
     * @dev Returns the downcasted uint120 from uint256, reverting on
     * overflow (when the input is greater than largest uint120).
     *
     * Counterpart to Solidity's `uint120` operator.
     *
     * Requirements:
     *
     * - input must fit into 120 bits
     */
    function toUint120(uint256 value) internal pure returns (uint120) {
        if (value > type(uint120).max) {
            revert SafeCastOverflowedUintDowncast(120, value);
        }
        return uint120(value);
    }

    /**
     * @dev Returns the downcasted uint112 from uint256, reverting on
     * overflow (when the input is greater than largest uint112).
     *
     * Counterpart to Solidity's `uint112` operator.
     *
     * Requirements:
     *
     * - input must fit into 112 bits
     */
    function toUint112(uint256 value) internal pure returns (uint112) {
        if (value > type(uint112).max) {
            revert SafeCastOverflowedUintDowncast(112, value);
        }
        return uint112(value);
    }

    /**
     * @dev Returns the downcasted uint104 from uint256, reverting on
     * overflow (when the input is greater than largest uint104).
     *
     * Counterpart to Solidity's `uint104` operator.
     *
     * Requirements:
     *
     * - input must fit into 104 bits
     */
    function toUint104(uint256 value) internal pure returns (uint104) {
        if (value > type(uint104).max) {
            revert SafeCastOverflowedUintDowncast(104, value);
        }
        return uint104(value);
    }

    /**
     * @dev Returns the downcasted uint96 from uint256, reverting on
     * overflow (when the input is greater than largest uint96).
     *
     * Counterpart to Solidity's `uint96` operator.
     *
     * Requirements:
     *
     * - input must fit into 96 bits
     */
    function toUint96(uint256 value) internal pure returns (uint96) {
        if (value > type(uint96).max) {
            revert SafeCastOverflowedUintDowncast(96, value);
        }
        return uint96(value);
    }

    /**
     * @dev Returns the downcasted uint88 from uint256, reverting on
     * overflow (when the input is greater than largest uint88).
     *
     * Counterpart to Solidity's `uint88` operator.
     *
     * Requirements:
     *
     * - input must fit into 88 bits
     */
    function toUint88(uint256 value) internal pure returns (uint88) {
        if (value > type(uint88).max) {
            revert SafeCastOverflowedUintDowncast(88, value);
        }
        return uint88(value);
    }

    /**
     * @dev Returns the downcasted uint80 from uint256, reverting on
     * overflow (when the input is greater than largest uint80).
     *
     * Counterpart to Solidity's `uint80` operator.
     *
     * Requirements:
     *
     * - input must fit into 80 bits
     */
    function toUint80(uint256 value) internal pure returns (uint80) {
        if (value > type(uint80).max) {
            revert SafeCastOverflowedUintDowncast(80, value);
        }
        return uint80(value);
    }

    /**
     * @dev Returns the downcasted uint72 from uint256, reverting on
     * overflow (when the input is greater than largest uint72).
     *
     * Counterpart to Solidity's `uint72` operator.
     *
     * Requirements:
     *
     * - input must fit into 72 bits
     */
    function toUint72(uint256 value) internal pure returns (uint72) {
        if (value > type(uint72).max) {
            revert SafeCastOverflowedUintDowncast(72, value);
        }
        return uint72(value);
    }

    /**
     * @dev Returns the downcasted uint64 from uint256, reverting on
     * overflow (when the input is greater than largest uint64).
     *
     * Counterpart to Solidity's `uint64` operator.
     *
     * Requirements:
     *
     * - input must fit into 64 bits
     */
    function toUint64(uint256 value) internal pure returns (uint64) {
        if (value > type(uint64).max) {
            revert SafeCastOverflowedUintDowncast(64, value);
        }
        return uint64(value);
    }

    /**
     * @dev Returns the downcasted uint56 from uint256, reverting on
     * overflow (when the input is greater than largest uint56).
     *
     * Counterpart to Solidity's `uint56` operator.
     *
     * Requirements:
     *
     * - input must fit into 56 bits
     */
    function toUint56(uint256 value) internal pure returns (uint56) {
        if (value > type(uint56).max) {
            revert SafeCastOverflowedUintDowncast(56, value);
        }
        return uint56(value);
    }

    /**
     * @dev Returns the downcasted uint48 from uint256, reverting on
     * overflow (when the input is greater than largest uint48).
     *
     * Counterpart to Solidity's `uint48` operator.
     *
     * Requirements:
     *
     * - input must fit into 48 bits
     */
    function toUint48(uint256 value) internal pure returns (uint48) {
        if (value > type(uint48).max) {
            revert SafeCastOverflowedUintDowncast(48, value);
        }
        return uint48(value);
    }

    /**
     * @dev Returns the downcasted uint40 from uint256, reverting on
     * overflow (when the input is greater than largest uint40).
     *
     * Counterpart to Solidity's `uint40` operator.
     *
     * Requirements:
     *
     * - input must fit into 40 bits
     */
    function toUint40(uint256 value) internal pure returns (uint40) {
        if (value > type(uint40).max) {
            revert SafeCastOverflowedUintDowncast(40, value);
        }
        return uint40(value);
    }

    /**
     * @dev Returns the downcasted uint32 from uint256, reverting on
     * overflow (when the input is greater than largest uint32).
     *
     * Counterpart to Solidity's `uint32` operator.
     *
     * Requirements:
     *
     * - input must fit into 32 bits
     */
    function toUint32(uint256 value) internal pure returns (uint32) {
        if (value > type(uint32).max) {
            revert SafeCastOverflowedUintDowncast(32, value);
        }
        return uint32(value);
    }

    /**
     * @dev Returns the downcasted uint24 from uint256, reverting on
     * overflow (when the input is greater than largest uint24).
     *
     * Counterpart to Solidity's `uint24` operator.
     *
     * Requirements:
     *
     * - input must fit into 24 bits
     */
    function toUint24(uint256 value) internal pure returns (uint24) {
        if (value > type(uint24).max) {
            revert SafeCastOverflowedUintDowncast(24, value);
        }
        return uint24(value);
    }

    /**
     * @dev Returns the downcasted uint16 from uint256, reverting on
     * overflow (when the input is greater than largest uint16).
     *
     * Counterpart to Solidity's `uint16` operator.
     *
     * Requirements:
     *
     * - input must fit into 16 bits
     */
    function toUint16(uint256 value) internal pure returns (uint16) {
        if (value > type(uint16).max) {
            revert SafeCastOverflowedUintDowncast(16, value);
        }
        return uint16(value);
    }

    /**
     * @dev Returns the downcasted uint8 from uint256, reverting on
     * overflow (when the input is greater than largest uint8).
     *
     * Counterpart to Solidity's `uint8` operator.
     *
     * Requirements:
     *
     * - input must fit into 8 bits
     */
    function toUint8(uint256 value) internal pure returns (uint8) {
        if (value > type(uint8).max) {
            revert SafeCastOverflowedUintDowncast(8, value);
        }
        return uint8(value);
    }

    /**
     * @dev Converts a signed int256 into an unsigned uint256.
     *
     * Requirements:
     *
     * - input must be greater than or equal to 0.
     */
    function toUint256(int256 value) internal pure returns (uint256) {
        if (value < 0) {
            revert SafeCastOverflowedIntToUint(value);
        }
        return uint256(value);
    }

    /**
     * @dev Returns the downcasted int248 from int256, reverting on
     * overflow (when the input is less than smallest int248 or
     * greater than largest int248).
     *
     * Counterpart to Solidity's `int248` operator.
     *
     * Requirements:
     *
     * - input must fit into 248 bits
     */
    function toInt248(int256 value) internal pure returns (int248 downcasted) {
        downcasted = int248(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(248, value);
        }
    }

    /**
     * @dev Returns the downcasted int240 from int256, reverting on
     * overflow (when the input is less than smallest int240 or
     * greater than largest int240).
     *
     * Counterpart to Solidity's `int240` operator.
     *
     * Requirements:
     *
     * - input must fit into 240 bits
     */
    function toInt240(int256 value) internal pure returns (int240 downcasted) {
        downcasted = int240(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(240, value);
        }
    }

    /**
     * @dev Returns the downcasted int232 from int256, reverting on
     * overflow (when the input is less than smallest int232 or
     * greater than largest int232).
     *
     * Counterpart to Solidity's `int232` operator.
     *
     * Requirements:
     *
     * - input must fit into 232 bits
     */
    function toInt232(int256 value) internal pure returns (int232 downcasted) {
        downcasted = int232(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(232, value);
        }
    }

    /**
     * @dev Returns the downcasted int224 from int256, reverting on
     * overflow (when the input is less than smallest int224 or
     * greater than largest int224).
     *
     * Counterpart to Solidity's `int224` operator.
     *
     * Requirements:
     *
     * - input must fit into 224 bits
     */
    function toInt224(int256 value) internal pure returns (int224 downcasted) {
        downcasted = int224(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(224, value);
        }
    }

    /**
     * @dev Returns the downcasted int216 from int256, reverting on
     * overflow (when the input is less than smallest int216 or
     * greater than largest int216).
     *
     * Counterpart to Solidity's `int216` operator.
     *
     * Requirements:
     *
     * - input must fit into 216 bits
     */
    function toInt216(int256 value) internal pure returns (int216 downcasted) {
        downcasted = int216(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(216, value);
        }
    }

    /**
     * @dev Returns the downcasted int208 from int256, reverting on
     * overflow (when the input is less than smallest int208 or
     * greater than largest int208).
     *
     * Counterpart to Solidity's `int208` operator.
     *
     * Requirements:
     *
     * - input must fit into 208 bits
     */
    function toInt208(int256 value) internal pure returns (int208 downcasted) {
        downcasted = int208(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(208, value);
        }
    }

    /**
     * @dev Returns the downcasted int200 from int256, reverting on
     * overflow (when the input is less than smallest int200 or
     * greater than largest int200).
     *
     * Counterpart to Solidity's `int200` operator.
     *
     * Requirements:
     *
     * - input must fit into 200 bits
     */
    function toInt200(int256 value) internal pure returns (int200 downcasted) {
        downcasted = int200(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(200, value);
        }
    }

    /**
     * @dev Returns the downcasted int192 from int256, reverting on
     * overflow (when the input is less than smallest int192 or
     * greater than largest int192).
     *
     * Counterpart to Solidity's `int192` operator.
     *
     * Requirements:
     *
     * - input must fit into 192 bits
     */
    function toInt192(int256 value) internal pure returns (int192 downcasted) {
        downcasted = int192(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(192, value);
        }
    }

    /**
     * @dev Returns the downcasted int184 from int256, reverting on
     * overflow (when the input is less than smallest int184 or
     * greater than largest int184).
     *
     * Counterpart to Solidity's `int184` operator.
     *
     * Requirements:
     *
     * - input must fit into 184 bits
     */
    function toInt184(int256 value) internal pure returns (int184 downcasted) {
        downcasted = int184(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(184, value);
        }
    }

    /**
     * @dev Returns the downcasted int176 from int256, reverting on
     * overflow (when the input is less than smallest int176 or
     * greater than largest int176).
     *
     * Counterpart to Solidity's `int176` operator.
     *
     * Requirements:
     *
     * - input must fit into 176 bits
     */
    function toInt176(int256 value) internal pure returns (int176 downcasted) {
        downcasted = int176(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(176, value);
        }
    }

    /**
     * @dev Returns the downcasted int168 from int256, reverting on
     * overflow (when the input is less than smallest int168 or
     * greater than largest int168).
     *
     * Counterpart to Solidity's `int168` operator.
     *
     * Requirements:
     *
     * - input must fit into 168 bits
     */
    function toInt168(int256 value) internal pure returns (int168 downcasted) {
        downcasted = int168(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(168, value);
        }
    }

    /**
     * @dev Returns the downcasted int160 from int256, reverting on
     * overflow (when the input is less than smallest int160 or
     * greater than largest int160).
     *
     * Counterpart to Solidity's `int160` operator.
     *
     * Requirements:
     *
     * - input must fit into 160 bits
     */
    function toInt160(int256 value) internal pure returns (int160 downcasted) {
        downcasted = int160(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(160, value);
        }
    }

    /**
     * @dev Returns the downcasted int152 from int256, reverting on
     * overflow (when the input is less than smallest int152 or
     * greater than largest int152).
     *
     * Counterpart to Solidity's `int152` operator.
     *
     * Requirements:
     *
     * - input must fit into 152 bits
     */
    function toInt152(int256 value) internal pure returns (int152 downcasted) {
        downcasted = int152(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(152, value);
        }
    }

    /**
     * @dev Returns the downcasted int144 from int256, reverting on
     * overflow (when the input is less than smallest int144 or
     * greater than largest int144).
     *
     * Counterpart to Solidity's `int144` operator.
     *
     * Requirements:
     *
     * - input must fit into 144 bits
     */
    function toInt144(int256 value) internal pure returns (int144 downcasted) {
        downcasted = int144(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(144, value);
        }
    }

    /**
     * @dev Returns the downcasted int136 from int256, reverting on
     * overflow (when the input is less than smallest int136 or
     * greater than largest int136).
     *
     * Counterpart to Solidity's `int136` operator.
     *
     * Requirements:
     *
     * - input must fit into 136 bits
     */
    function toInt136(int256 value) internal pure returns (int136 downcasted) {
        downcasted = int136(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(136, value);
        }
    }

    /**
     * @dev Returns the downcasted int128 from int256, reverting on
     * overflow (when the input is less than smallest int128 or
     * greater than largest int128).
     *
     * Counterpart to Solidity's `int128` operator.
     *
     * Requirements:
     *
     * - input must fit into 128 bits
     */
    function toInt128(int256 value) internal pure returns (int128 downcasted) {
        downcasted = int128(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(128, value);
        }
    }

    /**
     * @dev Returns the downcasted int120 from int256, reverting on
     * overflow (when the input is less than smallest int120 or
     * greater than largest int120).
     *
     * Counterpart to Solidity's `int120` operator.
     *
     * Requirements:
     *
     * - input must fit into 120 bits
     */
    function toInt120(int256 value) internal pure returns (int120 downcasted) {
        downcasted = int120(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(120, value);
        }
    }

    /**
     * @dev Returns the downcasted int112 from int256, reverting on
     * overflow (when the input is less than smallest int112 or
     * greater than largest int112).
     *
     * Counterpart to Solidity's `int112` operator.
     *
     * Requirements:
     *
     * - input must fit into 112 bits
     */
    function toInt112(int256 value) internal pure returns (int112 downcasted) {
        downcasted = int112(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(112, value);
        }
    }

    /**
     * @dev Returns the downcasted int104 from int256, reverting on
     * overflow (when the input is less than smallest int104 or
     * greater than largest int104).
     *
     * Counterpart to Solidity's `int104` operator.
     *
     * Requirements:
     *
     * - input must fit into 104 bits
     */
    function toInt104(int256 value) internal pure returns (int104 downcasted) {
        downcasted = int104(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(104, value);
        }
    }

    /**
     * @dev Returns the downcasted int96 from int256, reverting on
     * overflow (when the input is less than smallest int96 or
     * greater than largest int96).
     *
     * Counterpart to Solidity's `int96` operator.
     *
     * Requirements:
     *
     * - input must fit into 96 bits
     */
    function toInt96(int256 value) internal pure returns (int96 downcasted) {
        downcasted = int96(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(96, value);
        }
    }

    /**
     * @dev Returns the downcasted int88 from int256, reverting on
     * overflow (when the input is less than smallest int88 or
     * greater than largest int88).
     *
     * Counterpart to Solidity's `int88` operator.
     *
     * Requirements:
     *
     * - input must fit into 88 bits
     */
    function toInt88(int256 value) internal pure returns (int88 downcasted) {
        downcasted = int88(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(88, value);
        }
    }

    /**
     * @dev Returns the downcasted int80 from int256, reverting on
     * overflow (when the input is less than smallest int80 or
     * greater than largest int80).
     *
     * Counterpart to Solidity's `int80` operator.
     *
     * Requirements:
     *
     * - input must fit into 80 bits
     */
    function toInt80(int256 value) internal pure returns (int80 downcasted) {
        downcasted = int80(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(80, value);
        }
    }

    /**
     * @dev Returns the downcasted int72 from int256, reverting on
     * overflow (when the input is less than smallest int72 or
     * greater than largest int72).
     *
     * Counterpart to Solidity's `int72` operator.
     *
     * Requirements:
     *
     * - input must fit into 72 bits
     */
    function toInt72(int256 value) internal pure returns (int72 downcasted) {
        downcasted = int72(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(72, value);
        }
    }

    /**
     * @dev Returns the downcasted int64 from int256, reverting on
     * overflow (when the input is less than smallest int64 or
     * greater than largest int64).
     *
     * Counterpart to Solidity's `int64` operator.
     *
     * Requirements:
     *
     * - input must fit into 64 bits
     */
    function toInt64(int256 value) internal pure returns (int64 downcasted) {
        downcasted = int64(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(64, value);
        }
    }

    /**
     * @dev Returns the downcasted int56 from int256, reverting on
     * overflow (when the input is less than smallest int56 or
     * greater than largest int56).
     *
     * Counterpart to Solidity's `int56` operator.
     *
     * Requirements:
     *
     * - input must fit into 56 bits
     */
    function toInt56(int256 value) internal pure returns (int56 downcasted) {
        downcasted = int56(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(56, value);
        }
    }

    /**
     * @dev Returns the downcasted int48 from int256, reverting on
     * overflow (when the input is less than smallest int48 or
     * greater than largest int48).
     *
     * Counterpart to Solidity's `int48` operator.
     *
     * Requirements:
     *
     * - input must fit into 48 bits
     */
    function toInt48(int256 value) internal pure returns (int48 downcasted) {
        downcasted = int48(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(48, value);
        }
    }

    /**
     * @dev Returns the downcasted int40 from int256, reverting on
     * overflow (when the input is less than smallest int40 or
     * greater than largest int40).
     *
     * Counterpart to Solidity's `int40` operator.
     *
     * Requirements:
     *
     * - input must fit into 40 bits
     */
    function toInt40(int256 value) internal pure returns (int40 downcasted) {
        downcasted = int40(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(40, value);
        }
    }

    /**
     * @dev Returns the downcasted int32 from int256, reverting on
     * overflow (when the input is less than smallest int32 or
     * greater than largest int32).
     *
     * Counterpart to Solidity's `int32` operator.
     *
     * Requirements:
     *
     * - input must fit into 32 bits
     */
    function toInt32(int256 value) internal pure returns (int32 downcasted) {
        downcasted = int32(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(32, value);
        }
    }

    /**
     * @dev Returns the downcasted int24 from int256, reverting on
     * overflow (when the input is less than smallest int24 or
     * greater than largest int24).
     *
     * Counterpart to Solidity's `int24` operator.
     *
     * Requirements:
     *
     * - input must fit into 24 bits
     */
    function toInt24(int256 value) internal pure returns (int24 downcasted) {
        downcasted = int24(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(24, value);
        }
    }

    /**
     * @dev Returns the downcasted int16 from int256, reverting on
     * overflow (when the input is less than smallest int16 or
     * greater than largest int16).
     *
     * Counterpart to Solidity's `int16` operator.
     *
     * Requirements:
     *
     * - input must fit into 16 bits
     */
    function toInt16(int256 value) internal pure returns (int16 downcasted) {
        downcasted = int16(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(16, value);
        }
    }

    /**
     * @dev Returns the downcasted int8 from int256, reverting on
     * overflow (when the input is less than smallest int8 or
     * greater than largest int8).
     *
     * Counterpart to Solidity's `int8` operator.
     *
     * Requirements:
     *
     * - input must fit into 8 bits
     */
    function toInt8(int256 value) internal pure returns (int8 downcasted) {
        downcasted = int8(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(8, value);
        }
    }

    /**
     * @dev Converts an unsigned uint256 into a signed int256.
     *
     * Requirements:
     *
     * - input must be less than or equal to maxInt256.
     */
    function toInt256(uint256 value) internal pure returns (int256) {
        // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive
        if (value > uint256(type(int256).max)) {
            revert SafeCastOverflowedUintToInt(value);
        }
        return int256(value);
    }
}

File 20 of 26 : SignedMath.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SignedMath.sol)

pragma solidity ^0.8.20;

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

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

    /**
     * @dev Returns the average of two signed numbers without overflow.
     * The result is rounded towards zero.
     */
    function average(int256 a, int256 b) internal pure returns (int256) {
        // Formula from the book "Hacker's Delight"
        int256 x = (a & b) + ((a ^ b) >> 1);
        return x + (int256(uint256(x) >> 255) & (a ^ b));
    }

    /**
     * @dev Returns the absolute unsigned value of a signed value.
     */
    function abs(int256 n) internal pure returns (uint256) {
        unchecked {
            // must be unchecked in order to support `n = type(int256).min`
            return uint256(n >= 0 ? n : -n);
        }
    }
}

File 21 of 26 : Strings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Strings.sol)

pragma solidity ^0.8.20;

import {Math} from "./math/Math.sol";
import {SignedMath} from "./math/SignedMath.sol";

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant HEX_DIGITS = "0123456789abcdef";
    uint8 private constant ADDRESS_LENGTH = 20;

    /**
     * @dev The `value` string doesn't fit in the specified `length`.
     */
    error StringsInsufficientHexLength(uint256 value, uint256 length);

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

    /**
     * @dev Converts a `int256` to its ASCII `string` decimal representation.
     */
    function toStringSigned(int256 value) internal pure returns (string memory) {
        return string.concat(value < 0 ? "-" : "", toString(SignedMath.abs(value)));
    }

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

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        uint256 localValue = value;
        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_DIGITS[localValue & 0xf];
            localValue >>= 4;
        }
        if (localValue != 0) {
            revert StringsInsufficientHexLength(value, length);
        }
        return string(buffer);
    }

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

    /**
     * @dev Returns true if the two strings are equal.
     */
    function equal(string memory a, string memory b) internal pure returns (bool) {
        return bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b));
    }
}

File 22 of 26 : IKondux.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;

import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol";

interface IKondux {
    function changeDenominator(uint96 _denominator) external returns (uint96);
    function setDefaultRoyalty(address receiver, uint96 feeNumerator) external;
    function setTokenRoyalty(uint256 tokenId, address receiver, uint96 feeNumerator) external;
    function setBaseURI(string memory _newURI) external returns (string memory);
    function tokenURI(uint256 tokenId) external view returns (string memory);
    function safeMint(address to, uint256 dna) external returns (uint256);
    function setDna(uint256 _tokenID, uint256 _dna) external;
    function getDna(uint256 _tokenID) external view returns (uint256);
    function readGen(uint256 _tokenID, uint8 startIndex, uint8 endIndex) external view returns (int256);
    function writeGen(uint256 _tokenID, uint256 inputValue, uint8 startIndex, uint8 endIndex) external;
    function getTransferDate(uint256 _tokenID) external view returns (uint256);
    function burn(uint256 tokenId) external;
    function ownerOf(uint256 tokenId) external view returns (address);
    function getApproved(uint256 tokenId) external view returns (address);
    function faucet() external;
    function balanceOf(address owner) external view returns (uint256);
}

File 23 of 26 : ITreasury.sol
//SPDX-License-Identifier: MIT
pragma solidity >=0.8.9;

interface ITreasury {
    function deposit(
        uint256 _amount,
        address _token
    ) external;

    function depositEther() external payable;

    function withdraw(
        uint256 _amount,
        address _token
    ) external;

    function withdrawTo(
        uint256 _amount,
        address _token,
        address _to
    ) external;

    function withdrawEther(
        uint256 _amount
    ) external;
}

File 24 of 26 : Kondux_NFT.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;

// Import OpenZeppelin contracts
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Royalty.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";

// Kondux contract inherits from various OpenZeppelin contracts
contract Kondux is ERC721, ERC721Enumerable, ERC721Burnable, ERC721Royalty, AccessControl {
    uint256 private _tokenIdCounter;

    // Events emitted by the contract
    event BaseURIChanged(string baseURI);
    event DnaChanged(uint256 indexed tokenID, uint256 dna);
    event DenominatorChanged(uint96 denominator);
    event DnaModified(uint256 indexed tokenID, uint256 dna, uint256 inputValue, uint8 startIndex, uint8 endIndex);
    event RoleChanged(address indexed addr, bytes32 role, bool enabled);

    // Role definitions
    bytes32 public MINTER_ROLE = keccak256("MINTER_ROLE");
    bytes32 public DNA_MODIFIER_ROLE = keccak256("DNA_MODIFIER_ROLE");

    // Contract state variables
    string public baseURI;
    uint96 public denominator;

    mapping (uint256 => uint256) public indexDna; // Maps token IDs to DNA values
    
    mapping (uint256 => uint256) public transferDates; // Maps token IDs to the timestamp of receiving the token

    /**
     * @dev Initializes the Kondux contract with the given name and symbol.
     * Grants the DEFAULT_ADMIN_ROLE, MINTER_ROLE, and DNA_MODIFIER_ROLE to the contract creator.
     * Inherits the ERC721 constructor to set the token name and symbol.
     *
     * @param _name The name of the token.
     * @param _symbol The symbol of the token.
     */
    constructor(string memory _name, string memory _symbol) 
        ERC721(_name, _symbol) {
            _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
            _grantRole(MINTER_ROLE, msg.sender);
            _grantRole(DNA_MODIFIER_ROLE, msg.sender);
    }


    /**
     * @dev Modifier that requires the caller to have the DEFAULT_ADMIN_ROLE.
     * Reverts with an error message if the caller does not have the required role.
     */
    modifier onlyAdmin() {
        require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender), "kNFT Access Control: only admin");
        _;
    }

    /**
     * @dev Modifier that requires the caller to have the MINTER_ROLE.
     * Reverts with an error message if the caller does not have the required role.
     */
    modifier onlyMinter() {
        require(hasRole(MINTER_ROLE, msg.sender), "kNFT Access Control: only minter");
        _;
    }

    /**
     * @dev Modifier that requires the caller to have the DNA_MODIFIER_ROLE.
     * Reverts with an error message if the caller does not have the required role.
     */
    modifier onlyDnaModifier() {
        require(hasRole(DNA_MODIFIER_ROLE, msg.sender), "kNFT Access Control: only dna modifier");
        _;
    }

    /**
     * @dev Changes the denominator value.
     * Emits a DenominatorChanged event with the new denominator value.
     *
     * @param _denominator The new denominator value.
     * @return The updated denominator value.
     */
    function changeDenominator(uint96 _denominator) public onlyAdmin returns (uint96) { 
        denominator = _denominator;
        emit DenominatorChanged(denominator);
        return denominator;
    }

    /**
     * @dev Sets the default royalty for the contract.
     *
     * @param receiver The address that will receive the royalty fees.
     * @param feeNumerator The numerator of the royalty fee.
     */
    function setDefaultRoyalty(address receiver, uint96 feeNumerator) public onlyAdmin {
        _setDefaultRoyalty(receiver, feeNumerator);
    }

    /**
     * @dev Sets the royalty for a specific token.
     *
     * @param tokenId The ID of the token for which the royalty will be set.
     * @param receiver The address that will receive the royalty fees.
     * @param feeNumerator The numerator of the royalty fee.
     */
    function setTokenRoyalty(uint256 tokenId,address receiver,uint96 feeNumerator) public onlyAdmin {
        _setTokenRoyalty(tokenId, receiver, feeNumerator); 
    }

    /**
     * @dev Sets the base URI for token metadata.
     * Emits a BaseURIChanged event with the new base URI.
     *
     * @param _newURI The new base URI.
     * @return The updated base URI.
     */
    function setBaseURI(string memory _newURI) external onlyAdmin returns (string memory) {
        baseURI = _newURI;
        emit BaseURIChanged(baseURI);
        return baseURI;
    }

    /**
     * @dev Returns the token URI for a given token ID.
     * Reverts if the token ID does not exist.
     *
     * @param tokenId The ID of the token.
     * @return The token URI.
     */
    function tokenURI(uint256 tokenId) public view override(ERC721) returns (string memory) {
        require(_ownerOf(tokenId) != address(0), "ERC721Metadata: URI query for nonexistent token");
        return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, Strings.toString(tokenId))) : "";
    }

    /**
     * @dev Safely mints a new token with a specified DNA value for the recipient.
     * Increments the token ID counter.
     *
     * @param to The address of the recipient.
     * @param dna The DNA value of the new token.
     * @return The new token ID.
     */
    function safeMint(address to, uint256 dna) public onlyMinter returns (uint256) {
        uint256 tokenId = _tokenIdCounter++;
        _setDna(tokenId, dna);
        _safeMint(to, tokenId);
        return tokenId;
    }

    /**
     * @dev Sets the DNA value for a given token ID.
     *
     * @param _tokenID The ID of the token for which the DNA value will be set.
     * @param _dna The new DNA value.
     */
    function setDna(uint256 _tokenID, uint256 _dna) public onlyDnaModifier {
        _setDna(_tokenID, _dna);
    }

    /**
     * @dev Returns the DNA value for a given token ID.
     * Reverts if the token ID does not exist.
     *
     * @param _tokenID The ID of the token.
     * @return The DNA value of the token.
     */
    function getDna(uint256 _tokenID) public view returns (uint256) {
        require(_ownerOf(_tokenID) != address(0), "ERC721Metadata: URI query for nonexistent token");
        return indexDna[_tokenID];
    }

    /**
     * @dev Reads a range of bytes from the DNA value of a given token ID.
     * Reverts if the specified range is invalid.
     *
     * @param _tokenID The ID of the token.
     * @param startIndex The starting index of the byte range.
     * @param endIndex The ending index of the byte range.
     * @return The extracted value from the specified byte range.
     */
    function readGen(uint256 _tokenID, uint8 startIndex, uint8 endIndex) public view returns (int256) {
        require(startIndex < endIndex && endIndex <= 32, "Invalid range");

        uint256 originalValue = indexDna[_tokenID];
        uint256 extractedValue;

        for (uint8 i = startIndex; i < endIndex; i++) {
            assembly {
                let bytePos := sub(31, i) // Reverse the index since bytes are stored in big-endian
                let shiftAmount := mul(8, bytePos)

                // Extract the byte from the original value at the current position
                let extractedByte := and(shr(shiftAmount, originalValue), 0xff)

                // Shift the extracted byte to the left by the number of positions
                // from the start of the requested range
                let adjustedShiftAmount := mul(8, sub(i, startIndex))

                // Combine the shifted byte with the previously extracted bytes
                extractedValue := or(extractedValue, shl(adjustedShiftAmount, extractedByte))
            }
        }

        return int256(extractedValue);
    }

    /**
     * @dev Writes a range of bytes to the DNA value of a given token ID.
     * @param _tokenID The ID of the token.
     * @param inputValue The value to be written to the specified byte range.
     * @param startIndex The starting index of the byte range.
     * @param endIndex The ending index of the byte range.
     */ 
    function writeGen(uint256 _tokenID, uint256 inputValue, uint8 startIndex, uint8 endIndex) public onlyDnaModifier {
        _writeGen(_tokenID, inputValue, startIndex, endIndex); 
    }

    /**
     * @dev Writes a range of bytes to the DNA value of a given token ID.
     * Reverts if the specified range is invalid or the input value is too large.
     *
     * @param _tokenID The ID of the token.
     * @param inputValue The value to be written to the specified byte range.
     * @param startIndex The starting index of the byte range.
     * @param endIndex The ending index of the byte range.
     */
    function _writeGen(uint256 _tokenID, uint256 inputValue, uint8 startIndex, uint8 endIndex) internal {
        require(startIndex < endIndex && endIndex <= 32, "Invalid range");
        require(inputValue >= 0, "Only positive values are supported");

        uint256 maxInputValue = (1 << ((endIndex - startIndex) * 8)) - 1;
        require(uint256(inputValue) <= maxInputValue, "Input value is too large for the specified range");

        uint256 originalValue = indexDna[_tokenID];
        uint256 mask;
        uint256 updatedValue;

        for (uint8 i = startIndex; i < endIndex; i++) {
            assembly {
                let bytePos := sub(31, i) // Reverse the index since bytes are stored in big-endian
                let shiftAmount := mul(8, bytePos)

                // Prepare the mask for the current byte
                mask := or(mask, shl(shiftAmount, 0xff))

                // Prepare the updated value
                updatedValue := or(updatedValue, shl(shiftAmount, and(shr(mul(8, sub(i, startIndex)), inputValue), 0xff)))
            }
        }

        // Clear the bytes in the specified range of the original value, then store the updated value
        indexDna[_tokenID] = (originalValue & ~mask) | (updatedValue & mask);

        // Emit the BytesRangeModified event
        emit DnaModified(_tokenID, indexDna[_tokenID], inputValue, startIndex, endIndex);
    }

    /**
     * @dev Add or remove a role from an address.
     * @param role The role identifier (keccak256 hash of the role name).
     * @param addr The address for which the role will be granted or revoked.
     * @param enabled Flag to indicate if the role should be granted (true) or revoked (false).
     */
    function setRole(bytes32 role, address addr, bool enabled) public onlyAdmin {
        if (enabled) {
            _grantRole(role, addr);
        } else {
            _revokeRole(role, addr);
        }
        emit RoleChanged(addr, role, enabled);
    }

    /**
     * @dev Returns the timestamp of the last transfer for a given token ID.
     * Reverts if the token ID does not exist.
     *
     * @param tokenId The ID of the token.
     * @return The timestamp of the last transfer.
     */
    function getTransferDate(uint256 tokenId) public view returns (uint256) {
        require(_ownerOf(tokenId) != address(0), "ERC721Metadata: URI query for nonexistent token");
        return transferDates[tokenId];
    }
  
    // Internal functions //

    /**
     * @dev Returns the base URI for constructing token URIs.
     * @return The base URI.
     */
    function _baseURI() internal view override returns (string memory) { 
        return baseURI;
    }

    /**
     * @dev Internal function to set the DNA value for a given token ID.
     * @param _tokenID The ID of the token.
     * @param _dna The DNA value to be set.
     */
    function _setDna(uint256 _tokenID, uint256 _dna) internal {
        indexDna[_tokenID] = _dna;
        emit DnaChanged(_tokenID, _dna);
    }

    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding Solidity interface to learn more
     * about how these IDs are created.
     * @param interfaceId The interface identifier.
     * @return Whether the interface is supported.
     */
    function supportsInterface(bytes4 interfaceId)
        public
        view
        override(ERC721, ERC721Enumerable, ERC721Royalty, AccessControl)
        returns (bool)
    {
        return super.supportsInterface(interfaceId);
    }

    /**
     * @dev Internal function to update the balance of a given account.
     * @param to The address of the account.
     * @param tokenId The ID of the token.
     * @param auth The address of the authorizer.
     */
    function _update(address to, uint256 tokenId, address auth) internal
        override(ERC721, ERC721Enumerable) 
        returns (address prevOwner) {
        return super._update(to, tokenId, auth);
    }

    /**
     * @dev Internal function to increase the balance of a given account.
     * @param account The address of the account.
     * @param value The amount by which to increase the balance.
     */
    function _increaseBalance(address account, uint128 value) internal
        override(ERC721, ERC721Enumerable) {
        super._increaseBalance(account, value);
    }

}

File 25 of 26 : Minter_Bundle.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.23;
import "./interfaces/IKondux.sol";
import "./interfaces/ITreasury.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/utils/math/SafeCast.sol";
import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";


/**
 * @title MinterBundle
 * @notice Manages the minting of NFT bundles, including setting prices, pausing/unpausing minting, and interacting with external contracts for NFT and treasury management. Designed to facilitate bulk operations for efficiency and convenience.
 * @dev Inherits from OpenZeppelin's AccessControl for comprehensive role management, enabling a robust permission system. Utilizes interfaces for external contract interactions, ensuring modularity and flexibility.
 */
contract MinterBundle is AccessControl {

    bool public paused; // Controls whether minting is currently allowed.
    bool public foundersPassActive; // Controls whether founders pass can be used for minting.
    bool public kBoxActive; // Controls whether kBox can be used for minting.
    bool public kNFTActive; // Controls whether kNFT can be used for minting.
    bool public whitelistActive; // Controls whether the whitelist is active.
    uint16 public bundleSize; // The number of NFTs in each minted bundle.
    uint256 public price; // The ETH price for minting a bundle.
    bytes32 public rootWhitelist; // The Merkle root for the whitelist.

    IKondux public kNFT; // Interface to interact with the Kondux NFT contract for NFT operations.
    IKondux public kBox; // Interface for the kBOX NFT contract, allowing for special minting conditions.
    IKondux public foundersPass; // Interface for the founders pass contract, allowing for special minting conditions.
    ITreasury public treasury; // Interface to interact with the treasury contract for financial transactions.

    mapping (uint256 => bool) public usedFoundersPass;

    // Events for tracking contract state changes and interactions.
    event BundleMinted(address indexed minter, uint256[] tokenIds);
    event FoundersPassUsed(address indexed minter, uint256[] tokenIds, uint256 foundersPassId);
    event TreasuryChanged(address indexed treasury);
    event KNFTChanged(address indexed kNFT);
    event KBoxChanged(address indexed kBox);
    event FoundersPassChanged(address indexed foundersPass);
    event PriceChanged(uint256 price);
    event BundleSizeChanged(uint16 bundleSize);
    event Paused(bool paused);
    event PublicMintActive(bool active);
    event KBoxMintActive(bool active);
    event FoundersPassMintActive(bool active);
    event WhitelistActive(bool active);
    event WhitelistRootChanged(bytes32 root);

    /**
     * @dev Sets initial contract state, including addresses of related contracts, default price, and bundle size. Grants admin role to the deployer for further administrative actions.
     * @param _kNFT Address of the Kondux NFT contract.
     * @param _kBox Address of the kBox NFT contract.
     * @param _treasury Address of the treasury contract.
     */
    constructor(address _kNFT, address _kBox, address _foundersPass, address _treasury) {
        kNFT = IKondux(_kNFT);
        kBox = IKondux(_kBox);
        foundersPass = IKondux(_foundersPass);
        treasury = ITreasury(_treasury);
        price = 0.25 ether;
        bundleSize = 5;
        paused = true;
        foundersPassActive = true;
        kBoxActive = true;
        whitelistActive = true;
        kNFTActive = false;
        
        // Grant admin role to the message sender
        _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
    }

    /**
     * @notice Toggles the paused state of minting operations.
     * @dev Can only be executed by an admin. Emits a `Paused` event reflecting the new state.
     * @param _paused Boolean indicating the desired paused state.
     */
    function setPaused(bool _paused) public onlyAdmin {
        paused = _paused;
        emit Paused(_paused);
    }

    /**
     * @notice Mints a bundle of NFTs if minting is active and sufficient ETH is sent.
     * @dev Validates the sent ETH amount against the current price, deposits the ETH to the treasury, and mints the NFT bundle. Requires the contract to not be paused.
     * @return tokenIds Array of minted token IDs.
     */
    function publicMint() public payable isActive isPublicMintActive returns (uint256[] memory) {
        require(msg.value >= price, "Not enough ETH sent");
        treasury.depositEther{ value: msg.value }();
        uint256[] memory tokenIds = _mintBundle(bundleSize);
        emit BundleMinted(msg.sender, tokenIds);
        return tokenIds;
    }

    /**
     * @notice Mints a bundle of NFTs if minting is active and sufficient ETH is sent. Requires the sender to be on the whitelist.
     * @dev Validates the sent ETH amount against the current price, deposits the ETH to the treasury, and mints the NFT bundle. Requires the contract to not be paused and the whitelist to be active.
     * @param _merkleProof The Merkle proof for the sender's address.
     * @return tokenIds Array of minted token IDs.
     */     
    function publicMintWhitelist(bytes32[] calldata _merkleProof) public payable isActive isWhitelistActive returns (uint256[] memory) {
        require(msg.value >= price, "Not enough ETH sent");        
        bytes32 leaf = keccak256(abi.encodePacked(msg.sender));
        require(MerkleProof.verify(_merkleProof, rootWhitelist, leaf), "Incorrect proof");
        treasury.depositEther{ value: msg.value }();
        uint256[] memory tokenIds = _mintBundle(bundleSize);
        emit BundleMinted(msg.sender, tokenIds);
        return tokenIds;
    }

    /**
     * @notice Burns a specified kBox and mints a bundle of NFTs as a special minting operation.
     * @dev Requires the sender to be the owner of the kBox and for the contract to be approved to burn the kBox. This function demonstrates an alternative minting pathway with additional prerequisites.
     * @param _kBoxId The ID of the kBox to be burned in exchange for minting a new NFT bundle.
     * @return tokenIds Array of minted token IDs.
     */
    function publicMintWithBox(uint256 _kBoxId) public isActive isKBoxMintActive returns (uint256[] memory){
        require(kBox.ownerOf(_kBoxId) == msg.sender, "You are not the owner of this kBox");
        require(kBox.getApproved(_kBoxId) == address(this), "This contract is not approved to burn this kBox");

        kBox.burn(_kBoxId);

        // Mint a bundle of NFTs
        uint256[] memory tokenIds = _mintBundle(bundleSize);

        emit BundleMinted(msg.sender, tokenIds);
        return tokenIds;
    }

    /**
     * @notice Marsks a specified founders pass as used and mints a bundle of NFTs as a special minting operation.
     * @dev Requires the sender to be the owner of the founders pass and we mark it as used in the redeem process. This function demonstrates an alternative minting pathway with additional prerequisites.
     * @param _foundersPassId The ID of the founders pass to be marked as used in exchange for minting a new NFT bundle.
     * @return tokenIds Array of minted token IDs.
     */
    function publicMintWithFoundersPass(uint256 _foundersPassId) public isActive isFoundersPassMintActive returns (uint256[] memory){
        require(foundersPass.ownerOf(_foundersPassId) == msg.sender, "You are not the owner of this founders pass");
        require(!usedFoundersPass[_foundersPassId], "This founders pass has already been used");

        usedFoundersPass[_foundersPassId] = true;

        // Mint a bundle of NFTs
        uint256[] memory tokenIds = _mintBundle(bundleSize);

        emit FoundersPassUsed(msg.sender, tokenIds, _foundersPassId);
        return tokenIds;
    }

    /**
     * @notice Sets the DNA for each NFT in a minted bundle.
     * @dev Admin-only function that assigns a unique DNA to each NFT in the bundle, ensuring that each NFT has distinct characteristics. Validates that the lengths of the `tokenIds` and `dnas` arrays match and correspond to the current `bundleSize`.
     * @param tokenIds Array of token IDs for which to set DNA.
     * @param dnas Array of DNA values corresponding to each token ID.
     */
    function setBundleDna(uint256[] memory tokenIds, uint256[] memory dnas) public onlyAdmin {        
        require(tokenIds.length == dnas.length, "Array lengths do not match");
        require(tokenIds.length == bundleSize, "Array length must match bundle size");
        for (uint256 i = 0; i < bundleSize; i++) {
            kNFT.setDna(tokenIds[i], dnas[i]);
        }
    }

    /**
     * @notice Updates the address of the kBox NFT contract.
     * @dev Admin-only function to change the contract address through which the smart contract interacts with kBox NFTs. Emits a `KNFTChanged` event on success.
     * @param _kBox The new address of the kBox contract.
     */
    function setKBox(address _kBox) public onlyAdmin {
        require(_kBox != address(0), "kBox address is not set");
        kBox = IKondux(_kBox);
        emit KBoxChanged(_kBox);
    }

    /**
     * @notice Updates the address of the treasury contract.
     * @dev Admin-only function to change the contract address for managing treasury operations. Validates the new address before updating and emits a `TreasuryChanged` event on success.
     * @param _treasury The new treasury contract address.
     */
    function setTreasury(address _treasury) public onlyAdmin {
        require(_treasury != address(0), "Treasury address is not set");
        treasury = ITreasury(_treasury);
        emit TreasuryChanged(_treasury);
    }

    /**
     * @notice Updates the address of the Kondux NFT contract.
     * @dev Admin-only function to change the contract address for managing Kondux NFT operations. Validates the new address before updating and emits a `KNFTChanged` event on success.
     * @param _kNFT The new Kondux NFT contract address.
     */
    function setKNFT(address _kNFT) public onlyAdmin {
        require(_kNFT != address(0), "KNFT address is not set");
        kNFT = IKondux(_kNFT);
        emit KNFTChanged(_kNFT);
    }

    /**
     * @notice Updates the address of the founders pass contract.
     * @dev Admin-only function to change the contract address for managing founders pass operations. Validates the new address before updating and emits a `FoundersPassChanged` event on success.
     * @param _foundersPass The new founders pass contract address.
     */
    function setFoundersPass(address _foundersPass) public onlyAdmin {
        require(_foundersPass != address(0), "Founders pass address is not set");
        foundersPass = IKondux(_foundersPass);
        emit FoundersPassChanged(_foundersPass);
    }

    /**
     * @notice Updates the minting price for an NFT bundle.
     * @dev Admin-only function to adjust the ETH price required to mint an NFT bundle. Validates the new price before applying the change and emits a `PriceChanged` event on success.
     * @param _price The new minting price in ETH.
     */
    function setPrice(uint256 _price) public onlyAdmin {
        require(_price > 0, "Price must be greater than 0");
        price = _price;
        emit PriceChanged(_price);
    }

    /**
     * @notice Adjusts the size of the NFT bundle that can be minted at once.
     * @dev Admin-only function to set the number of NFTs included in a single mint operation. Validates the new size for practical limits and emits a `BundleSizeChanged` event on update.
     * @param _bundleSize The new bundle size, within set boundaries.
     */
    function setBundleSize(uint16 _bundleSize) public onlyAdmin {
        require(_bundleSize > 0, "Bundle size must be greater than 0");
        require(_bundleSize <= 15, "Bundle size must be less than or equal to 15");
        bundleSize = _bundleSize;
        emit BundleSizeChanged(_bundleSize);
    }

    /**
     * @notice Grants the admin role to a specified address.
     * @dev Can be executed only by an existing admin. Ensures that the target address is not already an admin and is not the zero address before granting the role.
     * @param _admin The address to be granted admin privileges.
     */
    function setAdmin(address _admin) public onlyAdmin {
        require(_admin != address(0), "Admin address is not set");
        require(!hasRole(DEFAULT_ADMIN_ROLE, _admin), "Address already has admin role");
        grantRole(DEFAULT_ADMIN_ROLE, _admin);
    }

    /**
     * @notice Sets the active state for public minting of Kondux NFTs.
     * @dev Admin-only function to toggle the active state of public minting for Kondux NFTs. Emits a `PublicMintActive` event reflecting the new state.
     * @param _active Boolean indicating the desired active state.
     */
    function setPublicMintActive(bool _active) public onlyAdmin {
        kNFTActive = _active;
        emit PublicMintActive(_active);
    }

    /**
     * @notice Sets the active state for kBox minting.
     * @dev Admin-only function to toggle the active state of minting kBox NFTs. Emits a `KBoxMintActive` event reflecting the new state.
     * @param _active Boolean indicating the desired active state.
     */
    function setKBoxMintActive(bool _active) public onlyAdmin {
        kBoxActive = _active;
        emit KBoxMintActive(_active);
    }

    /**
     * @notice Sets the active state for founders pass minting.
     * @dev Admin-only function to toggle the active state of minting NFTs with founders passes. Emits a `FoundersPassMintActive` event reflecting the new state.
     * @param _active Boolean indicating the desired active state.
     */
    function setFoundersPassMintActive(bool _active) public onlyAdmin {
        foundersPassActive = _active;
        emit FoundersPassMintActive(_active);
    }

    /**
     * @notice Sets the active state for the whitelist.
     * @dev Admin-only function to toggle the active state of the whitelist. Emits a `WhitelistActive` event reflecting the new state.
     * @param _active Boolean indicating the desired active state.
     */
    function setWhitelistActive(bool _active) public onlyAdmin {
        whitelistActive = _active;
        emit WhitelistActive(_active);
    }

    /**
     * @notice Updates the Merkle root for the whitelist.
     * @dev Admin-only function to set a new Merkle root for the whitelist. Emits a `WhitelistRootChanged` event reflecting the new root.
     * @param _root The new Merkle root for the whitelist.
     */
    function setWhitelistRoot(bytes32 _root) public onlyAdmin {
        rootWhitelist = _root;

        emit WhitelistRootChanged(_root);
    }

    // Getter functions provide external visibility into the contract's state without modifying it.

    /**
     * @notice Returns the address of the Kondux NFT contract.
     * @return The current address interfaced by this contract for Kondux NFT operations.
     */
    function getKNFT() public view returns (address) {
        return address(kNFT);
    }

    /**
     * @notice Returns the address of the kBox NFT contract.
     * @return The current address interfaced by this contract for kBox NFT operations.
     */
    function getKBox() public view returns (address) {
        return address(kBox);
    }

    /**
     * @notice Returns the address of the treasury contract.
     * @return The current treasury contract address for financial transactions related to minting.
     */
    function getTreasury() public view returns (address) {
        return address(treasury);
    }

    // Internal functions are utilized by public functions to perform core operations in a secure and encapsulated manner.

    /**
     * @dev Mints a specified number of NFTs to the sender's address. Each NFT minted is part of the bundle and is assigned a consecutive token ID.
     * @param _bundleSize The number of NFTs to mint in the bundle.
     * @return tokenIds An array of the minted NFT token IDs.
     */
    function _mintBundle(uint16 _bundleSize) internal returns (uint256[] memory) {
        uint256[] memory tokenIds = new uint256[](_bundleSize);
        for (uint16 i = 0; i < _bundleSize; i++) {
            tokenIds[i] = kNFT.safeMint(msg.sender, 0); // The second parameter could be a metadata identifier or similar.
        }
        return tokenIds;
    }

    // Modifiers enhance function behaviors with pre-conditions, making the contract's logic more modular, readable, and secure.

    /**
     * @dev Ensures a function is only callable when the contract is not paused.
     * @notice Requires the contract to not be paused for the function to execute.
     */
    modifier isActive() {
        require(!paused, "Contract is paused");
        _;
    }

    /**
     * @dev Ensures a function is only callable when kNFT minting is active.
     * @notice Requires the kNFT minting to be active for the function to execute.
     */
    modifier isPublicMintActive() {
        require(kNFTActive || (foundersPassActive && foundersPass.balanceOf(msg.sender) > 0), "kNFT minting is not active or you don't have a Founder's Pass");
        _;
    }

    /**
     * @dev Ensures a function is only callable when kBox minting is active.
     * @notice Requires the kBox minting to be active for the function to execute.
     */
    modifier isKBoxMintActive() {
        require(kBoxActive, "kBox minting is not active");
        _;
    }

    /**
     * @dev Ensures a function is only callable when founders pass minting is active.
     * @notice Requires the founders pass minting to be active for the function to execute.
     */
    modifier isFoundersPassMintActive() {
        require(foundersPassActive, "Founder's Pass minting is not active");
        _;
    }

    /**
     * @dev Ensures a function is only callable when the whitelist is active.
     * @notice Requires the whitelist to be active for the function to execute.
     */
    modifier isWhitelistActive() {
        require(whitelistActive, "Whitelist is not active");
        _;
    }

    /**
     * @dev Restricts a function's access to users with the admin role.
     * @notice Only callable by users with the admin role.
     */
    modifier onlyAdmin() {
        require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender), "Caller is not an admin");
        _;
    }
}

File 26 of 26 : Minter_Bundle_Demo.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.23;
import "../interfaces/IKondux.sol";
import "../interfaces/ITreasury.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/utils/math/SafeCast.sol";
import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";


/**
 * @title MinterBundle
 * @notice Manages the minting of NFT bundles, including setting prices, pausing/unpausing minting, and interacting with external contracts for NFT and treasury management. Designed to facilitate bulk operations for efficiency and convenience.
 * @dev Inherits from OpenZeppelin's AccessControl for comprehensive role management, enabling a robust permission system. Utilizes interfaces for external contract interactions, ensuring modularity and flexibility.
 */
contract MinterBundleDemo is AccessControl {

    bool public paused; // Controls whether minting is currently allowed.
    bool public foundersPassActive; // Controls whether founders pass can be used for minting.
    bool public kBoxActive; // Controls whether kBox can be used for minting.
    bool public kNFTActive; // Controls whether kNFT can be used for minting.
    bool public whitelistActive; // Controls whether the whitelist is active.
    uint16 public bundleSize; // The number of NFTs in each minted bundle.
    uint256 public price; // The ETH price for minting a bundle.
    bytes32 public rootWhitelist; // The Merkle root for the whitelist.

    IKondux public kNFT; // Interface to interact with the Kondux NFT contract for NFT operations.
    IKondux public kBox; // Interface for the kBOX NFT contract, allowing for special minting conditions.
    IKondux public foundersPass; // Interface for the founders pass contract, allowing for special minting conditions.
    ITreasury public treasury; // Interface to interact with the treasury contract for financial transactions.

    mapping (uint256 => bool) public usedFoundersPass;

    // Events for tracking contract state changes and interactions.
    event BundleMinted(address indexed minter, uint256[] tokenIds);
    event FoundersPassUsed(address indexed minter, uint256[] tokenIds, uint256 foundersPassId);
    event TreasuryChanged(address indexed treasury);
    event KNFTChanged(address indexed kNFT);
    event KBoxChanged(address indexed kBox);
    event FoundersPassChanged(address indexed foundersPass);
    event PriceChanged(uint256 price);
    event BundleSizeChanged(uint16 bundleSize);
    event Paused(bool paused);
    event PublicMintActive(bool active);
    event KBoxMintActive(bool active);
    event FoundersPassMintActive(bool active);
    event WhitelistActive(bool active);
    event WhitelistRootChanged(bytes32 root);

    /**
     * @dev Sets initial contract state, including addresses of related contracts, default price, and bundle size. Grants admin role to the deployer for further administrative actions.
     * @param _kNFT Address of the Kondux NFT contract.
     * @param _kBox Address of the kBox NFT contract.
     * @param _treasury Address of the treasury contract.
     */
    constructor(address _kNFT, address _kBox, address _foundersPass, address _treasury) {
        kNFT = IKondux(_kNFT);
        kBox = IKondux(_kBox);
        foundersPass = IKondux(_foundersPass);
        treasury = ITreasury(_treasury);
        price = 0.000001 ether;
        bundleSize = 5;
        paused = false;
        foundersPassActive = true;
        kBoxActive = true;
        whitelistActive = true;
        kNFTActive = true;
        
        // Grant admin role to the message sender
        _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
    }

    /**
     * @notice Toggles the paused state of minting operations.
     * @dev Can only be executed by an admin. Emits a `Paused` event reflecting the new state.
     * @param _paused Boolean indicating the desired paused state.
     */
    function setPaused(bool _paused) public onlyAdmin {
        paused = _paused;
        emit Paused(_paused);
    }

    /**
     * @notice Mints a bundle of NFTs if minting is active and sufficient ETH is sent.
     * @dev Validates the sent ETH amount against the current price, deposits the ETH to the treasury, and mints the NFT bundle. Requires the contract to not be paused.
     * @return tokenIds Array of minted token IDs.
     */
    function publicMint() public payable isActive isPublicMintActive returns (uint256[] memory) {
        require(msg.value >= price, "Not enough ETH sent");
        treasury.depositEther{ value: msg.value }();
        uint256[] memory tokenIds = _mintBundle(bundleSize);
        emit BundleMinted(msg.sender, tokenIds);
        return tokenIds;
    }

    /**
     * @notice Mints a bundle of NFTs if minting is active and sufficient ETH is sent. Requires the sender to be on the whitelist.
     * @dev Validates the sent ETH amount against the current price, deposits the ETH to the treasury, and mints the NFT bundle. Requires the contract to not be paused and the whitelist to be active.
     * @param _merkleProof The Merkle proof for the sender's address.
     * @return tokenIds Array of minted token IDs.
     */     
    function publicMintWhitelist(bytes32[] calldata _merkleProof) public payable isActive isWhitelistActive returns (uint256[] memory) {
        require(msg.value >= price, "Not enough ETH sent");        
        bytes32 leaf = keccak256(abi.encodePacked(msg.sender));
        require(MerkleProof.verify(_merkleProof, rootWhitelist, leaf), "Incorrect proof");
        treasury.depositEther{ value: msg.value }();
        uint256[] memory tokenIds = _mintBundle(bundleSize);
        emit BundleMinted(msg.sender, tokenIds);
        return tokenIds;
    }

    /**
     * @notice Burns a specified kBox and mints a bundle of NFTs as a special minting operation.
     * @dev Requires the sender to be the owner of the kBox and for the contract to be approved to burn the kBox. This function demonstrates an alternative minting pathway with additional prerequisites.
     * @param _kBoxId The ID of the kBox to be burned in exchange for minting a new NFT bundle.
     * @return tokenIds Array of minted token IDs.
     */
    function publicMintWithBox(uint256 _kBoxId) public isActive isKBoxMintActive returns (uint256[] memory){
        require(kBox.ownerOf(_kBoxId) == msg.sender, "You are not the owner of this kBox");
        require(kBox.getApproved(_kBoxId) == address(this), "This contract is not approved to burn this kBox");

        kBox.burn(_kBoxId);

        // Mint a bundle of NFTs
        uint256[] memory tokenIds = _mintBundle(bundleSize);

        emit BundleMinted(msg.sender, tokenIds);
        return tokenIds;
    }

    /**
     * @notice Marsks a specified founders pass as used and mints a bundle of NFTs as a special minting operation.
     * @dev Requires the sender to be the owner of the founders pass and we mark it as used in the redeem process. This function demonstrates an alternative minting pathway with additional prerequisites.
     * @param _foundersPassId The ID of the founders pass to be marked as used in exchange for minting a new NFT bundle.
     * @return tokenIds Array of minted token IDs.
     */
    function publicMintWithFoundersPass(uint256 _foundersPassId) public isActive isFoundersPassMintActive returns (uint256[] memory){
        require(foundersPass.ownerOf(_foundersPassId) == msg.sender, "You are not the owner of this founders pass");
        require(!usedFoundersPass[_foundersPassId], "This founders pass has already been used");

        usedFoundersPass[_foundersPassId] = true;

        // Mint a bundle of NFTs
        uint256[] memory tokenIds = _mintBundle(bundleSize);

        emit FoundersPassUsed(msg.sender, tokenIds, _foundersPassId);
        return tokenIds;
    }

    /**
     * @notice Sets the DNA for each NFT in a minted bundle.
     * @dev Admin-only function that assigns a unique DNA to each NFT in the bundle, ensuring that each NFT has distinct characteristics. Validates that the lengths of the `tokenIds` and `dnas` arrays match and correspond to the current `bundleSize`.
     * @param tokenIds Array of token IDs for which to set DNA.
     * @param dnas Array of DNA values corresponding to each token ID.
     */
    function setBundleDna(uint256[] memory tokenIds, uint256[] memory dnas) public onlyAdmin {        
        require(tokenIds.length == dnas.length, "Array lengths do not match");
        require(tokenIds.length == bundleSize, "Array length must match bundle size");
        for (uint256 i = 0; i < bundleSize; i++) {
            kNFT.setDna(tokenIds[i], dnas[i]);
        }
    }

    /**
     * @notice Updates the address of the kBox NFT contract.
     * @dev Admin-only function to change the contract address through which the smart contract interacts with kBox NFTs. Emits a `KNFTChanged` event on success.
     * @param _kBox The new address of the kBox contract.
     */
    function setKBox(address _kBox) public onlyAdmin {
        require(_kBox != address(0), "kBox address is not set");
        kBox = IKondux(_kBox);
        emit KBoxChanged(_kBox);
    }

    /**
     * @notice Updates the address of the treasury contract.
     * @dev Admin-only function to change the contract address for managing treasury operations. Validates the new address before updating and emits a `TreasuryChanged` event on success.
     * @param _treasury The new treasury contract address.
     */
    function setTreasury(address _treasury) public onlyAdmin {
        require(_treasury != address(0), "Treasury address is not set");
        treasury = ITreasury(_treasury);
        emit TreasuryChanged(_treasury);
    }

    /// @notice Sets the Kondux NFT contract address.
    /// @dev Can only be called by an admin, requires non-zero address.
    /// @param _kNFT The new KNFT address.
    function setKNFT(address _kNFT) public onlyAdmin {
        require(_kNFT != address(0), "KNFT address is not set");
        kNFT = IKondux(_kNFT);
        emit KNFTChanged(_kNFT);
    }

    /**
     * @notice Updates the address of the founders pass contract.
     * @dev Admin-only function to change the contract address for managing founders pass operations. Validates the new address before updating and emits a `FoundersPassChanged` event on success.
     * @param _foundersPass The new founders pass contract address.
     */
    function setFoundersPass(address _foundersPass) public onlyAdmin {
        require(_foundersPass != address(0), "Founders pass address is not set");
        foundersPass = IKondux(_foundersPass);
        emit FoundersPassChanged(_foundersPass);
    }

    /**
     * @notice Updates the minting price for an NFT bundle.
     * @dev Admin-only function to adjust the ETH price required to mint an NFT bundle. Validates the new price before applying the change and emits a `PriceChanged` event on success.
     * @param _price The new minting price in ETH.
     */
    function setPrice(uint256 _price) public onlyAdmin {
        require(_price > 0, "Price must be greater than 0");
        price = _price;
        emit PriceChanged(_price);
    }

    /**
     * @notice Adjusts the size of the NFT bundle that can be minted at once.
     * @dev Admin-only function to set the number of NFTs included in a single mint operation. Validates the new size for practical limits and emits a `BundleSizeChanged` event on update.
     * @param _bundleSize The new bundle size, within set boundaries.
     */
    function setBundleSize(uint16 _bundleSize) public onlyAdmin {
        require(_bundleSize > 0, "Bundle size must be greater than 0");
        require(_bundleSize <= 15, "Bundle size must be less than or equal to 15");
        bundleSize = _bundleSize;
        emit BundleSizeChanged(_bundleSize);
    }

    /**
     * @notice Grants the admin role to a specified address.
     * @dev Can be executed only by an existing admin. Ensures that the target address is not already an admin and is not the zero address before granting the role.
     * @param _admin The address to be granted admin privileges.
     */
    function setAdmin(address _admin) public onlyAdmin {
        require(_admin != address(0), "Admin address is not set");
        require(!hasRole(DEFAULT_ADMIN_ROLE, _admin), "Address already has admin role");
        grantRole(DEFAULT_ADMIN_ROLE, _admin);
    }

    /**
     * @notice Sets the active state for public minting of Kondux NFTs.
     * @dev Admin-only function to toggle the active state of public minting for Kondux NFTs. Emits a `PublicMintActive` event reflecting the new state.
     * @param _active Boolean indicating the desired active state.
     */
    function setPublicMintActive(bool _active) public onlyAdmin {
        kNFTActive = _active;
        emit PublicMintActive(_active);
    }

    /**
     * @notice Sets the active state for kBox minting.
     * @dev Admin-only function to toggle the active state of minting kBox NFTs. Emits a `KBoxMintActive` event reflecting the new state.
     * @param _active Boolean indicating the desired active state.
     */
    function setKBoxMintActive(bool _active) public onlyAdmin {
        kBoxActive = _active;
        emit KBoxMintActive(_active);
    }

    /**
     * @notice Sets the active state for founders pass minting.
     * @dev Admin-only function to toggle the active state of minting NFTs with founders passes. Emits a `FoundersPassMintActive` event reflecting the new state.
     * @param _active Boolean indicating the desired active state.
     */
    function setFoundersPassMintActive(bool _active) public onlyAdmin {
        foundersPassActive = _active;
        emit FoundersPassMintActive(_active);
    }

    /**
     * @notice Sets the active state for the whitelist.
     * @dev Admin-only function to toggle the active state of the whitelist. Emits a `WhitelistActive` event reflecting the new state.
     * @param _active Boolean indicating the desired active state.
     */
    function setWhitelistActive(bool _active) public onlyAdmin {
        whitelistActive = _active;
        emit WhitelistActive(_active);
    }

    /**
     * @notice Updates the Merkle root for the whitelist.
     * @dev Admin-only function to set a new Merkle root for the whitelist. Emits a `WhitelistRootChanged` event reflecting the new root.
     * @param _root The new Merkle root for the whitelist.
     */
    function setWhitelistRoot(bytes32 _root) public onlyAdmin {
        rootWhitelist = _root;

        emit WhitelistRootChanged(_root);
    }

    // Getter functions provide external visibility into the contract's state without modifying it.

    /**
     * @notice Returns the address of the Kondux NFT contract.
     * @return The current address interfaced by this contract for Kondux NFT operations.
     */
    function getKNFT() public view returns (address) {
        return address(kNFT);
    }

    /**
     * @notice Returns the address of the kBox NFT contract.
     * @return The current address interfaced by this contract for kBox NFT operations.
     */
    function getKBox() public view returns (address) {
        return address(kBox);
    }

    /**
     * @notice Returns the address of the treasury contract.
     * @return The current treasury contract address for financial transactions related to minting.
     */
    function getTreasury() public view returns (address) {
        return address(treasury);
    }

    // Internal functions are utilized by public functions to perform core operations in a secure and encapsulated manner.

    /**
     * @dev Mints a specified number of NFTs to the sender's address. Each NFT minted is part of the bundle and is assigned a consecutive token ID.
     * @param _bundleSize The number of NFTs to mint in the bundle.
     * @return tokenIds An array of the minted NFT token IDs.
     */
    function _mintBundle(uint16 _bundleSize) internal returns (uint256[] memory) {
        uint256[] memory tokenIds = new uint256[](_bundleSize);
        for (uint16 i = 0; i < _bundleSize; i++) {
            tokenIds[i] = kNFT.safeMint(msg.sender, 0); // The second parameter could be a metadata identifier or similar.
        }
        return tokenIds;
    }

    // Modifiers enhance function behaviors with pre-conditions, making the contract's logic more modular, readable, and secure.

    /**
     * @dev Ensures a function is only callable when the contract is not paused.
     */
    modifier isActive() {
        require(!paused, "Contract is paused");
        _;
    }

    /**
     * @dev Ensures a function is only callable when kNFT minting is active.
     */
    modifier isPublicMintActive() {
        require(kNFTActive || (foundersPassActive && foundersPass.balanceOf(msg.sender) > 0), "kNFT minting is not active or you don't have a Founder's Pass");
        _;
    }

    /**
     * @dev Ensures a function is only callable when kBox minting is active.
     */
    modifier isKBoxMintActive() {
        require(kBoxActive, "kBox minting is not active");
        _;
    }

    /**
     * @dev Ensures a function is only callable when founders pass minting is active.
     */
    modifier isFoundersPassMintActive() {
        require(foundersPassActive, "Founder's Pass minting is not active");
        _;
    }

    /**
     * @dev Ensures a function is only callable when the whitelist is active.
     */
    modifier isWhitelistActive() {
        require(whitelistActive, "Whitelist is not active");
        _;
    }

    /**
     * @dev Restricts a function's access to users with the admin role.
     */
    modifier onlyAdmin() {
        require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender), "Caller is not an admin");
        _;
    }
}

Settings
{
  "metadata": {
    "bytecodeHash": "none"
  },
  "optimizer": {
    "enabled": true,
    "runs": 800
  },
  "evmVersion": "paris",
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  }
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AccessControlBadConfirmation","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"neededRole","type":"bytes32"}],"name":"AccessControlUnauthorizedAccount","type":"error"},{"inputs":[{"internalType":"uint256","name":"numerator","type":"uint256"},{"internalType":"uint256","name":"denominator","type":"uint256"}],"name":"ERC2981InvalidDefaultRoyalty","type":"error"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"}],"name":"ERC2981InvalidDefaultRoyaltyReceiver","type":"error"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"numerator","type":"uint256"},{"internalType":"uint256","name":"denominator","type":"uint256"}],"name":"ERC2981InvalidTokenRoyalty","type":"error"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"}],"name":"ERC2981InvalidTokenRoyaltyReceiver","type":"error"},{"inputs":[],"name":"ERC721EnumerableForbiddenBatchMint","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"owner","type":"address"}],"name":"ERC721IncorrectOwner","type":"error"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ERC721InsufficientApproval","type":"error"},{"inputs":[{"internalType":"address","name":"approver","type":"address"}],"name":"ERC721InvalidApprover","type":"error"},{"inputs":[{"internalType":"address","name":"operator","type":"address"}],"name":"ERC721InvalidOperator","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"ERC721InvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"}],"name":"ERC721InvalidReceiver","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"}],"name":"ERC721InvalidSender","type":"error"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ERC721NonexistentToken","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"ERC721OutOfBoundsIndex","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"baseURI","type":"string"}],"name":"BaseURIChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint96","name":"denominator","type":"uint96"}],"name":"DenominatorChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenID","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"dna","type":"uint256"}],"name":"DnaChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenID","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"dna","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"inputValue","type":"uint256"},{"indexed":false,"internalType":"uint8","name":"startIndex","type":"uint8"},{"indexed":false,"internalType":"uint8","name":"endIndex","type":"uint8"}],"name":"DnaModified","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":"address","name":"addr","type":"address"},{"indexed":false,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":false,"internalType":"bool","name":"enabled","type":"bool"}],"name":"RoleChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DNA_MODIFIER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MINTER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"baseURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint96","name":"_denominator","type":"uint96"}],"name":"changeDenominator","outputs":[{"internalType":"uint96","name":"","type":"uint96"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"denominator","outputs":[{"internalType":"uint96","name":"","type":"uint96"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenID","type":"uint256"}],"name":"getDna","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"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":"uint256","name":"tokenId","type":"uint256"}],"name":"getTransferDate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"indexDna","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenID","type":"uint256"},{"internalType":"uint8","name":"startIndex","type":"uint8"},{"internalType":"uint8","name":"endIndex","type":"uint8"}],"name":"readGen","outputs":[{"internalType":"int256","name":"","type":"int256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"callerConfirmation","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"salePrice","type":"uint256"}],"name":"royaltyInfo","outputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"dna","type":"uint256"}],"name":"safeMint","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_newURI","type":"string"}],"name":"setBaseURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint96","name":"feeNumerator","type":"uint96"}],"name":"setDefaultRoyalty","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenID","type":"uint256"},{"internalType":"uint256","name":"_dna","type":"uint256"}],"name":"setDna","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"addr","type":"address"},{"internalType":"bool","name":"enabled","type":"bool"}],"name":"setRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint96","name":"feeNumerator","type":"uint96"}],"name":"setTokenRoyalty","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenOfOwnerByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"transferDates","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenID","type":"uint256"},{"internalType":"uint256","name":"inputValue","type":"uint256"},{"internalType":"uint8","name":"startIndex","type":"uint8"},{"internalType":"uint8","name":"endIndex","type":"uint8"}],"name":"writeGen","outputs":[],"stateMutability":"nonpayable","type":"function"}]

60806040527f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a6600e557fec24298dbd4b206c04cdf3b7c16a0458a980808b5ea4b7b04745962db1bf69a8600f553480156200005957600080fd5b5060405162002f9a38038062002f9a8339810160408190526200007c9162000251565b818160026200008c83826200034c565b5060036200009b82826200034c565b50620000ad91506000905033620000d6565b50600e54620000bd9033620000d6565b50600f54620000cd9033620000d6565b50505062000418565b6000828152600c602090815260408083206001600160a01b038516845290915281205460ff166200017f576000838152600c602090815260408083206001600160a01b03861684529091529020805460ff19166001179055620001363390565b6001600160a01b0316826001600160a01b0316847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a450600162000183565b5060005b92915050565b634e487b7160e01b600052604160045260246000fd5b600082601f830112620001b157600080fd5b81516001600160401b0380821115620001ce57620001ce62000189565b604051601f8301601f19908116603f01168101908282118183101715620001f957620001f962000189565b81604052838152602092508660208588010111156200021757600080fd5b600091505b838210156200023b57858201830151818301840152908201906200021c565b6000602085830101528094505050505092915050565b600080604083850312156200026557600080fd5b82516001600160401b03808211156200027d57600080fd5b6200028b868387016200019f565b93506020850151915080821115620002a257600080fd5b50620002b1858286016200019f565b9150509250929050565b600181811c90821680620002d057607f821691505b602082108103620002f157634e487b7160e01b600052602260045260246000fd5b50919050565b601f82111562000347576000816000526020600020601f850160051c81016020861015620003225750805b601f850160051c820191505b8181101562000343578281556001016200032e565b5050505b505050565b81516001600160401b0381111562000368576200036862000189565b6200038081620003798454620002bb565b84620002f7565b602080601f831160018114620003b857600084156200039f5750858301515b600019600386901b1c1916600185901b17855562000343565b600085815260208120601f198616915b82811015620003e957888601518255948401946001909101908401620003c8565b5085821015620004085787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b612b7280620004286000396000f3fe608060405234801561001057600080fd5b50600436106102d35760003560e01c806355f804b31161018657806396ce0795116100e3578063b576bcb211610097578063d539139311610071578063d53913931461063a578063d547741f14610643578063e985e9c51461065657600080fd5b8063b576bcb214610601578063b88d4fde14610614578063c87b56dd1461062757600080fd5b8063a217fddf116100c8578063a217fddf146105d3578063a22cb465146105db578063ab51e23a146105ee57600080fd5b806396ce079514610595578063a1448194146105c057600080fd5b80636c0360eb1161013a57806370a082311161011f57806370a082311461054157806391d148541461055457806395d89b411461058d57600080fd5b80636c0360eb146105195780636e7dbfcb1461052157600080fd5b80636352211e1161016b5780636352211e146104e05780636750bcbc146104f35780636a9513161461050657600080fd5b806355f804b3146104ba5780635944c753146104cd57600080fd5b8063248a9ca311610234578063422627c3116101e857806342966c68116101cd57806342966c681461048b57806348571f231461049e5780634f6ccce7146104a757600080fd5b8063422627c31461046557806342842e0e1461047857600080fd5b80632f2ff15d116102195780632f2ff15d1461042c5780632f745c591461043f57806336568abe1461045257600080fd5b8063248a9ca3146103d75780632a55205a146103fa57600080fd5b8063095ea7b31161028b57806318160ddd1161027057806318160ddd1461039c5780631c9ad5b1146103a457806323b872dd146103c457600080fd5b8063095ea7b3146103685780630caefef41461037b57600080fd5b8063067b61f2116102bc578063067b61f21461031557806306fdde0314610328578063081812fc1461033d57600080fd5b806301ffc9a7146102d857806304634d8d14610300575b600080fd5b6102eb6102e636600461233f565b610692565b60405190151581526020015b60405180910390f35b61031361030e36600461238a565b6106a3565b005b6103136103233660046123bd565b610734565b6103306107b9565b6040516102f7919061242f565b61035061034b366004612442565b61084b565b6040516001600160a01b0390911681526020016102f7565b61031361037636600461245b565b610874565b61038e610389366004612496565b61087f565b6040519081526020016102f7565b600a5461038e565b61038e6103b2366004612442565b60126020526000908152604090205481565b6103136103d23660046124d2565b610923565b61038e6103e5366004612442565b6000908152600c602052604090206001015490565b61040d6104083660046123bd565b6109ae565b604080516001600160a01b0390931683526020830191909152016102f7565b61031361043a36600461250e565b610a5a565b61038e61044d36600461245b565b610a7f565b61031361046036600461250e565b610ae4565b61038e610473366004612442565b610b1c565b6103136104863660046124d2565b610bab565b610313610499366004612442565b610bc6565b61038e600f5481565b61038e6104b5366004612442565b610bd2565b6103306104c83660046125bd565b610c2b565b6103136104db366004612606565b610d84565b6103506104ee366004612442565b610e0d565b61038e610501366004612442565b610e18565b610313610514366004612649565b610ea7565b610330610f91565b61038e61052f366004612442565b60136020526000908152604090205481565b61038e61054f36600461267c565b61101f565b6102eb61056236600461250e565b6000918252600c602090815260408084206001600160a01b0393909316845291905290205460ff1690565b610330611067565b6011546105a8906001600160601b031681565b6040516001600160601b0390911681526020016102f7565b61038e6105ce36600461245b565b611076565b61038e600081565b6103136105e9366004612697565b611114565b6105a86105fc3660046126c1565b61111f565b61031361060f3660046126dc565b611204565b610313610622366004612722565b61128b565b610330610635366004612442565b6112a2565b61038e600e5481565b61031361065136600461250e565b61137d565b6102eb61066436600461279e565b6001600160a01b03918216600090815260076020908152604080832093909416825291909152205460ff1690565b600061069d826113a2565b92915050565b3360009081527f13649b2456f1b42fef0f0040b3aaeabcd21a76a0f3f5defd4f583839455116e8602052604090205460ff166107265760405162461bcd60e51b815260206004820152601f60248201527f6b4e46542041636365737320436f6e74726f6c3a206f6e6c792061646d696e0060448201526064015b60405180910390fd5b61073082826113c7565b5050565b600f546000908152600c6020908152604080832033845290915290205460ff166107af5760405162461bcd60e51b815260206004820152602660248201527f6b4e46542041636365737320436f6e74726f6c3a206f6e6c7920646e61206d6f6044820152653234b334b2b960d11b606482015260840161071d565b610730828261146a565b6060600280546107c8906127c8565b80601f01602080910402602001604051908101604052809291908181526020018280546107f4906127c8565b80156108415780601f1061081657610100808354040283529160200191610841565b820191906000526020600020905b81548152906001019060200180831161082457829003601f168201915b5050505050905090565b6000610856826114bb565b506000828152600660205260409020546001600160a01b031661069d565b6107308282336114f4565b60008160ff168360ff1610801561089a575060208260ff1611155b6108d65760405162461bcd60e51b815260206004820152600d60248201526c496e76616c69642072616e676560981b604482015260640161071d565b60008481526012602052604081205490845b8460ff168160ff161015610919576008601f829003810284901c60ff168783039091021b91909117906001016108e8565b5095945050505050565b6001600160a01b03821661094d57604051633250574960e11b81526000600482015260240161071d565b600061095a838333611501565b9050836001600160a01b0316816001600160a01b0316146109a8576040516364283d7b60e01b81526001600160a01b038086166004830152602482018490528216604482015260640161071d565b50505050565b60008281526001602090815260408083208151808301909252546001600160a01b038116808352600160a01b9091046001600160601b0316928201929092528291610a235750604080518082019091526000546001600160a01b0381168252600160a01b90046001600160601b031660208201525b602081015160009061271090610a42906001600160601b031687612818565b610a4c919061282f565b915196919550909350505050565b6000828152600c6020526040902060010154610a7581611516565b6109a88383611523565b6000610a8a8361101f565b8210610abb5760405163295f44f760e21b81526001600160a01b03841660048201526024810183905260440161071d565b506001600160a01b03919091166000908152600860209081526040808320938352929052205490565b6001600160a01b0381163314610b0d5760405163334bd91960e11b815260040160405180910390fd5b610b1782826115d1565b505050565b6000818152600460205260408120546001600160a01b0316610b985760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b606482015260840161071d565b5060009081526012602052604090205490565b610b178383836040518060200160405280600081525061128b565b61073060008233611501565b6000610bdd600a5490565b8210610c065760405163295f44f760e21b8152600060048201526024810183905260440161071d565b600a8281548110610c1957610c19612851565b90600052602060002001549050919050565b3360009081527f13649b2456f1b42fef0f0040b3aaeabcd21a76a0f3f5defd4f583839455116e8602052604090205460609060ff16610cac5760405162461bcd60e51b815260206004820152601f60248201527f6b4e46542041636365737320436f6e74726f6c3a206f6e6c792061646d696e00604482015260640161071d565b6010610cb883826128b7565b507f5411e8ebf1636d9e83d5fc4900bf80cbac82e8790da2a4c94db4895e889eedf66010604051610ce99190612977565b60405180910390a160108054610cfe906127c8565b80601f0160208091040260200160405190810160405280929190818152602001828054610d2a906127c8565b8015610d775780601f10610d4c57610100808354040283529160200191610d77565b820191906000526020600020905b815481529060010190602001808311610d5a57829003601f168201915b505050505090505b919050565b3360009081527f13649b2456f1b42fef0f0040b3aaeabcd21a76a0f3f5defd4f583839455116e8602052604090205460ff16610e025760405162461bcd60e51b815260206004820152601f60248201527f6b4e46542041636365737320436f6e74726f6c3a206f6e6c792061646d696e00604482015260640161071d565b610b17838383611658565b600061069d826114bb565b6000818152600460205260408120546001600160a01b0316610e945760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b606482015260840161071d565b5060009081526013602052604090205490565b3360009081527f13649b2456f1b42fef0f0040b3aaeabcd21a76a0f3f5defd4f583839455116e8602052604090205460ff16610f255760405162461bcd60e51b815260206004820152601f60248201527f6b4e46542041636365737320436f6e74726f6c3a206f6e6c792061646d696e00604482015260640161071d565b8015610f3b57610f358383611523565b50610f47565b610f4583836115d1565b505b6040805184815282151560208201526001600160a01b038416917f0a3389242138f35e16a456882b75845c8c6b72970ed65963a34ec6f1cc9be603910160405180910390a2505050565b60108054610f9e906127c8565b80601f0160208091040260200160405190810160405280929190818152602001828054610fca906127c8565b80156110175780601f10610fec57610100808354040283529160200191611017565b820191906000526020600020905b815481529060010190602001808311610ffa57829003601f168201915b505050505081565b60006001600160a01b03821661104b576040516322718ad960e21b81526000600482015260240161071d565b506001600160a01b031660009081526005602052604090205490565b6060600380546107c8906127c8565b600e546000908152600c6020908152604080832033845290915281205460ff166110e25760405162461bcd60e51b815260206004820181905260248201527f6b4e46542041636365737320436f6e74726f6c3a206f6e6c79206d696e746572604482015260640161071d565b600d8054600091826110f383612a07565b919050559050611103818461146a565b61110d848261171a565b9392505050565b610730338383611734565b3360009081527f13649b2456f1b42fef0f0040b3aaeabcd21a76a0f3f5defd4f583839455116e8602052604081205460ff1661119d5760405162461bcd60e51b815260206004820152601f60248201527f6b4e46542041636365737320436f6e74726f6c3a206f6e6c792061646d696e00604482015260640161071d565b601180546bffffffffffffffffffffffff19166001600160601b0384169081179091556040519081527f601b85aa9305dbcfbfc81aa2d4b5126c1ce24afdd1bad47d6880e5b6df081f579060200160405180910390a150506011546001600160601b031690565b600f546000908152600c6020908152604080832033845290915290205460ff1661127f5760405162461bcd60e51b815260206004820152602660248201527f6b4e46542041636365737320436f6e74726f6c3a206f6e6c7920646e61206d6f6044820152653234b334b2b960d11b606482015260840161071d565b6109a8848484846117d3565b611296848484610923565b6109a88484848461198c565b6000818152600460205260409020546060906001600160a01b03166113215760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b606482015260840161071d565b600060108054611330906127c8565b90501161134c576040518060200160405280600081525061069d565b601061135783611ab5565b604051602001611368929190612a20565b60405160208183030381529060405292915050565b6000828152600c602052604090206001015461139881611516565b6109a883836115d1565b60006001600160e01b03198216637965db0b60e01b148061069d575061069d82611b55565b6127106001600160601b03821681101561140657604051636f483d0960e01b81526001600160601b03831660048201526024810182905260440161071d565b6001600160a01b03831661143057604051635b6cc80560e11b81526000600482015260240161071d565b50604080518082019091526001600160a01b039092168083526001600160601b039091166020909201829052600160a01b90910217600055565b600082815260126020526040908190208290555182907f4e26044f7fb3724a9375deb74974fdc2f4e07f265efce87f93cfced354258487906114af9084815260200190565b60405180910390a25050565b6000818152600460205260408120546001600160a01b03168061069d57604051637e27328960e01b81526004810184905260240161071d565b610b178383836001611b60565b600061150e848484611c92565b949350505050565b6115208133611d5f565b50565b6000828152600c602090815260408083206001600160a01b038516845290915281205460ff166115c9576000838152600c602090815260408083206001600160a01b03861684529091529020805460ff191660011790556115813390565b6001600160a01b0316826001600160a01b0316847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a450600161069d565b50600061069d565b6000828152600c602090815260408083206001600160a01b038516845290915281205460ff16156115c9576000838152600c602090815260408083206001600160a01b0386168085529252808320805460ff1916905551339286917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a450600161069d565b6127106001600160601b03821681101561169e5760405163dfd1fc1b60e01b8152600481018590526001600160601b03831660248201526044810182905260640161071d565b6001600160a01b0383166116cf57604051634b4f842960e11b8152600481018590526000602482015260440161071d565b506040805180820182526001600160a01b0393841681526001600160601b0392831660208083019182526000968752600190529190942093519051909116600160a01b029116179055565b610730828260405180602001604052806000815250611db4565b6001600160a01b03821661176657604051630b61174360e31b81526001600160a01b038316600482015260240161071d565b6001600160a01b03838116600081815260076020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b8060ff168260ff161080156117ec575060208160ff1611155b6118285760405162461bcd60e51b815260206004820152600d60248201526c496e76616c69642072616e676560981b604482015260640161071d565b600060016118368484612aa7565b611841906008612ac0565b60ff166001901b6118529190612ae3565b9050808411156118ca5760405162461bcd60e51b815260206004820152603060248201527f496e7075742076616c756520697320746f6f206c6172676520666f722074686560448201527f207370656369666965642072616e676500000000000000000000000000000000606482015260840161071d565b6000858152601260205260408120549080855b8560ff168160ff1610156119195760ff6008601f839003810282811b95909517948984039091028a901c909116901b91909117906001016118dd565b50600088815260126020908152604091829020841986168585161790819055825190815290810189905260ff8881168284015287166060820152905189917fe152bca267ba38f000682405e9883c60a372ace2d8f54ad39deebd5a33bb72ee919081900360800190a25050505050505050565b6001600160a01b0383163b156109a857604051630a85bd0160e11b81526001600160a01b0384169063150b7a02906119ce903390889087908790600401612af6565b6020604051808303816000875af1925050508015611a09575060408051601f3d908101601f19168201909252611a0691810190612b32565b60015b611a72573d808015611a37576040519150601f19603f3d011682016040523d82523d6000602084013e611a3c565b606091505b508051600003611a6a57604051633250574960e11b81526001600160a01b038516600482015260240161071d565b805181602001fd5b6001600160e01b03198116630a85bd0160e11b14611aae57604051633250574960e11b81526001600160a01b038516600482015260240161071d565b5050505050565b60606000611ac283611dcb565b600101905060008167ffffffffffffffff811115611ae257611ae2612531565b6040519080825280601f01601f191660200182016040528015611b0c576020820181803683370190505b5090508181016020015b600019017f3031323334353637383961626364656600000000000000000000000000000000600a86061a8153600a8504945084611b1657509392505050565b600061069d82611ead565b8080611b7457506001600160a01b03821615155b15611c55576000611b84846114bb565b90506001600160a01b03831615801590611bb05750826001600160a01b0316816001600160a01b031614155b8015611be257506001600160a01b0380821660009081526007602090815260408083209387168352929052205460ff16155b15611c0b5760405163a9fbf51f60e01b81526001600160a01b038416600482015260240161071d565b8115611c535783856001600160a01b0316826001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45b505b50506000908152600660205260409020805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b600080611ca0858585611ed2565b90506001600160a01b038116611cfd57611cf884600a80546000838152600b60205260408120829055600182018355919091527fc65a7bb8d6351c1cf70c95a316cc6a92839c986682d98bc35f958f4883f9d2a80155565b611d20565b846001600160a01b0316816001600160a01b031614611d2057611d208185611fd8565b6001600160a01b038516611d3c57611d3784612069565b61150e565b846001600160a01b0316816001600160a01b03161461150e5761150e8585612118565b6000828152600c602090815260408083206001600160a01b038516845290915290205460ff166107305760405163e2517d3f60e01b81526001600160a01b03821660048201526024810183905260440161071d565b611dbe8383612168565b610b17600084848461198c565b6000807a184f03e93ff9f4daa797ed6e38ed64bf6a1f0100000000000000008310611e14577a184f03e93ff9f4daa797ed6e38ed64bf6a1f010000000000000000830492506040015b6d04ee2d6d415b85acef81000000008310611e40576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc100008310611e5e57662386f26fc10000830492506010015b6305f5e1008310611e76576305f5e100830492506008015b6127108310611e8a57612710830492506004015b60648310611e9c576064830492506002015b600a831061069d5760010192915050565b60006001600160e01b0319821663780e9d6360e01b148061069d575061069d826121cd565b6000828152600460205260408120546001600160a01b0390811690831615611eff57611eff81848661220d565b6001600160a01b03811615611f3d57611f1c600085600080611b60565b6001600160a01b038116600090815260056020526040902080546000190190555b6001600160a01b03851615611f6c576001600160a01b0385166000908152600560205260409020805460010190555b600084815260046020526040808220805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0389811691821790925591518793918516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4949350505050565b6000611fe38361101f565b600083815260096020526040902054909150808214612036576001600160a01b03841660009081526008602090815260408083208584528252808320548484528184208190558352600990915290208190555b5060009182526009602090815260408084208490556001600160a01b039094168352600881528383209183525290812055565b600a5460009061207b90600190612ae3565b6000838152600b6020526040812054600a80549394509092849081106120a3576120a3612851565b9060005260206000200154905080600a83815481106120c4576120c4612851565b6000918252602080832090910192909255828152600b9091526040808220849055858252812055600a8054806120fc576120fc612b4f565b6001900381819060005260206000200160009055905550505050565b600060016121258461101f565b61212f9190612ae3565b6001600160a01b039093166000908152600860209081526040808320868452825280832085905593825260099052919091209190915550565b6001600160a01b03821661219257604051633250574960e11b81526000600482015260240161071d565b60006121a083836000611501565b90506001600160a01b03811615610b17576040516339e3563760e11b81526000600482015260240161071d565b60006001600160e01b031982166380ac58cd60e01b14806121fe57506001600160e01b03198216635b5e139f60e01b145b8061069d575061069d82612271565b6122188383836122a6565b610b17576001600160a01b03831661224657604051637e27328960e01b81526004810182905260240161071d565b60405163177e802f60e01b81526001600160a01b03831660048201526024810182905260440161071d565b60006001600160e01b0319821663152a902d60e11b148061069d57506301ffc9a760e01b6001600160e01b031983161461069d565b60006001600160a01b0383161580159061150e5750826001600160a01b0316846001600160a01b0316148061230057506001600160a01b0380851660009081526007602090815260408083209387168352929052205460ff165b8061150e5750506000908152600660205260409020546001600160a01b03908116911614919050565b6001600160e01b03198116811461152057600080fd5b60006020828403121561235157600080fd5b813561110d81612329565b80356001600160a01b0381168114610d7f57600080fd5b80356001600160601b0381168114610d7f57600080fd5b6000806040838503121561239d57600080fd5b6123a68361235c565b91506123b460208401612373565b90509250929050565b600080604083850312156123d057600080fd5b50508035926020909101359150565b60005b838110156123fa5781810151838201526020016123e2565b50506000910152565b6000815180845261241b8160208601602086016123df565b601f01601f19169290920160200192915050565b60208152600061110d6020830184612403565b60006020828403121561245457600080fd5b5035919050565b6000806040838503121561246e57600080fd5b6124778361235c565b946020939093013593505050565b803560ff81168114610d7f57600080fd5b6000806000606084860312156124ab57600080fd5b833592506124bb60208501612485565b91506124c960408501612485565b90509250925092565b6000806000606084860312156124e757600080fd5b6124f08461235c565b92506124fe6020850161235c565b9150604084013590509250925092565b6000806040838503121561252157600080fd5b823591506123b46020840161235c565b634e487b7160e01b600052604160045260246000fd5b600067ffffffffffffffff8084111561256257612562612531565b604051601f8501601f19908116603f0116810190828211818310171561258a5761258a612531565b816040528093508581528686860111156125a357600080fd5b858560208301376000602087830101525050509392505050565b6000602082840312156125cf57600080fd5b813567ffffffffffffffff8111156125e657600080fd5b8201601f810184136125f757600080fd5b61150e84823560208401612547565b60008060006060848603121561261b57600080fd5b8335925061262b6020850161235c565b91506124c960408501612373565b80358015158114610d7f57600080fd5b60008060006060848603121561265e57600080fd5b8335925061266e6020850161235c565b91506124c960408501612639565b60006020828403121561268e57600080fd5b61110d8261235c565b600080604083850312156126aa57600080fd5b6126b38361235c565b91506123b460208401612639565b6000602082840312156126d357600080fd5b61110d82612373565b600080600080608085870312156126f257600080fd5b843593506020850135925061270960408601612485565b915061271760608601612485565b905092959194509250565b6000806000806080858703121561273857600080fd5b6127418561235c565b935061274f6020860161235c565b925060408501359150606085013567ffffffffffffffff81111561277257600080fd5b8501601f8101871361278357600080fd5b61279287823560208401612547565b91505092959194509250565b600080604083850312156127b157600080fd5b6127ba8361235c565b91506123b46020840161235c565b600181811c908216806127dc57607f821691505b6020821081036127fc57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b808202811582820484141761069d5761069d612802565b60008261284c57634e487b7160e01b600052601260045260246000fd5b500490565b634e487b7160e01b600052603260045260246000fd5b601f821115610b17576000816000526020600020601f850160051c810160208610156128905750805b601f850160051c820191505b818110156128af5782815560010161289c565b505050505050565b815167ffffffffffffffff8111156128d1576128d1612531565b6128e5816128df84546127c8565b84612867565b602080601f83116001811461291a57600084156129025750858301515b600019600386901b1c1916600185901b1785556128af565b600085815260208120601f198616915b828110156129495788860151825594840194600190910190840161292a565b50858210156129675787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b600060208083526000845461298b816127c8565b80602087015260406001808416600081146129ad57600181146129c9576129f9565b60ff19851660408a0152604084151560051b8a010195506129f9565b89600052602060002060005b858110156129f05781548b82018601529083019088016129d5565b8a016040019650505b509398975050505050505050565b600060018201612a1957612a19612802565b5060010190565b6000808454612a2e816127c8565b60018281168015612a465760018114612a5b57612a8a565b60ff1984168752821515830287019450612a8a565b8860005260208060002060005b85811015612a815781548a820152908401908201612a68565b50505082870194505b505050508351612a9e8183602088016123df565b01949350505050565b60ff828116828216039081111561069d5761069d612802565b60ff8181168382160290811690818114612adc57612adc612802565b5092915050565b8181038181111561069d5761069d612802565b60006001600160a01b03808716835280861660208401525083604083015260806060830152612b286080830184612403565b9695505050505050565b600060208284031215612b4457600080fd5b815161110d81612329565b634e487b7160e01b600052603160045260246000fdfea164736f6c6343000817000a00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000b4b6f6e647578206b4e465400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044b4e465400000000000000000000000000000000000000000000000000000000

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106102d35760003560e01c806355f804b31161018657806396ce0795116100e3578063b576bcb211610097578063d539139311610071578063d53913931461063a578063d547741f14610643578063e985e9c51461065657600080fd5b8063b576bcb214610601578063b88d4fde14610614578063c87b56dd1461062757600080fd5b8063a217fddf116100c8578063a217fddf146105d3578063a22cb465146105db578063ab51e23a146105ee57600080fd5b806396ce079514610595578063a1448194146105c057600080fd5b80636c0360eb1161013a57806370a082311161011f57806370a082311461054157806391d148541461055457806395d89b411461058d57600080fd5b80636c0360eb146105195780636e7dbfcb1461052157600080fd5b80636352211e1161016b5780636352211e146104e05780636750bcbc146104f35780636a9513161461050657600080fd5b806355f804b3146104ba5780635944c753146104cd57600080fd5b8063248a9ca311610234578063422627c3116101e857806342966c68116101cd57806342966c681461048b57806348571f231461049e5780634f6ccce7146104a757600080fd5b8063422627c31461046557806342842e0e1461047857600080fd5b80632f2ff15d116102195780632f2ff15d1461042c5780632f745c591461043f57806336568abe1461045257600080fd5b8063248a9ca3146103d75780632a55205a146103fa57600080fd5b8063095ea7b31161028b57806318160ddd1161027057806318160ddd1461039c5780631c9ad5b1146103a457806323b872dd146103c457600080fd5b8063095ea7b3146103685780630caefef41461037b57600080fd5b8063067b61f2116102bc578063067b61f21461031557806306fdde0314610328578063081812fc1461033d57600080fd5b806301ffc9a7146102d857806304634d8d14610300575b600080fd5b6102eb6102e636600461233f565b610692565b60405190151581526020015b60405180910390f35b61031361030e36600461238a565b6106a3565b005b6103136103233660046123bd565b610734565b6103306107b9565b6040516102f7919061242f565b61035061034b366004612442565b61084b565b6040516001600160a01b0390911681526020016102f7565b61031361037636600461245b565b610874565b61038e610389366004612496565b61087f565b6040519081526020016102f7565b600a5461038e565b61038e6103b2366004612442565b60126020526000908152604090205481565b6103136103d23660046124d2565b610923565b61038e6103e5366004612442565b6000908152600c602052604090206001015490565b61040d6104083660046123bd565b6109ae565b604080516001600160a01b0390931683526020830191909152016102f7565b61031361043a36600461250e565b610a5a565b61038e61044d36600461245b565b610a7f565b61031361046036600461250e565b610ae4565b61038e610473366004612442565b610b1c565b6103136104863660046124d2565b610bab565b610313610499366004612442565b610bc6565b61038e600f5481565b61038e6104b5366004612442565b610bd2565b6103306104c83660046125bd565b610c2b565b6103136104db366004612606565b610d84565b6103506104ee366004612442565b610e0d565b61038e610501366004612442565b610e18565b610313610514366004612649565b610ea7565b610330610f91565b61038e61052f366004612442565b60136020526000908152604090205481565b61038e61054f36600461267c565b61101f565b6102eb61056236600461250e565b6000918252600c602090815260408084206001600160a01b0393909316845291905290205460ff1690565b610330611067565b6011546105a8906001600160601b031681565b6040516001600160601b0390911681526020016102f7565b61038e6105ce36600461245b565b611076565b61038e600081565b6103136105e9366004612697565b611114565b6105a86105fc3660046126c1565b61111f565b61031361060f3660046126dc565b611204565b610313610622366004612722565b61128b565b610330610635366004612442565b6112a2565b61038e600e5481565b61031361065136600461250e565b61137d565b6102eb61066436600461279e565b6001600160a01b03918216600090815260076020908152604080832093909416825291909152205460ff1690565b600061069d826113a2565b92915050565b3360009081527f13649b2456f1b42fef0f0040b3aaeabcd21a76a0f3f5defd4f583839455116e8602052604090205460ff166107265760405162461bcd60e51b815260206004820152601f60248201527f6b4e46542041636365737320436f6e74726f6c3a206f6e6c792061646d696e0060448201526064015b60405180910390fd5b61073082826113c7565b5050565b600f546000908152600c6020908152604080832033845290915290205460ff166107af5760405162461bcd60e51b815260206004820152602660248201527f6b4e46542041636365737320436f6e74726f6c3a206f6e6c7920646e61206d6f6044820152653234b334b2b960d11b606482015260840161071d565b610730828261146a565b6060600280546107c8906127c8565b80601f01602080910402602001604051908101604052809291908181526020018280546107f4906127c8565b80156108415780601f1061081657610100808354040283529160200191610841565b820191906000526020600020905b81548152906001019060200180831161082457829003601f168201915b5050505050905090565b6000610856826114bb565b506000828152600660205260409020546001600160a01b031661069d565b6107308282336114f4565b60008160ff168360ff1610801561089a575060208260ff1611155b6108d65760405162461bcd60e51b815260206004820152600d60248201526c496e76616c69642072616e676560981b604482015260640161071d565b60008481526012602052604081205490845b8460ff168160ff161015610919576008601f829003810284901c60ff168783039091021b91909117906001016108e8565b5095945050505050565b6001600160a01b03821661094d57604051633250574960e11b81526000600482015260240161071d565b600061095a838333611501565b9050836001600160a01b0316816001600160a01b0316146109a8576040516364283d7b60e01b81526001600160a01b038086166004830152602482018490528216604482015260640161071d565b50505050565b60008281526001602090815260408083208151808301909252546001600160a01b038116808352600160a01b9091046001600160601b0316928201929092528291610a235750604080518082019091526000546001600160a01b0381168252600160a01b90046001600160601b031660208201525b602081015160009061271090610a42906001600160601b031687612818565b610a4c919061282f565b915196919550909350505050565b6000828152600c6020526040902060010154610a7581611516565b6109a88383611523565b6000610a8a8361101f565b8210610abb5760405163295f44f760e21b81526001600160a01b03841660048201526024810183905260440161071d565b506001600160a01b03919091166000908152600860209081526040808320938352929052205490565b6001600160a01b0381163314610b0d5760405163334bd91960e11b815260040160405180910390fd5b610b1782826115d1565b505050565b6000818152600460205260408120546001600160a01b0316610b985760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b606482015260840161071d565b5060009081526012602052604090205490565b610b178383836040518060200160405280600081525061128b565b61073060008233611501565b6000610bdd600a5490565b8210610c065760405163295f44f760e21b8152600060048201526024810183905260440161071d565b600a8281548110610c1957610c19612851565b90600052602060002001549050919050565b3360009081527f13649b2456f1b42fef0f0040b3aaeabcd21a76a0f3f5defd4f583839455116e8602052604090205460609060ff16610cac5760405162461bcd60e51b815260206004820152601f60248201527f6b4e46542041636365737320436f6e74726f6c3a206f6e6c792061646d696e00604482015260640161071d565b6010610cb883826128b7565b507f5411e8ebf1636d9e83d5fc4900bf80cbac82e8790da2a4c94db4895e889eedf66010604051610ce99190612977565b60405180910390a160108054610cfe906127c8565b80601f0160208091040260200160405190810160405280929190818152602001828054610d2a906127c8565b8015610d775780601f10610d4c57610100808354040283529160200191610d77565b820191906000526020600020905b815481529060010190602001808311610d5a57829003601f168201915b505050505090505b919050565b3360009081527f13649b2456f1b42fef0f0040b3aaeabcd21a76a0f3f5defd4f583839455116e8602052604090205460ff16610e025760405162461bcd60e51b815260206004820152601f60248201527f6b4e46542041636365737320436f6e74726f6c3a206f6e6c792061646d696e00604482015260640161071d565b610b17838383611658565b600061069d826114bb565b6000818152600460205260408120546001600160a01b0316610e945760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b606482015260840161071d565b5060009081526013602052604090205490565b3360009081527f13649b2456f1b42fef0f0040b3aaeabcd21a76a0f3f5defd4f583839455116e8602052604090205460ff16610f255760405162461bcd60e51b815260206004820152601f60248201527f6b4e46542041636365737320436f6e74726f6c3a206f6e6c792061646d696e00604482015260640161071d565b8015610f3b57610f358383611523565b50610f47565b610f4583836115d1565b505b6040805184815282151560208201526001600160a01b038416917f0a3389242138f35e16a456882b75845c8c6b72970ed65963a34ec6f1cc9be603910160405180910390a2505050565b60108054610f9e906127c8565b80601f0160208091040260200160405190810160405280929190818152602001828054610fca906127c8565b80156110175780601f10610fec57610100808354040283529160200191611017565b820191906000526020600020905b815481529060010190602001808311610ffa57829003601f168201915b505050505081565b60006001600160a01b03821661104b576040516322718ad960e21b81526000600482015260240161071d565b506001600160a01b031660009081526005602052604090205490565b6060600380546107c8906127c8565b600e546000908152600c6020908152604080832033845290915281205460ff166110e25760405162461bcd60e51b815260206004820181905260248201527f6b4e46542041636365737320436f6e74726f6c3a206f6e6c79206d696e746572604482015260640161071d565b600d8054600091826110f383612a07565b919050559050611103818461146a565b61110d848261171a565b9392505050565b610730338383611734565b3360009081527f13649b2456f1b42fef0f0040b3aaeabcd21a76a0f3f5defd4f583839455116e8602052604081205460ff1661119d5760405162461bcd60e51b815260206004820152601f60248201527f6b4e46542041636365737320436f6e74726f6c3a206f6e6c792061646d696e00604482015260640161071d565b601180546bffffffffffffffffffffffff19166001600160601b0384169081179091556040519081527f601b85aa9305dbcfbfc81aa2d4b5126c1ce24afdd1bad47d6880e5b6df081f579060200160405180910390a150506011546001600160601b031690565b600f546000908152600c6020908152604080832033845290915290205460ff1661127f5760405162461bcd60e51b815260206004820152602660248201527f6b4e46542041636365737320436f6e74726f6c3a206f6e6c7920646e61206d6f6044820152653234b334b2b960d11b606482015260840161071d565b6109a8848484846117d3565b611296848484610923565b6109a88484848461198c565b6000818152600460205260409020546060906001600160a01b03166113215760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b606482015260840161071d565b600060108054611330906127c8565b90501161134c576040518060200160405280600081525061069d565b601061135783611ab5565b604051602001611368929190612a20565b60405160208183030381529060405292915050565b6000828152600c602052604090206001015461139881611516565b6109a883836115d1565b60006001600160e01b03198216637965db0b60e01b148061069d575061069d82611b55565b6127106001600160601b03821681101561140657604051636f483d0960e01b81526001600160601b03831660048201526024810182905260440161071d565b6001600160a01b03831661143057604051635b6cc80560e11b81526000600482015260240161071d565b50604080518082019091526001600160a01b039092168083526001600160601b039091166020909201829052600160a01b90910217600055565b600082815260126020526040908190208290555182907f4e26044f7fb3724a9375deb74974fdc2f4e07f265efce87f93cfced354258487906114af9084815260200190565b60405180910390a25050565b6000818152600460205260408120546001600160a01b03168061069d57604051637e27328960e01b81526004810184905260240161071d565b610b178383836001611b60565b600061150e848484611c92565b949350505050565b6115208133611d5f565b50565b6000828152600c602090815260408083206001600160a01b038516845290915281205460ff166115c9576000838152600c602090815260408083206001600160a01b03861684529091529020805460ff191660011790556115813390565b6001600160a01b0316826001600160a01b0316847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a450600161069d565b50600061069d565b6000828152600c602090815260408083206001600160a01b038516845290915281205460ff16156115c9576000838152600c602090815260408083206001600160a01b0386168085529252808320805460ff1916905551339286917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a450600161069d565b6127106001600160601b03821681101561169e5760405163dfd1fc1b60e01b8152600481018590526001600160601b03831660248201526044810182905260640161071d565b6001600160a01b0383166116cf57604051634b4f842960e11b8152600481018590526000602482015260440161071d565b506040805180820182526001600160a01b0393841681526001600160601b0392831660208083019182526000968752600190529190942093519051909116600160a01b029116179055565b610730828260405180602001604052806000815250611db4565b6001600160a01b03821661176657604051630b61174360e31b81526001600160a01b038316600482015260240161071d565b6001600160a01b03838116600081815260076020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b8060ff168260ff161080156117ec575060208160ff1611155b6118285760405162461bcd60e51b815260206004820152600d60248201526c496e76616c69642072616e676560981b604482015260640161071d565b600060016118368484612aa7565b611841906008612ac0565b60ff166001901b6118529190612ae3565b9050808411156118ca5760405162461bcd60e51b815260206004820152603060248201527f496e7075742076616c756520697320746f6f206c6172676520666f722074686560448201527f207370656369666965642072616e676500000000000000000000000000000000606482015260840161071d565b6000858152601260205260408120549080855b8560ff168160ff1610156119195760ff6008601f839003810282811b95909517948984039091028a901c909116901b91909117906001016118dd565b50600088815260126020908152604091829020841986168585161790819055825190815290810189905260ff8881168284015287166060820152905189917fe152bca267ba38f000682405e9883c60a372ace2d8f54ad39deebd5a33bb72ee919081900360800190a25050505050505050565b6001600160a01b0383163b156109a857604051630a85bd0160e11b81526001600160a01b0384169063150b7a02906119ce903390889087908790600401612af6565b6020604051808303816000875af1925050508015611a09575060408051601f3d908101601f19168201909252611a0691810190612b32565b60015b611a72573d808015611a37576040519150601f19603f3d011682016040523d82523d6000602084013e611a3c565b606091505b508051600003611a6a57604051633250574960e11b81526001600160a01b038516600482015260240161071d565b805181602001fd5b6001600160e01b03198116630a85bd0160e11b14611aae57604051633250574960e11b81526001600160a01b038516600482015260240161071d565b5050505050565b60606000611ac283611dcb565b600101905060008167ffffffffffffffff811115611ae257611ae2612531565b6040519080825280601f01601f191660200182016040528015611b0c576020820181803683370190505b5090508181016020015b600019017f3031323334353637383961626364656600000000000000000000000000000000600a86061a8153600a8504945084611b1657509392505050565b600061069d82611ead565b8080611b7457506001600160a01b03821615155b15611c55576000611b84846114bb565b90506001600160a01b03831615801590611bb05750826001600160a01b0316816001600160a01b031614155b8015611be257506001600160a01b0380821660009081526007602090815260408083209387168352929052205460ff16155b15611c0b5760405163a9fbf51f60e01b81526001600160a01b038416600482015260240161071d565b8115611c535783856001600160a01b0316826001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45b505b50506000908152600660205260409020805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b600080611ca0858585611ed2565b90506001600160a01b038116611cfd57611cf884600a80546000838152600b60205260408120829055600182018355919091527fc65a7bb8d6351c1cf70c95a316cc6a92839c986682d98bc35f958f4883f9d2a80155565b611d20565b846001600160a01b0316816001600160a01b031614611d2057611d208185611fd8565b6001600160a01b038516611d3c57611d3784612069565b61150e565b846001600160a01b0316816001600160a01b03161461150e5761150e8585612118565b6000828152600c602090815260408083206001600160a01b038516845290915290205460ff166107305760405163e2517d3f60e01b81526001600160a01b03821660048201526024810183905260440161071d565b611dbe8383612168565b610b17600084848461198c565b6000807a184f03e93ff9f4daa797ed6e38ed64bf6a1f0100000000000000008310611e14577a184f03e93ff9f4daa797ed6e38ed64bf6a1f010000000000000000830492506040015b6d04ee2d6d415b85acef81000000008310611e40576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc100008310611e5e57662386f26fc10000830492506010015b6305f5e1008310611e76576305f5e100830492506008015b6127108310611e8a57612710830492506004015b60648310611e9c576064830492506002015b600a831061069d5760010192915050565b60006001600160e01b0319821663780e9d6360e01b148061069d575061069d826121cd565b6000828152600460205260408120546001600160a01b0390811690831615611eff57611eff81848661220d565b6001600160a01b03811615611f3d57611f1c600085600080611b60565b6001600160a01b038116600090815260056020526040902080546000190190555b6001600160a01b03851615611f6c576001600160a01b0385166000908152600560205260409020805460010190555b600084815260046020526040808220805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0389811691821790925591518793918516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4949350505050565b6000611fe38361101f565b600083815260096020526040902054909150808214612036576001600160a01b03841660009081526008602090815260408083208584528252808320548484528184208190558352600990915290208190555b5060009182526009602090815260408084208490556001600160a01b039094168352600881528383209183525290812055565b600a5460009061207b90600190612ae3565b6000838152600b6020526040812054600a80549394509092849081106120a3576120a3612851565b9060005260206000200154905080600a83815481106120c4576120c4612851565b6000918252602080832090910192909255828152600b9091526040808220849055858252812055600a8054806120fc576120fc612b4f565b6001900381819060005260206000200160009055905550505050565b600060016121258461101f565b61212f9190612ae3565b6001600160a01b039093166000908152600860209081526040808320868452825280832085905593825260099052919091209190915550565b6001600160a01b03821661219257604051633250574960e11b81526000600482015260240161071d565b60006121a083836000611501565b90506001600160a01b03811615610b17576040516339e3563760e11b81526000600482015260240161071d565b60006001600160e01b031982166380ac58cd60e01b14806121fe57506001600160e01b03198216635b5e139f60e01b145b8061069d575061069d82612271565b6122188383836122a6565b610b17576001600160a01b03831661224657604051637e27328960e01b81526004810182905260240161071d565b60405163177e802f60e01b81526001600160a01b03831660048201526024810182905260440161071d565b60006001600160e01b0319821663152a902d60e11b148061069d57506301ffc9a760e01b6001600160e01b031983161461069d565b60006001600160a01b0383161580159061150e5750826001600160a01b0316846001600160a01b0316148061230057506001600160a01b0380851660009081526007602090815260408083209387168352929052205460ff165b8061150e5750506000908152600660205260409020546001600160a01b03908116911614919050565b6001600160e01b03198116811461152057600080fd5b60006020828403121561235157600080fd5b813561110d81612329565b80356001600160a01b0381168114610d7f57600080fd5b80356001600160601b0381168114610d7f57600080fd5b6000806040838503121561239d57600080fd5b6123a68361235c565b91506123b460208401612373565b90509250929050565b600080604083850312156123d057600080fd5b50508035926020909101359150565b60005b838110156123fa5781810151838201526020016123e2565b50506000910152565b6000815180845261241b8160208601602086016123df565b601f01601f19169290920160200192915050565b60208152600061110d6020830184612403565b60006020828403121561245457600080fd5b5035919050565b6000806040838503121561246e57600080fd5b6124778361235c565b946020939093013593505050565b803560ff81168114610d7f57600080fd5b6000806000606084860312156124ab57600080fd5b833592506124bb60208501612485565b91506124c960408501612485565b90509250925092565b6000806000606084860312156124e757600080fd5b6124f08461235c565b92506124fe6020850161235c565b9150604084013590509250925092565b6000806040838503121561252157600080fd5b823591506123b46020840161235c565b634e487b7160e01b600052604160045260246000fd5b600067ffffffffffffffff8084111561256257612562612531565b604051601f8501601f19908116603f0116810190828211818310171561258a5761258a612531565b816040528093508581528686860111156125a357600080fd5b858560208301376000602087830101525050509392505050565b6000602082840312156125cf57600080fd5b813567ffffffffffffffff8111156125e657600080fd5b8201601f810184136125f757600080fd5b61150e84823560208401612547565b60008060006060848603121561261b57600080fd5b8335925061262b6020850161235c565b91506124c960408501612373565b80358015158114610d7f57600080fd5b60008060006060848603121561265e57600080fd5b8335925061266e6020850161235c565b91506124c960408501612639565b60006020828403121561268e57600080fd5b61110d8261235c565b600080604083850312156126aa57600080fd5b6126b38361235c565b91506123b460208401612639565b6000602082840312156126d357600080fd5b61110d82612373565b600080600080608085870312156126f257600080fd5b843593506020850135925061270960408601612485565b915061271760608601612485565b905092959194509250565b6000806000806080858703121561273857600080fd5b6127418561235c565b935061274f6020860161235c565b925060408501359150606085013567ffffffffffffffff81111561277257600080fd5b8501601f8101871361278357600080fd5b61279287823560208401612547565b91505092959194509250565b600080604083850312156127b157600080fd5b6127ba8361235c565b91506123b46020840161235c565b600181811c908216806127dc57607f821691505b6020821081036127fc57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b808202811582820484141761069d5761069d612802565b60008261284c57634e487b7160e01b600052601260045260246000fd5b500490565b634e487b7160e01b600052603260045260246000fd5b601f821115610b17576000816000526020600020601f850160051c810160208610156128905750805b601f850160051c820191505b818110156128af5782815560010161289c565b505050505050565b815167ffffffffffffffff8111156128d1576128d1612531565b6128e5816128df84546127c8565b84612867565b602080601f83116001811461291a57600084156129025750858301515b600019600386901b1c1916600185901b1785556128af565b600085815260208120601f198616915b828110156129495788860151825594840194600190910190840161292a565b50858210156129675787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b600060208083526000845461298b816127c8565b80602087015260406001808416600081146129ad57600181146129c9576129f9565b60ff19851660408a0152604084151560051b8a010195506129f9565b89600052602060002060005b858110156129f05781548b82018601529083019088016129d5565b8a016040019650505b509398975050505050505050565b600060018201612a1957612a19612802565b5060010190565b6000808454612a2e816127c8565b60018281168015612a465760018114612a5b57612a8a565b60ff1984168752821515830287019450612a8a565b8860005260208060002060005b85811015612a815781548a820152908401908201612a68565b50505082870194505b505050508351612a9e8183602088016123df565b01949350505050565b60ff828116828216039081111561069d5761069d612802565b60ff8181168382160290811690818114612adc57612adc612802565b5092915050565b8181038181111561069d5761069d612802565b60006001600160a01b03808716835280861660208401525083604083015260806060830152612b286080830184612403565b9695505050505050565b600060208284031215612b4457600080fd5b815161110d81612329565b634e487b7160e01b600052603160045260246000fdfea164736f6c6343000817000a

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

00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000b4b6f6e647578206b4e465400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044b4e465400000000000000000000000000000000000000000000000000000000

-----Decoded View---------------
Arg [0] : _name (string): Kondux kNFT
Arg [1] : _symbol (string): KNFT

-----Encoded View---------------
6 Constructor Arguments found :
Arg [0] : 0000000000000000000000000000000000000000000000000000000000000040
Arg [1] : 0000000000000000000000000000000000000000000000000000000000000080
Arg [2] : 000000000000000000000000000000000000000000000000000000000000000b
Arg [3] : 4b6f6e647578206b4e4654000000000000000000000000000000000000000000
Arg [4] : 0000000000000000000000000000000000000000000000000000000000000004
Arg [5] : 4b4e465400000000000000000000000000000000000000000000000000000000


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

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