APE Price: $1.17 (+7.45%)

Contract

0x04828e5786c6fee6222Fa61c61D6C68D59f62e9A

Overview

APE Balance

Apechain LogoApechain LogoApechain Logo0 APE

APE Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
0x6080604047670502024-11-20 13:49:5126 hrs ago1732110591IN
 Create: RandomMint721
0 APE0.0607193225.42069

Parent Transaction Hash Block From To
View All Internal Transactions

Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
RandomMint721

Compiler Version
v0.8.24+commit.e11b9ed9

Optimization Enabled:
No with 200 runs

Other Settings:
paris EvmVersion
File 1 of 46 : RandomMint721.sol
// SPDX-License-Identifier: MIT
// @author: Buildtree - Powered by NFT Studios

pragma solidity ^0.8.18;

import {IERC721Mintable} from "./../interfaces/IERC721Mintable.sol";
import {Payable} from "./../libraries/Payable.sol";
import {SupplyControl} from "./../libraries/SupplyControl.sol";
import {LimitPerWallet} from "./../libraries/LimitPerWallet.sol";
import {SignatureProtected} from "./../libraries/SignatureProtected.sol";
import {DTOs} from "./../libraries/dtos.sol";
import {RandomGenerator} from "./../libraries/RandomGenerator.sol";

contract RandomMint721 is
    Payable,
    SupplyControl,
    LimitPerWallet,
    SignatureProtected,
    RandomGenerator
{
    mapping(uint256 => uint256) private tokenMatrix;
    string public constant contractType = "RANDOM-MINTER-721";
    string public constant version = "1.0.0";

    IERC721Mintable public erc721Contract;

    bool private _isInitialized;

    function init(
        address owner,
        uint256 maxSupply,
        address signerAddress,
        address feeRecipient,
        DTOs.Recipient[] memory recipients,
        address erc721Address
    ) external {
        require(_isInitialized == false, "Contract already initialized.");
        _transferOwnership(owner);
        initSupplyControl(maxSupply);
        initSignatureProtected(signerAddress);
        initPayable(feeRecipient, recipients);

        erc721Contract = IERC721Mintable(erc721Address);
        _isInitialized = true;
    }

    function mint(
        uint256 _amount,
        uint256 _maxPerWallet,
        uint256 _pricePerToken,
        uint256 _feePerToken,
        bytes calldata _signature
    ) external payable {
        validateSignature(
            abi.encodePacked(_maxPerWallet, _pricePerToken, _feePerToken),
            _signature
        );

        uint256 totalMinted = erc721Contract.totalMinted();
        _amount = _getAvailableTokens(_amount, totalMinted);
        _amount = getAvailableForWallet(_amount, _maxPerWallet);

        checkSentEther(_amount, _pricePerToken, _feePerToken);

        uint256[] memory ids = new uint256[](_amount);
        for (uint256 i; i < ids.length; i++) {
            ids[i] = getTokenToBeMinted(totalMinted + i, maxSupply);
        }

        erc721Contract.mint(msg.sender, ids);
    }

    function getAvailableTokens() public view returns (uint256) {
        (bool success, bytes memory totalSupply) = address(erc721Contract)
            .staticcall(abi.encodeWithSignature("totalMinted()"));

        require(success, "Call to totalSupply failed");

        return maxSupply - abi.decode(totalSupply, (uint256));
    }

    /**
     * @dev Returns a random available token to be minted
     */
    function getTokenToBeMinted(
        uint256 _totalSupply,
        uint256 _maxSupply
    ) internal returns (uint256) {
        uint256 maxIndex = _maxSupply - _totalSupply;
        uint256 random = getRandomNumber(maxIndex, _totalSupply);

        uint256 tokenId = tokenMatrix[random];
        if (tokenMatrix[random] == 0) {
            tokenId = random;
        }

        tokenMatrix[maxIndex - 1] == 0
            ? tokenMatrix[random] = maxIndex - 1
            : tokenMatrix[random] = tokenMatrix[maxIndex - 1];

        return tokenId;
    }
}

File 2 of 46 : 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 3 of 46 : 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 4 of 46 : Ownable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)

pragma solidity ^0.8.20;

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

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

    /**
     * @dev The caller account is not authorized to perform an operation.
     */
    error OwnableUnauthorizedAccount(address account);

    /**
     * @dev The owner is not a valid owner account. (eg. `address(0)`)
     */
    error OwnableInvalidOwner(address owner);

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

    /**
     * @dev Initializes the contract setting the address provided by the deployer as the initial owner.
     */
    constructor(address initialOwner) {
        if (initialOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(initialOwner);
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

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

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        if (owner() != _msgSender()) {
            revert OwnableUnauthorizedAccount(_msgSender());
        }
    }

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

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        if (newOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(newOwner);
    }

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

File 5 of 46 : 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 6 of 46 : 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 7 of 46 : Clones.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/Clones.sol)

pragma solidity ^0.8.20;

/**
 * @dev https://eips.ethereum.org/EIPS/eip-1167[EIP 1167] is a standard for
 * deploying minimal proxy contracts, also known as "clones".
 *
 * > To simply and cheaply clone contract functionality in an immutable way, this standard specifies
 * > a minimal bytecode implementation that delegates all calls to a known, fixed address.
 *
 * The library includes functions to deploy a proxy using either `create` (traditional deployment) or `create2`
 * (salted deterministic deployment). It also includes functions to predict the addresses of clones deployed using the
 * deterministic method.
 */
library Clones {
    /**
     * @dev A clone instance deployment failed.
     */
    error ERC1167FailedCreateClone();

    /**
     * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`.
     *
     * This function uses the create opcode, which should never revert.
     */
    function clone(address implementation) internal returns (address instance) {
        /// @solidity memory-safe-assembly
        assembly {
            // Cleans the upper 96 bits of the `implementation` word, then packs the first 3 bytes
            // of the `implementation` address with the bytecode before the address.
            mstore(0x00, or(shr(0xe8, shl(0x60, implementation)), 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000))
            // Packs the remaining 17 bytes of `implementation` with the bytecode after the address.
            mstore(0x20, or(shl(0x78, implementation), 0x5af43d82803e903d91602b57fd5bf3))
            instance := create(0, 0x09, 0x37)
        }
        if (instance == address(0)) {
            revert ERC1167FailedCreateClone();
        }
    }

    /**
     * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`.
     *
     * This function uses the create2 opcode and a `salt` to deterministically deploy
     * the clone. Using the same `implementation` and `salt` multiple time will revert, since
     * the clones cannot be deployed twice at the same address.
     */
    function cloneDeterministic(address implementation, bytes32 salt) internal returns (address instance) {
        /// @solidity memory-safe-assembly
        assembly {
            // Cleans the upper 96 bits of the `implementation` word, then packs the first 3 bytes
            // of the `implementation` address with the bytecode before the address.
            mstore(0x00, or(shr(0xe8, shl(0x60, implementation)), 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000))
            // Packs the remaining 17 bytes of `implementation` with the bytecode after the address.
            mstore(0x20, or(shl(0x78, implementation), 0x5af43d82803e903d91602b57fd5bf3))
            instance := create2(0, 0x09, 0x37, salt)
        }
        if (instance == address(0)) {
            revert ERC1167FailedCreateClone();
        }
    }

    /**
     * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.
     */
    function predictDeterministicAddress(
        address implementation,
        bytes32 salt,
        address deployer
    ) internal pure returns (address predicted) {
        /// @solidity memory-safe-assembly
        assembly {
            let ptr := mload(0x40)
            mstore(add(ptr, 0x38), deployer)
            mstore(add(ptr, 0x24), 0x5af43d82803e903d91602b57fd5bf3ff)
            mstore(add(ptr, 0x14), implementation)
            mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73)
            mstore(add(ptr, 0x58), salt)
            mstore(add(ptr, 0x78), keccak256(add(ptr, 0x0c), 0x37))
            predicted := keccak256(add(ptr, 0x43), 0x55)
        }
    }

    /**
     * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.
     */
    function predictDeterministicAddress(
        address implementation,
        bytes32 salt
    ) internal view returns (address predicted) {
        return predictDeterministicAddress(implementation, salt, address(this));
    }
}

File 8 of 46 : 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 9 of 46 : ERC1155.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC1155/ERC1155.sol)

pragma solidity ^0.8.20;

import {IERC1155} from "./IERC1155.sol";
import {IERC1155Receiver} from "./IERC1155Receiver.sol";
import {IERC1155MetadataURI} from "./extensions/IERC1155MetadataURI.sol";
import {Context} from "../../utils/Context.sol";
import {IERC165, ERC165} from "../../utils/introspection/ERC165.sol";
import {Arrays} from "../../utils/Arrays.sol";
import {IERC1155Errors} from "../../interfaces/draft-IERC6093.sol";

/**
 * @dev Implementation of the basic standard multi-token.
 * See https://eips.ethereum.org/EIPS/eip-1155
 * Originally based on code by Enjin: https://github.com/enjin/erc-1155
 */
abstract contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI, IERC1155Errors {
    using Arrays for uint256[];
    using Arrays for address[];

    mapping(uint256 id => mapping(address account => uint256)) private _balances;

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

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

    /**
     * @dev See {_setURI}.
     */
    constructor(string memory uri_) {
        _setURI(uri_);
    }

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

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

    /**
     * @dev See {IERC1155-balanceOf}.
     */
    function balanceOf(address account, uint256 id) public view virtual returns (uint256) {
        return _balances[id][account];
    }

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

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

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

        return batchBalances;
    }

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

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

    /**
     * @dev See {IERC1155-safeTransferFrom}.
     */
    function safeTransferFrom(address from, address to, uint256 id, uint256 value, bytes memory data) public virtual {
        address sender = _msgSender();
        if (from != sender && !isApprovedForAll(from, sender)) {
            revert ERC1155MissingApprovalForAll(sender, from);
        }
        _safeTransferFrom(from, to, id, value, data);
    }

    /**
     * @dev See {IERC1155-safeBatchTransferFrom}.
     */
    function safeBatchTransferFrom(
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory values,
        bytes memory data
    ) public virtual {
        address sender = _msgSender();
        if (from != sender && !isApprovedForAll(from, sender)) {
            revert ERC1155MissingApprovalForAll(sender, from);
        }
        _safeBatchTransferFrom(from, to, ids, values, data);
    }

    /**
     * @dev Transfers a `value` amount of tokens of type `id` from `from` to `to`. Will mint (or burn) if `from`
     * (or `to`) is the zero address.
     *
     * Emits a {TransferSingle} event if the arrays contain one element, and {TransferBatch} otherwise.
     *
     * Requirements:
     *
     * - If `to` refers to a smart contract, it must implement either {IERC1155Receiver-onERC1155Received}
     *   or {IERC1155Receiver-onERC1155BatchReceived} and return the acceptance magic value.
     * - `ids` and `values` must have the same length.
     *
     * NOTE: The ERC-1155 acceptance check is not performed in this function. See {_updateWithAcceptanceCheck} instead.
     */
    function _update(address from, address to, uint256[] memory ids, uint256[] memory values) internal virtual {
        if (ids.length != values.length) {
            revert ERC1155InvalidArrayLength(ids.length, values.length);
        }

        address operator = _msgSender();

        for (uint256 i = 0; i < ids.length; ++i) {
            uint256 id = ids.unsafeMemoryAccess(i);
            uint256 value = values.unsafeMemoryAccess(i);

            if (from != address(0)) {
                uint256 fromBalance = _balances[id][from];
                if (fromBalance < value) {
                    revert ERC1155InsufficientBalance(from, fromBalance, value, id);
                }
                unchecked {
                    // Overflow not possible: value <= fromBalance
                    _balances[id][from] = fromBalance - value;
                }
            }

            if (to != address(0)) {
                _balances[id][to] += value;
            }
        }

        if (ids.length == 1) {
            uint256 id = ids.unsafeMemoryAccess(0);
            uint256 value = values.unsafeMemoryAccess(0);
            emit TransferSingle(operator, from, to, id, value);
        } else {
            emit TransferBatch(operator, from, to, ids, values);
        }
    }

    /**
     * @dev Version of {_update} that performs the token acceptance check by calling
     * {IERC1155Receiver-onERC1155Received} or {IERC1155Receiver-onERC1155BatchReceived} on the receiver address if it
     * contains code (eg. is a smart contract at the moment of execution).
     *
     * IMPORTANT: Overriding this function is discouraged because it poses a reentrancy risk from the receiver. So any
     * update to the contract state after this function would break the check-effect-interaction pattern. Consider
     * overriding {_update} instead.
     */
    function _updateWithAcceptanceCheck(
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory values,
        bytes memory data
    ) internal virtual {
        _update(from, to, ids, values);
        if (to != address(0)) {
            address operator = _msgSender();
            if (ids.length == 1) {
                uint256 id = ids.unsafeMemoryAccess(0);
                uint256 value = values.unsafeMemoryAccess(0);
                _doSafeTransferAcceptanceCheck(operator, from, to, id, value, data);
            } else {
                _doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, values, data);
            }
        }
    }

    /**
     * @dev Transfers a `value` tokens of token type `id` from `from` to `to`.
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - `from` must have a balance of tokens of type `id` of at least `value` amount.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
     * acceptance magic value.
     */
    function _safeTransferFrom(address from, address to, uint256 id, uint256 value, bytes memory data) internal {
        if (to == address(0)) {
            revert ERC1155InvalidReceiver(address(0));
        }
        if (from == address(0)) {
            revert ERC1155InvalidSender(address(0));
        }
        (uint256[] memory ids, uint256[] memory values) = _asSingletonArrays(id, value);
        _updateWithAcceptanceCheck(from, to, ids, values, data);
    }

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_safeTransferFrom}.
     *
     * Emits a {TransferBatch} event.
     *
     * Requirements:
     *
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
     * acceptance magic value.
     * - `ids` and `values` must have the same length.
     */
    function _safeBatchTransferFrom(
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory values,
        bytes memory data
    ) internal {
        if (to == address(0)) {
            revert ERC1155InvalidReceiver(address(0));
        }
        if (from == address(0)) {
            revert ERC1155InvalidSender(address(0));
        }
        _updateWithAcceptanceCheck(from, to, ids, values, data);
    }

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

    /**
     * @dev Creates a `value` amount of tokens of type `id`, and assigns them to `to`.
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
     * acceptance magic value.
     */
    function _mint(address to, uint256 id, uint256 value, bytes memory data) internal {
        if (to == address(0)) {
            revert ERC1155InvalidReceiver(address(0));
        }
        (uint256[] memory ids, uint256[] memory values) = _asSingletonArrays(id, value);
        _updateWithAcceptanceCheck(address(0), to, ids, values, data);
    }

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

    /**
     * @dev Destroys a `value` amount of tokens of type `id` from `from`
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `from` must have at least `value` amount of tokens of type `id`.
     */
    function _burn(address from, uint256 id, uint256 value) internal {
        if (from == address(0)) {
            revert ERC1155InvalidSender(address(0));
        }
        (uint256[] memory ids, uint256[] memory values) = _asSingletonArrays(id, value);
        _updateWithAcceptanceCheck(from, address(0), ids, values, "");
    }

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}.
     *
     * Emits a {TransferBatch} event.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `from` must have at least `value` amount of tokens of type `id`.
     * - `ids` and `values` must have the same length.
     */
    function _burnBatch(address from, uint256[] memory ids, uint256[] memory values) internal {
        if (from == address(0)) {
            revert ERC1155InvalidSender(address(0));
        }
        _updateWithAcceptanceCheck(from, address(0), ids, values, "");
    }

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

    /**
     * @dev Performs an acceptance check by calling {IERC1155-onERC1155Received} on the `to` address
     * if it contains code at the moment of execution.
     */
    function _doSafeTransferAcceptanceCheck(
        address operator,
        address from,
        address to,
        uint256 id,
        uint256 value,
        bytes memory data
    ) private {
        if (to.code.length > 0) {
            try IERC1155Receiver(to).onERC1155Received(operator, from, id, value, data) returns (bytes4 response) {
                if (response != IERC1155Receiver.onERC1155Received.selector) {
                    // Tokens rejected
                    revert ERC1155InvalidReceiver(to);
                }
            } catch (bytes memory reason) {
                if (reason.length == 0) {
                    // non-ERC1155Receiver implementer
                    revert ERC1155InvalidReceiver(to);
                } else {
                    /// @solidity memory-safe-assembly
                    assembly {
                        revert(add(32, reason), mload(reason))
                    }
                }
            }
        }
    }

    /**
     * @dev Performs a batch acceptance check by calling {IERC1155-onERC1155BatchReceived} on the `to` address
     * if it contains code at the moment of execution.
     */
    function _doSafeBatchTransferAcceptanceCheck(
        address operator,
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory values,
        bytes memory data
    ) private {
        if (to.code.length > 0) {
            try IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, values, data) returns (
                bytes4 response
            ) {
                if (response != IERC1155Receiver.onERC1155BatchReceived.selector) {
                    // Tokens rejected
                    revert ERC1155InvalidReceiver(to);
                }
            } catch (bytes memory reason) {
                if (reason.length == 0) {
                    // non-ERC1155Receiver implementer
                    revert ERC1155InvalidReceiver(to);
                } else {
                    /// @solidity memory-safe-assembly
                    assembly {
                        revert(add(32, reason), mload(reason))
                    }
                }
            }
        }
    }

    /**
     * @dev Creates an array in memory with only one value for each of the elements provided.
     */
    function _asSingletonArrays(
        uint256 element1,
        uint256 element2
    ) private pure returns (uint256[] memory array1, uint256[] memory array2) {
        /// @solidity memory-safe-assembly
        assembly {
            // Load the free memory pointer
            array1 := mload(0x40)
            // Set array length to 1
            mstore(array1, 1)
            // Store the single element at the next word after the length (where content starts)
            mstore(add(array1, 0x20), element1)

            // Repeat for next array locating it right after the first array
            array2 := add(array1, 0x40)
            mstore(array2, 1)
            mstore(add(array2, 0x20), element2)

            // Update the free memory pointer by pointing after the second array
            mstore(0x40, add(array2, 0x40))
        }
    }
}

File 10 of 46 : IERC1155MetadataURI.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC1155/extensions/IERC1155MetadataURI.sol)

pragma solidity ^0.8.20;

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

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

File 11 of 46 : IERC1155.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (token/ERC1155/IERC1155.sol)

pragma solidity ^0.8.20;

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

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

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

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

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

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

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

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

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

    /**
     * @dev Transfers a `value` amount of tokens of type `id` from `from` to `to`.
     *
     * WARNING: This function can potentially allow a reentrancy attack when transferring tokens
     * to an untrusted contract, when invoking {onERC1155Received} on the receiver.
     * Ensure to follow the checks-effects-interactions pattern and consider employing
     * reentrancy guards when interacting with untrusted contracts.
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}.
     * - `from` must have a balance of tokens of type `id` of at least `value` amount.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
     * acceptance magic value.
     */
    function safeTransferFrom(address from, address to, uint256 id, uint256 value, bytes calldata data) external;

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
     *
     * WARNING: This function can potentially allow a reentrancy attack when transferring tokens
     * to an untrusted contract, when invoking {onERC1155BatchReceived} on the receiver.
     * Ensure to follow the checks-effects-interactions pattern and consider employing
     * reentrancy guards when interacting with untrusted contracts.
     *
     * Emits either a {TransferSingle} or a {TransferBatch} event, depending on the length of the array arguments.
     *
     * Requirements:
     *
     * - `ids` and `values` must have the same length.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
     * acceptance magic value.
     */
    function safeBatchTransferFrom(
        address from,
        address to,
        uint256[] calldata ids,
        uint256[] calldata values,
        bytes calldata data
    ) external;
}

File 12 of 46 : IERC1155Receiver.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC1155/IERC1155Receiver.sol)

pragma solidity ^0.8.20;

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

/**
 * @dev Interface that must be implemented by smart contracts in order to receive
 * ERC-1155 token transfers.
 */
interface IERC1155Receiver is IERC165 {
    /**
     * @dev Handles the receipt of a single ERC1155 token type. This function is
     * called at the end of a `safeTransferFrom` after the balance has been updated.
     *
     * NOTE: To accept the transfer, this must return
     * `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))`
     * (i.e. 0xf23a6e61, or its own function selector).
     *
     * @param operator The address which initiated the transfer (i.e. msg.sender)
     * @param from The address which previously owned the token
     * @param id The ID of the token being transferred
     * @param value The amount of tokens being transferred
     * @param data Additional data with no specified format
     * @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed
     */
    function onERC1155Received(
        address operator,
        address from,
        uint256 id,
        uint256 value,
        bytes calldata data
    ) external returns (bytes4);

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

File 13 of 46 : 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 14 of 46 : 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 15 of 46 : 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 16 of 46 : 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 17 of 46 : Arrays.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Arrays.sol)

pragma solidity ^0.8.20;

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

/**
 * @dev Collection of functions related to array types.
 */
library Arrays {
    using StorageSlot for bytes32;

    /**
     * @dev Searches a sorted `array` and returns the first index that contains
     * a value greater or equal to `element`. If no such index exists (i.e. all
     * values in the array are strictly less than `element`), the array length is
     * returned. Time complexity O(log n).
     *
     * `array` is expected to be sorted in ascending order, and to contain no
     * repeated elements.
     */
    function findUpperBound(uint256[] storage array, uint256 element) internal view returns (uint256) {
        uint256 low = 0;
        uint256 high = array.length;

        if (high == 0) {
            return 0;
        }

        while (low < high) {
            uint256 mid = Math.average(low, high);

            // Note that mid will always be strictly less than high (i.e. it will be a valid array index)
            // because Math.average rounds towards zero (it does integer division with truncation).
            if (unsafeAccess(array, mid).value > element) {
                high = mid;
            } else {
                low = mid + 1;
            }
        }

        // At this point `low` is the exclusive upper bound. We will return the inclusive upper bound.
        if (low > 0 && unsafeAccess(array, low - 1).value == element) {
            return low - 1;
        } else {
            return low;
        }
    }

    /**
     * @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
     *
     * WARNING: Only use if you are certain `pos` is lower than the array length.
     */
    function unsafeAccess(address[] storage arr, uint256 pos) internal pure returns (StorageSlot.AddressSlot storage) {
        bytes32 slot;
        // We use assembly to calculate the storage slot of the element at index `pos` of the dynamic array `arr`
        // following https://docs.soliditylang.org/en/v0.8.20/internals/layout_in_storage.html#mappings-and-dynamic-arrays.

        /// @solidity memory-safe-assembly
        assembly {
            mstore(0, arr.slot)
            slot := add(keccak256(0, 0x20), pos)
        }
        return slot.getAddressSlot();
    }

    /**
     * @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
     *
     * WARNING: Only use if you are certain `pos` is lower than the array length.
     */
    function unsafeAccess(bytes32[] storage arr, uint256 pos) internal pure returns (StorageSlot.Bytes32Slot storage) {
        bytes32 slot;
        // We use assembly to calculate the storage slot of the element at index `pos` of the dynamic array `arr`
        // following https://docs.soliditylang.org/en/v0.8.20/internals/layout_in_storage.html#mappings-and-dynamic-arrays.

        /// @solidity memory-safe-assembly
        assembly {
            mstore(0, arr.slot)
            slot := add(keccak256(0, 0x20), pos)
        }
        return slot.getBytes32Slot();
    }

    /**
     * @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
     *
     * WARNING: Only use if you are certain `pos` is lower than the array length.
     */
    function unsafeAccess(uint256[] storage arr, uint256 pos) internal pure returns (StorageSlot.Uint256Slot storage) {
        bytes32 slot;
        // We use assembly to calculate the storage slot of the element at index `pos` of the dynamic array `arr`
        // following https://docs.soliditylang.org/en/v0.8.20/internals/layout_in_storage.html#mappings-and-dynamic-arrays.

        /// @solidity memory-safe-assembly
        assembly {
            mstore(0, arr.slot)
            slot := add(keccak256(0, 0x20), pos)
        }
        return slot.getUint256Slot();
    }

    /**
     * @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
     *
     * WARNING: Only use if you are certain `pos` is lower than the array length.
     */
    function unsafeMemoryAccess(uint256[] memory arr, uint256 pos) internal pure returns (uint256 res) {
        assembly {
            res := mload(add(add(arr, 0x20), mul(pos, 0x20)))
        }
    }

    /**
     * @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
     *
     * WARNING: Only use if you are certain `pos` is lower than the array length.
     */
    function unsafeMemoryAccess(address[] memory arr, uint256 pos) internal pure returns (address res) {
        assembly {
            res := mload(add(add(arr, 0x20), mul(pos, 0x20)))
        }
    }
}

File 18 of 46 : 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 19 of 46 : ECDSA.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/ECDSA.sol)

pragma solidity ^0.8.20;

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

    /**
     * @dev The signature derives the `address(0)`.
     */
    error ECDSAInvalidSignature();

    /**
     * @dev The signature has an invalid length.
     */
    error ECDSAInvalidSignatureLength(uint256 length);

    /**
     * @dev The signature has an S value that is in the upper half order.
     */
    error ECDSAInvalidSignatureS(bytes32 s);

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with `signature` or an error. This will not
     * return address(0) without also returning an error description. Errors are documented using an enum (error type)
     * and a bytes32 providing additional information about the error.
     *
     * If no error is returned, then the address can be used for verification purposes.
     *
     * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.
     *
     * Documentation for signature generation:
     * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
     * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
     */
    function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError, bytes32) {
        if (signature.length == 65) {
            bytes32 r;
            bytes32 s;
            uint8 v;
            // ecrecover takes the signature parameters, and the only way to get them
            // currently is to use assembly.
            /// @solidity memory-safe-assembly
            assembly {
                r := mload(add(signature, 0x20))
                s := mload(add(signature, 0x40))
                v := byte(0, mload(add(signature, 0x60)))
            }
            return tryRecover(hash, v, r, s);
        } else {
            return (address(0), RecoverError.InvalidSignatureLength, bytes32(signature.length));
        }
    }

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

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
     *
     * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
     */
    function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError, bytes32) {
        unchecked {
            bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
            // We do not check for an overflow here since the shift operation results in 0 or 1.
            uint8 v = uint8((uint256(vs) >> 255) + 27);
            return tryRecover(hash, v, r, s);
        }
    }

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

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

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

        return (signer, RecoverError.NoError, bytes32(0));
    }

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

    /**
     * @dev Optionally reverts with the corresponding custom error according to the `error` argument provided.
     */
    function _throwError(RecoverError error, bytes32 errorArg) private pure {
        if (error == RecoverError.NoError) {
            return; // no error: do nothing
        } else if (error == RecoverError.InvalidSignature) {
            revert ECDSAInvalidSignature();
        } else if (error == RecoverError.InvalidSignatureLength) {
            revert ECDSAInvalidSignatureLength(uint256(errorArg));
        } else if (error == RecoverError.InvalidSignatureS) {
            revert ECDSAInvalidSignatureS(errorArg);
        }
    }
}

File 20 of 46 : 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 21 of 46 : 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 22 of 46 : 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 23 of 46 : 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 24 of 46 : StorageSlot.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/StorageSlot.sol)
// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.

pragma solidity ^0.8.20;

/**
 * @dev Library for reading and writing primitive types to specific storage slots.
 *
 * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
 * This library helps with reading and writing to such slots without the need for inline assembly.
 *
 * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
 *
 * Example usage to set ERC1967 implementation slot:
 * ```solidity
 * contract ERC1967 {
 *     bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
 *
 *     function _getImplementation() internal view returns (address) {
 *         return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
 *     }
 *
 *     function _setImplementation(address newImplementation) internal {
 *         require(newImplementation.code.length > 0);
 *         StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
 *     }
 * }
 * ```
 */
library StorageSlot {
    struct AddressSlot {
        address value;
    }

    struct BooleanSlot {
        bool value;
    }

    struct Bytes32Slot {
        bytes32 value;
    }

    struct Uint256Slot {
        uint256 value;
    }

    struct StringSlot {
        string value;
    }

    struct BytesSlot {
        bytes value;
    }

    /**
     * @dev Returns an `AddressSlot` with member `value` located at `slot`.
     */
    function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `BooleanSlot` with member `value` located at `slot`.
     */
    function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
     */
    function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `Uint256Slot` with member `value` located at `slot`.
     */
    function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `StringSlot` with member `value` located at `slot`.
     */
    function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `StringSlot` representation of the string storage pointer `store`.
     */
    function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := store.slot
        }
    }

    /**
     * @dev Returns an `BytesSlot` with member `value` located at `slot`.
     */
    function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.
     */
    function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := store.slot
        }
    }
}

File 25 of 46 : 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 26 of 46 : ERC1155ProxyFactory.sol
// SPDX-License-Identifier: MIT
// @author: Buildtree - Powered by NFT Studios

pragma solidity ^0.8.18;

import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";
import {DTOs} from "./../libraries/dtos.sol";
import {SignatureProtected} from "./../libraries/SignatureProtected.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

interface IERC1155 {
    function init(
        address owner,
        uint96 royalty,
        string memory name,
        string memory symbol,
        bool transferLocked,
        address metadataResolver
    ) external;

    function addMinter(address minter) external;

    function transferOwnership(address owner) external;

    function owner() external returns (address);
}

interface IMinter {
    function init(
        address owner,
        address signerAddress,
        address feeRecipient,
        uint256[] memory availableTokens,
        DTOs.Recipient[] memory recipients,
        address erc1155Address
    ) external;
}

interface IMetadataResolver {
    function setBaseURI(address _address, string memory _baseURI) external;
}

contract ERC1155ProxyFactory is Ownable, SignatureProtected {
    address public paymentRecipient;
    address public erc1155Address;
    mapping(string => address) allowedMinters;
    string public metadataBaseUrl;
    IMetadataResolver public metadataResolver;

    event NewContract(
        string indexed iuuid,
        string uuid,
        address token,
        address minter,
        uint256[] extras
    );

    constructor(
        address _erc1155Address,
        string memory _metadataBaseUrl,
        address _metadataResolverAddress,
        address _signerAddress,
        address _paymentRecipient
    ) {
        paymentRecipient = _paymentRecipient;
        erc1155Address = _erc1155Address;
        metadataBaseUrl = _metadataBaseUrl;
        metadataResolver = IMetadataResolver(_metadataResolverAddress);
        initSignatureProtected(_signerAddress);
    }

    // Only Owner
    function setERC721Address(address _erc1155Address) external onlyOwner {
        erc1155Address = _erc1155Address;
    }

    function addAllowedMinter(
        string memory _type,
        address _address
    ) external onlyOwner {
        allowedMinters[_type] = _address;
    }

    function removeAllowedMinter(string memory _type) external onlyOwner {
        delete allowedMinters[_type];
    }

    function getAllowedMinterByKind(
        string memory kind
    ) public view returns (address) {
        require(
            allowedMinters[kind] != address(0),
            "No contract found for the given kind"
        );

        return allowedMinters[kind];
    }

    function setMetadataResolverAddress(
        address _metadataResolverAddress
    ) external onlyOwner {
        metadataResolver = IMetadataResolver(_metadataResolverAddress);
    }

    function setMetadataBaseUrl(
        string memory _metadataBaseUrl
    ) external onlyOwner {
        metadataBaseUrl = _metadataBaseUrl;
    }

    function setPaymentRecipient(address _paymentRecipient) external onlyOwner {
        paymentRecipient = _paymentRecipient;
    }

    // Public
    function create(
        DTOs.Create1155ContractDto calldata _createDto
    ) external payable {
        validateSignature(
            abi.encodePacked(
                keccak256(abi.encodePacked(_createDto.uuid)),
                _createDto.paymentAmount,
                _createDto.extras
            ),
            _createDto.signature
        );

        handlePayment(_createDto.paymentAmount);

        address cloneErc1155Address = Clones.clone(erc1155Address);
        IERC1155 erc1155 = IERC1155(cloneErc1155Address);

        erc1155.init(
            _createDto.owner,
            _createDto.royaltyPercentage,
            _createDto.name,
            _createDto.symbol,
            _createDto.transferLocked,
            address(metadataResolver)
        );

        address cloneMinterAddress = Clones.clone(
            getAllowedMinterByKind(_createDto.minterKind)
        );
        IMinter minter = IMinter(cloneMinterAddress);

        minter.init(
            _createDto.owner,
            _createDto.signer,
            paymentRecipient,
            _createDto.availableTokens,
            _createDto.recipients,
            cloneErc1155Address
        );

        erc1155.addMinter(cloneMinterAddress);
        erc1155.transferOwnership(_createDto.owner);

        metadataResolver.setBaseURI(
            cloneErc1155Address,
            string(abi.encodePacked(metadataBaseUrl, _createDto.uuid, "/"))
        );

        emit NewContract(
            _createDto.uuid,
            _createDto.uuid,
            cloneErc1155Address,
            cloneMinterAddress,
            _createDto.extras
        );
    }

    function handlePayment(uint256 paymentAmount) internal {
        if (paymentAmount == 0) {
            return;
        }

        require(
            msg.value >= paymentAmount,
            "The payment amount has not been satisfied"
        );

        (bool success, ) = address(paymentRecipient).call{value: msg.value}("");
        require(success, "Payable: Transfer failed");
    }

    function encodeBytes32String(
        string memory source
    ) private pure returns (bytes32 result) {
        bytes memory tempBytes = bytes(source);
        if (tempBytes.length == 0) {
            return 0x0;
        }
        assembly {
            result := mload(add(tempBytes, 32))
        }
    }
}

File 27 of 46 : ERC721ProxyFactory.sol
// SPDX-License-Identifier: MIT
// @author: Buildtree - Powered by NFT Studios

pragma solidity ^0.8.18;

import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";
import {DTOs} from "./../libraries/dtos.sol";
import {SignatureProtected} from "./../libraries/SignatureProtected.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

interface IERC721 {
    function init(
        address owner,
        uint96 royalty,
        string memory name,
        string memory symbol,
        bool transferLocked,
        address metadataResolver
    ) external;

    function addMinter(address minter) external;

    function transferOwnership(address owner) external;

    function owner() external returns (address);
}

interface IMinter {
    function init(
        address owner,
        uint256 maxSupply,
        address signerAddress,
        address feeRecipient,
        DTOs.Recipient[] memory recipients,
        address erc721Address
    ) external;
}

interface IMetadataResolver {
    function setBaseURI(address _address, string memory _baseURI) external;
}

contract ERC721ProxyFactory is Ownable, SignatureProtected {
    address public paymentRecipient;
    address public erc721Address;
    mapping(string => address) allowedMinters;
    string public metadataBaseUrl;
    IMetadataResolver public metadataResolver;

    event NewContract(
        string indexed iuuid,
        string uuid,
        address token,
        address minter,
        uint256[] extras
    );

    constructor(
        address _erc721Address,
        string memory _metadataBaseUrl,
        address _metadataResolverAddress,
        address _signerAddress,
        address _paymentRecipient
    ) {
        paymentRecipient = _paymentRecipient;
        erc721Address = _erc721Address;
        metadataBaseUrl = _metadataBaseUrl;
        metadataResolver = IMetadataResolver(_metadataResolverAddress);
        initSignatureProtected(_signerAddress);
    }

    // Only Owner
    function setERC721Address(address _erc721Address) external onlyOwner {
        erc721Address = _erc721Address;
    }

    function addAllowedMinter(
        string memory _type,
        address _address
    ) external onlyOwner {
        allowedMinters[_type] = _address;
    }

    function removeAllowedMinter(string memory _type) external onlyOwner {
        delete allowedMinters[_type];
    }

    function getAllowedMinterByKind(
        string memory kind
    ) public view returns (address) {
        require(
            allowedMinters[kind] != address(0),
            "No contract found for the given kind"
        );

        return allowedMinters[kind];
    }

    function setMetadataResolverAddress(
        address _metadataResolverAddress
    ) external onlyOwner {
        metadataResolver = IMetadataResolver(_metadataResolverAddress);
    }

    function setMetadataBaseUrl(
        string memory _metadataBaseUrl
    ) external onlyOwner {
        metadataBaseUrl = _metadataBaseUrl;
    }

    function setPaymentRecipient(address _paymentRecipient) external onlyOwner {
        paymentRecipient = _paymentRecipient;
    }

    // Public
    function create(
        DTOs.Create721ContractDto calldata _createDto
    ) external payable {
        validateSignature(
            abi.encodePacked(
                keccak256(abi.encodePacked(_createDto.uuid)),
                _createDto.paymentAmount,
                _createDto.extras
            ),
            _createDto.signature
        );

        handlePayment(_createDto.paymentAmount);

        address cloneErc721Address = Clones.clone(erc721Address);
        IERC721 erc721 = IERC721(cloneErc721Address);

        erc721.init(
            _createDto.owner,
            _createDto.royaltyPercentage,
            _createDto.name,
            _createDto.symbol,
            _createDto.transferLocked,
            address(metadataResolver)
        );

        address cloneMinterAddress = Clones.clone(
            getAllowedMinterByKind(_createDto.minterKind)
        );
        IMinter minter = IMinter(cloneMinterAddress);

        minter.init(
            _createDto.owner,
            _createDto.maxSupply,
            _createDto.signer,
            paymentRecipient,
            _createDto.recipients,
            cloneErc721Address
        );

        erc721.addMinter(cloneMinterAddress);
        erc721.transferOwnership(_createDto.owner);

        metadataResolver.setBaseURI(
            cloneErc721Address,
            string(abi.encodePacked(metadataBaseUrl, _createDto.uuid, "/"))
        );

        emit NewContract(
            _createDto.uuid,
            _createDto.uuid,
            cloneErc721Address,
            cloneMinterAddress,
            _createDto.extras
        );
    }

    function handlePayment(uint256 paymentAmount) internal {
        if (paymentAmount == 0) {
            return;
        }

        require(
            msg.value >= paymentAmount,
            "The payment amount has not been satisfied"
        );

        (bool success, ) = address(paymentRecipient).call{value: msg.value}("");
        require(success, "Payable: Transfer failed");
    }

    function encodeBytes32String(
        string memory source
    ) private pure returns (bytes32 result) {
        bytes memory tempBytes = bytes(source);
        if (tempBytes.length == 0) {
            return 0x0;
        }
        assembly {
            result := mload(add(tempBytes, 32))
        }
    }
}

File 28 of 46 : IERC1155Mintable.sol
// SPDX-License-Identifier: MIT
// @author: Buildtree - Powered by NFT Studios

pragma solidity ^0.8.18;

interface IERC1155Mintable {
    function mint(
        address _to,
        uint256[] memory _ids,
        uint256[] memory _values
    ) external;

    function totalMinted() external returns (uint256);
}

File 29 of 46 : IERC721Mintable.sol
// SPDX-License-Identifier: MIT
// @author: Buildtree - Powered by NFT Studios

pragma solidity ^0.8.18;

interface IERC721Mintable {
    function mint(address _to, uint256[] memory _ids) external;

    function totalMinted() external returns (uint256);

    function exists(uint256 _tokenId) external view returns (bool);
}

File 30 of 46 : IMetadataResolver.sol
// SPDX-License-Identifier: MIT
// @author: Buildtree - Powered by NFT Studios

pragma solidity ^0.8.18;

interface IMetadataResolver {
    function getTokenURI(
        address _address,
        uint256 _tokenId
    ) external view returns (string memory);
}

File 31 of 46 : dtos.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

library DTOs {
    struct Recipient {
        address addr;
        uint256 percentage;
    }

    struct Create721ContractDto {
        address owner;
        string uuid;
        string name;
        string symbol;
        bool transferLocked;
        uint96 royaltyPercentage;
        uint256 maxSupply;
        address signer;
        Recipient[] recipients;
        uint256 paymentAmount;
        string minterKind;
        uint256[] extras;
        bytes signature;
    }

    struct Create1155ContractDto {
        address owner;
        string uuid;
        string name;
        string symbol;
        bool transferLocked;
        uint96 royaltyPercentage;
        uint256[] availableTokens;
        address signer;
        Recipient[] recipients;
        uint256 paymentAmount;
        string minterKind;
        uint256[] extras;
        bytes signature;
    }
}

File 32 of 46 : LimitPerWallet.sol
// SPDX-License-Identifier: MIT
// @author: Buildtree - Powered by NFT Studios

pragma solidity ^0.8.18;

abstract contract LimitPerWallet {
    mapping(address => uint256) public mintsPerWallet;

    /**
     * @dev Checks if the given wallet address can mint more tokens.
     * If the desired amount to be minted exceeds the amount of tokens left allowed to be minted by the given address
     * it will return the maximum amount of tokens that address can mint.
     *
     * If the given address can not mint more tokens it will revert the transaction.
     */
    function getAvailableForWallet(
        uint256 _amount,
        uint256 _maxPerWallet
    ) internal returns (uint256) {
        // If maxPerWallet is 0 it means that there is no limit per wallet.
        if (_maxPerWallet == 0) {
            return _amount;
        }

        if (mintsPerWallet[msg.sender] + _amount > _maxPerWallet) {
            _amount = _maxPerWallet - mintsPerWallet[msg.sender];
        }

        require(
            _amount > 0,
            "LimitPerWallet: The caller address can not mint more tokens"
        );

        mintsPerWallet[msg.sender] += _amount;

        return _amount;
    }
}

File 33 of 46 : Lockable.sol
// SPDX-License-Identifier: MIT
// @author: Buildtree - Powered by NFT Studios

pragma solidity ^0.8.18;
import "@openzeppelin/contracts/access/Ownable.sol";

abstract contract Lockable is Ownable {
    bool public isMintLocked;
    bool public isBurnLocked;
    bool public isMetadataLocked;

    modifier mintIsNotLocked() {
        require(isMintLocked == false, "Lockable: mint is locked");

        _;
    }

    modifier burnIsNotLocked() {
        require(isBurnLocked == false, "Lockable: burn is locked");

        _;
    }

    modifier metadataIsNotLocked() {
        require(isMetadataLocked == false, "Lockable: metadata is locked");

        _;
    }

    function lockMint() external onlyOwner {
        isMintLocked = true;
    }

    function lockBurn() external onlyOwner {
        isBurnLocked = true;
    }

    function lockMetadata() external onlyOwner {
        isMetadataLocked = true;
    }
}

File 34 of 46 : Payable.sol
// SPDX-License-Identifier: MIT
// @author: Buildtree - Powered by NFT Studios

pragma solidity ^0.8.18;

import {DTOs} from "./../libraries/dtos.sol";

abstract contract Payable {
    address public feeRecipient;
    uint256 private _totalEarnings;

    modifier onlyRecipient() {
        bool isRecipient = false;
        for (uint256 i = 0; i < recipients.length; i++) {
            if (recipients[i].addr == msg.sender) {
                isRecipient = true;
                break;
            }
        }

        require(
            isRecipient,
            "Payable: The caller is not an allowed withdrawer"
        );

        _;
    }

    uint256 constant BASIS_POINTS = 10000;

    DTOs.Recipient[] public recipients;

    function initPayable(
        address _feeRecipient,
        DTOs.Recipient[] memory _recipients
    ) internal {
        feeRecipient = _feeRecipient;

        for (uint256 i = 0; i < _recipients.length; i++) {
            recipients.push(_recipients[i]);
        }
    }

    function checkSentEther(
        uint256 _amount,
        uint256 _pricePerToken,
        uint256 _feePerToken
    ) internal {
        uint totalPrice = _amount * _pricePerToken;
        uint totalFee = _amount * _feePerToken;
        uint total = totalPrice + totalFee;

        require(
            msg.value >= total,
            "Payable: Not enough Ether provided to mint"
        );

        if (msg.value > total) {
            payable(msg.sender).transfer(msg.value - total);
        }

        if (totalFee > 0) {
            (bool success, ) = address(feeRecipient).call{value: totalFee}("");
            require(success, "Payable: Transfer failed");
        }
    }

    function withdraw() external onlyRecipient {
        uint256 totalBalance = address(this).balance;
        _totalEarnings += totalBalance;

        for (uint256 i; i < recipients.length; i++) {
            (bool success, ) = address(recipients[i].addr).call{
                value: mulScale(
                    totalBalance,
                    recipients[i].percentage,
                    BASIS_POINTS
                )
            }("");

            require(success, "Payable: Transfer failed");
        }
    }

    function totalEarnings() external view returns (uint256) {
        return _totalEarnings + address(this).balance;
    }

    function mulScale(
        uint256 x,
        uint256 y,
        uint256 scale
    ) internal pure returns (uint256) {
        uint256 a = x / scale;
        uint256 b = x % scale;
        uint256 c = y / scale;
        uint256 d = y % scale;

        return a * c * scale + a * d + b * c + (b * d) / scale;
    }
}

File 35 of 46 : ProtectedMintBurn.sol
// SPDX-License-Identifier: MIT
// @author: Buildtree - Powered by NFT Studios

pragma solidity ^0.8.18;
import "@openzeppelin/contracts/access/Ownable.sol";

abstract contract ProtectedMintBurn is Ownable {
    event AddMinter(address _minter);
    event RemoveMinter(address _minter);
    event AddBurner(address _minter);
    event RemoveBurner(address _minter);

    mapping(address => bool) public allowedMinter;
    mapping(address => bool) public allowedBurner;

    constructor() {
        allowedMinter[msg.sender] = true;
    }

    modifier onlyMinter() {
        require(
            allowedMinter[msg.sender],
            "ProtectedMintBurn: caller is not a minter"
        );

        _;
    }

    modifier onlyBurner() {
        require(
            allowedBurner[msg.sender],
            "ProtectedMintBurn: caller is not a burner"
        );

        _;
    }

    function addMinter(address _minter) external onlyOwner {
        allowedMinter[_minter] = true;

        emit AddMinter(_minter);
    }

    function removeMinter(address _minter) external onlyOwner {
        allowedMinter[_minter] = false;

        emit RemoveMinter(_minter);
    }

    function addBurner(address _burner) external onlyOwner {
        allowedBurner[_burner] = true;

        emit AddBurner(_burner);
    }

    function removeBurner(address _burner) external onlyOwner {
        allowedBurner[_burner] = false;

        emit RemoveBurner(_burner);
    }
}

File 36 of 46 : RandomGenerator.sol
// SPDX-License-Identifier: MIT
// @author: Buildtree - Powered by NFT Studios

pragma solidity ^0.8.18;

abstract contract RandomGenerator {
    /**
     * @dev Generates a pseudo-random number.
     */
    function getRandomNumber(
        uint256 _upper,
        uint256 _variable // This value should change in between calls to this function within the same block to avoid generating the same number.
    ) internal view returns (uint256) {
        uint256 random = uint256(
            keccak256(
                abi.encodePacked(
                    _variable,
                    blockhash(block.number - 1),
                    block.coinbase,
                    block.prevrandao,
                    msg.sender
                )
            )
        );

        return (random % _upper);
    }
}

File 37 of 46 : SignatureProtected.sol
// SPDX-License-Identifier: MIT
// @author: Buildtree - Powered by NFT Studios

pragma solidity ^0.8.18;

import "@openzeppelin/contracts/access/Ownable.sol";
import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import {AccessControl} from "@openzeppelin/contracts/access/AccessControl.sol";

abstract contract SignatureProtected is Ownable {
    address public signerAddress;

    constructor() Ownable(msg.sender) {}

    function initSignatureProtected(address _signerAddress) internal {
        signerAddress = _signerAddress;
    }

    function setSignerAddress(address _signerAddress) external onlyOwner {
        signerAddress = _signerAddress;
    }

    function validateSignature(
        bytes memory packedParams,
        bytes calldata signature
    ) internal view {
        require(
            ECDSA.recover(generateHash(packedParams), signature) ==
                signerAddress,
            "SignatureProtected: Invalid signature for the caller"
        );
    }

    function generateHash(
        bytes memory packedParams
    ) private view returns (bytes32) {
        bytes32 _hash = keccak256(
            bytes.concat(
                abi.encodePacked(address(this), msg.sender),
                packedParams
            )
        );

        bytes memory result = abi.encodePacked(
            "\x19Ethereum Signed Message:\n32",
            _hash
        );

        return keccak256(result);
    }
}

File 38 of 46 : SupplyControl.sol
// SPDX-License-Identifier: MIT
// @author: Buildtree - Powered by NFT Studios

pragma solidity ^0.8.18;

abstract contract SupplyControl {
    uint256 public maxSupply;

    function initSupplyControl(uint256 _maxSupply) internal {
        maxSupply = _maxSupply;
    }

    /**
     * @dev Checks if there are tokens left to be minted.
     * If there are not enough tokens for the given amount to mint, it will return whatever is left.
     *
     * If there are no tokens left to be minted it will revert the transaction.
     */
    function _getAvailableTokens(
        uint256 _amountToMint,
        uint256 _totalMinted
    ) internal view returns (uint256) {
        uint256 availableTokens = maxSupply - _totalMinted;
        require(availableTokens > 0, "SupplyControl: No tokens left to mint");

        if (availableTokens < _amountToMint) {
            return availableTokens;
        }

        return _amountToMint;
    }
}

File 39 of 46 : SupplyControl1155.sol
// SPDX-License-Identifier: MIT
// @author: Buildtree - Powered by NFT Studios

pragma solidity ^0.8.18;

abstract contract SupplyControl1155 {
    uint256[] internal availableTokens;
    uint256 public maxSupply;

    function initSupplyControl(uint256[] memory _availableTokens) internal {
        availableTokens = _availableTokens;
        for (uint256 i; i < _availableTokens.length; i++) {
            maxSupply += _availableTokens[i];
        }
    }

    /**
     * @dev Checks if there are tokens left to be minted.
     * If there are not enough tokens for the given amount to mint, it will return whatever is left.
     *
     * If there are no tokens left to be minted it will revert the transaction.
     */
    function _getAvailableTokens(
        uint256 _amountToMint
    ) internal view returns (uint256) {
        uint256 _availableTokens = getAvailableTokens();

        require(_availableTokens > 0, "SupplyControl: No tokens left to mint");
        if (_availableTokens < _amountToMint) {
            return _availableTokens;
        }

        return _amountToMint;
    }

    function getAvailableTokens() public view returns (uint256) {
        uint256 _availableTokens;
        for (uint256 i; i < availableTokens.length; i++) {
            _availableTokens += availableTokens[i];
        }

        return _availableTokens;
    }
}

File 40 of 46 : MetadataBaseUrl.sol
// SPDX-License-Identifier: MIT
// @author: Buildtree - Powered by NFT Studios

pragma solidity ^0.8.18;

import "@openzeppelin/contracts/utils/Strings.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

import {IMetadataResolver} from "./../interfaces/IMetadataResolver.sol";

contract MetadataBaseUrl is Ownable, IMetadataResolver {
    using Strings for uint256;

    mapping(address => bool) public allowedSetters;
    mapping(address => string) public baseURI;

    constructor() Ownable(msg.sender) {
        allowedSetters[msg.sender] = true;
    }

    function addAllowedSetter(address _allowedSetter) external onlyOwner {
        allowedSetters[_allowedSetter] = true;
    }

    function removeAllowedSetter(address _allowedSetter) external onlyOwner {
        allowedSetters[_allowedSetter] = false;
    }

    function setBaseURI(address _address, string memory _baseURI) external {
        require(
            allowedSetters[msg.sender],
            "MetadataBaseUrl: Caller not allowed"
        );

        baseURI[_address] = _baseURI;
    }

    function getTokenURI(
        address _address,
        uint256 _tokenId
    ) external view returns (string memory) {
        return string(abi.encodePacked(baseURI[_address], _tokenId.toString()));
    }
}

File 41 of 46 : PickMint1155.sol
// SPDX-License-Identifier: MIT
// @author: Buildtree - Powered by NFT Studios

pragma solidity ^0.8.18;

import {IERC1155Mintable} from "./../interfaces/IERC1155Mintable.sol";
import {Payable} from "./../libraries/Payable.sol";
import {SupplyControl1155} from "./../libraries/SupplyControl1155.sol";
import {LimitPerWallet} from "./../libraries/LimitPerWallet.sol";
import {SignatureProtected} from "./../libraries/SignatureProtected.sol";
import {DTOs} from "./../libraries/dtos.sol";

contract PickMint1155 is
    Payable,
    SupplyControl1155,
    LimitPerWallet,
    SignatureProtected
{
    string public constant contractType = "PICK-MINTER-1155";
    string public constant version = "1.0.0";

    IERC1155Mintable public erc1155Contract;

    bool private _isInitialized;

    function init(
        address owner,
        address signerAddress,
        address feeRecipient,
        uint256[] memory availableTokens,
        DTOs.Recipient[] memory recipients,
        address erc1155Address
    ) external {
        require(_isInitialized == false, "Contract already initialized.");
        _transferOwnership(owner);
        initSupplyControl(availableTokens);
        initSignatureProtected(signerAddress);
        initPayable(feeRecipient, recipients);

        erc1155Contract = IERC1155Mintable(erc1155Address);
        _isInitialized = true;
    }

    function mint(
        uint256[] memory _ids,
        uint256[] memory _amounts,
        uint256 _maxPerWallet,
        uint256 _pricePerToken,
        uint256 _feePerToken,
        bytes calldata _signature
    ) external payable {
        validateSignature(
            abi.encodePacked(_maxPerWallet, _pricePerToken, _feePerToken),
            _signature
        );

        uint256 _amount;
        for (uint256 i; i < _ids.length; i++) {
            require(
                _ids[i] < availableTokens.length,
                "Invalid ID to be minted"
            );
            uint _available = availableTokens[_ids[i]];
            if (_available < _amounts[i]) {
                _amounts[i] = _available;
            }
            availableTokens[_ids[i]] -= _amounts[i];
            _amount += _amounts[i];
        }

        require(
            _amount > 0,
            "None of the selected tokens to mint are available"
        );

        uint256 _availableAmount = getAvailableForWallet(
            _amount,
            _maxPerWallet
        );
        require(
            _availableAmount >= _amount,
            "Not enough tokens available to mint for your wallet"
        );

        checkSentEther(_amount, _pricePerToken, _feePerToken);

        erc1155Contract.mint(msg.sender, _ids, _amounts);
    }
}

File 42 of 46 : PickMint721.sol
// SPDX-License-Identifier: MIT
// @author: Buildtree - Powered by NFT Studios

pragma solidity ^0.8.18;

import {IERC721Mintable} from "./../interfaces/IERC721Mintable.sol";
import {Payable} from "./../libraries/Payable.sol";
import {SupplyControl} from "./../libraries/SupplyControl.sol";
import {LimitPerWallet} from "./../libraries/LimitPerWallet.sol";
import {SignatureProtected} from "./../libraries/SignatureProtected.sol";
import {DTOs} from "./../libraries/dtos.sol";

contract PickMint721 is
    Payable,
    SupplyControl,
    LimitPerWallet,
    SignatureProtected
{
    string public constant contractType = "PICK-MINTER-721";
    string public constant version = "1.0.0";

    IERC721Mintable public erc721Contract;

    bool private _isInitialized;

    function init(
        address owner,
        uint256 maxSupply,
        address signerAddress,
        address feeRecipient,
        DTOs.Recipient[] memory recipients,
        address erc721Address
    ) external {
        require(_isInitialized == false, "Contract already initialized.");
        _transferOwnership(owner);
        initSupplyControl(maxSupply);
        initSignatureProtected(signerAddress);
        initPayable(feeRecipient, recipients);

        erc721Contract = IERC721Mintable(erc721Address);
        _isInitialized = true;
    }

    function mint(
        uint256[] memory _ids,
        uint256 _maxPerWallet,
        uint256 _pricePerToken,
        uint256 _feePerToken,
        bytes calldata _signature
    ) external payable {
        validateSignature(
            abi.encodePacked(_maxPerWallet, _pricePerToken, _feePerToken),
            _signature
        );

        uint256 _amount;
        for (uint256 i; i < _ids.length; i++) {
            require(_ids[i] < maxSupply, "Invalid ID to be minted");
            if (!erc721Contract.exists(_ids[i])) {
                _amount++;
            }
        }

        uint256 _availableAmount = getAvailableForWallet(
            _amount,
            _maxPerWallet
        );
        require(
            _availableAmount >= _amount,
            "Not enough tokens available to mint for your wallet"
        );

        checkSentEther(_amount, _pricePerToken, _feePerToken);

        uint256[] memory idsToMint = new uint256[](_amount);
        uint256 c;
        for (uint256 i; i < _ids.length; i++) {
            if (erc721Contract.exists(_ids[i])) {
                continue;
            }

            idsToMint[c] = _ids[i];
            c++;
        }

        erc721Contract.mint(msg.sender, idsToMint);
    }
}

File 43 of 46 : RandomMint1155.sol
// SPDX-License-Identifier: MIT
// @author: Buildtree - Powered by NFT Studios

pragma solidity ^0.8.18;

import {IERC1155Mintable} from "./../interfaces/IERC1155Mintable.sol";
import {Payable} from "./../libraries/Payable.sol";
import {SupplyControl1155} from "./../libraries/SupplyControl1155.sol";
import {LimitPerWallet} from "./../libraries/LimitPerWallet.sol";
import {SignatureProtected} from "./../libraries/SignatureProtected.sol";
import {DTOs} from "./../libraries/dtos.sol";
import {RandomGenerator} from "./../libraries/RandomGenerator.sol";

contract RandomMint1155 is
    Payable,
    SupplyControl1155,
    LimitPerWallet,
    SignatureProtected,
    RandomGenerator
{
    string public constant contractType = "RANDOM-MINTER-1155";
    string public constant version = "1.0.0";

    IERC1155Mintable public erc1155Contract;

    bool private _isInitialized;

    function init(
        address owner,
        address signerAddress,
        address feeRecipient,
        uint256[] memory availableTokens,
        DTOs.Recipient[] memory recipients,
        address erc1155Address
    ) external {
        require(_isInitialized == false, "Contract already initialized.");
        _transferOwnership(owner);
        initSupplyControl(availableTokens);
        initSignatureProtected(signerAddress);
        initPayable(feeRecipient, recipients);

        erc1155Contract = IERC1155Mintable(erc1155Address);
        _isInitialized = true;
    }

    function mint(
        uint256 _amount,
        uint256 _maxPerWallet,
        uint256 _pricePerToken,
        uint256 _feePerToken,
        bytes calldata _signature
    ) external payable {
        validateSignature(
            abi.encodePacked(_maxPerWallet, _pricePerToken, _feePerToken),
            _signature
        );

        _amount = _getAvailableTokens(_amount);
        _amount = getAvailableForWallet(_amount, _maxPerWallet);

        checkSentEther(_amount, _pricePerToken, _feePerToken);

        uint256[] memory amountsPerToken = new uint256[](
            availableTokens.length
        );

        uint256 diffCount = 0;
        for (uint256 i; i < _amount; i++) {
            uint256 tokenId = getRandomTokenId(i);
            if (amountsPerToken[tokenId] == 0) {
                diffCount++;
            }

            amountsPerToken[tokenId]++;
        }

        uint256[] memory ids = new uint256[](diffCount);
        uint256[] memory amounts = new uint256[](diffCount);

        uint256 found = 0;
        for (uint256 i; i < amountsPerToken.length; i++) {
            if (amountsPerToken[i] == 0) {
                continue;
            }

            ids[found] = i;
            amounts[found] = amountsPerToken[i];
            found++;
        }

        erc1155Contract.mint(msg.sender, ids, amounts);
    }

    function getRandomTokenId(
        uint256 _randomVariable
    ) internal returns (uint256) {
        uint256 random = getRandomNumber(getAvailableTokens(), _randomVariable);

        uint256 total;
        for (uint256 i; i < availableTokens.length; i++) {
            total += availableTokens[i];
            if (random < total) {
                availableTokens[i]--;
                return i;
            }
        }

        revert("Invalid random value generated");
    }
}

File 44 of 46 : SequentialMint721.sol
// SPDX-License-Identifier: MIT
// @author: Buildtree - Powered by NFT Studios

pragma solidity ^0.8.18;

import {IERC721Mintable} from "./../interfaces/IERC721Mintable.sol";
import {Payable} from "./../libraries/Payable.sol";
import {SupplyControl} from "./../libraries/SupplyControl.sol";
import {LimitPerWallet} from "./../libraries/LimitPerWallet.sol";
import {SignatureProtected} from "./../libraries/SignatureProtected.sol";
import {DTOs} from "./../libraries/dtos.sol";

contract SequentialMint721 is
    Payable,
    SupplyControl,
    LimitPerWallet,
    SignatureProtected
{
    string public constant contractType = "SEQUENTIAL-MINTER-721";
    string public constant version = "1.0.0";

    IERC721Mintable public erc721Contract;

    bool private _isInitialized;

    function init(
        address owner,
        uint256 maxSupply,
        address signerAddress,
        address feeRecipient,
        DTOs.Recipient[] memory recipients,
        address erc721Address
    ) external {
        require(_isInitialized == false, "Contract already initialized.");
        _transferOwnership(owner);
        initSupplyControl(maxSupply);
        initSignatureProtected(signerAddress);
        initPayable(feeRecipient, recipients);

        erc721Contract = IERC721Mintable(erc721Address);
        _isInitialized = true;
    }

    function mint(
        uint256 _amount,
        uint256 _maxPerWallet,
        uint256 _pricePerToken,
        uint256 _feePerToken,
        bytes calldata _signature
    ) external payable {
        validateSignature(
            abi.encodePacked(_maxPerWallet, _pricePerToken, _feePerToken),
            _signature
        );

        uint256 totalMinted = erc721Contract.totalMinted();
        _amount = _getAvailableTokens(_amount, totalMinted);
        _amount = getAvailableForWallet(_amount, _maxPerWallet);

        checkSentEther(_amount, _pricePerToken, _feePerToken);

        uint256[] memory ids = new uint256[](_amount);
        for (uint256 i; i < ids.length; i++) {
            ids[i] = totalMinted + i;
        }

        erc721Contract.mint(msg.sender, ids);
    }
}

File 45 of 46 : Base1155.sol
// SPDX-License-Identifier: MIT
// @author: Buildtree - Powered by NFT Studios

pragma solidity ^0.8.18;

import "@openzeppelin/contracts/access/Ownable.sol";
import {ERC1155} from "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";
import {ERC2981} from "@openzeppelin/contracts/token/common/ERC2981.sol";
import {Lockable} from "./../libraries/Lockable.sol";
import {ProtectedMintBurn} from "./../libraries/ProtectedMintBurn.sol";
import {IMetadataResolver} from "./../interfaces/IMetadataResolver.sol";
import {IERC1155Mintable} from "./../interfaces/IERC1155Mintable.sol";
import {AccessControl} from "@openzeppelin/contracts/access/AccessControl.sol";

contract Base1155 is
    ERC1155,
    ERC2981,
    Ownable,
    Lockable,
    ProtectedMintBurn,
    IERC1155Mintable
{
    event TransferLocked(bool isTransferLocked);

    string public constant contractType = "ERC-1155";
    string public constant version = "1.0.0";

    IMetadataResolver public metadataResolver;
    uint256 public totalMinted;
    uint256 public totalBurned;
    bool public transferLocked;

    string private _name;
    string private _symbol;
    bool private _isInitialized;

    struct BatchMint {
        address addr;
        uint256[] ids;
        uint256[] values;
    }

    constructor() ERC1155("") Ownable(msg.sender) {}

    function init(
        address owner,
        uint96 royalty,
        string memory __name,
        string memory __symbol,
        bool _transferLocked,
        address _metadataResolver
    ) public {
        require(_isInitialized == false, "Contract already initialized.");
        _transferOwnership(msg.sender);
        _setDefaultRoyalty(owner, royalty);
        _name = __name;
        _symbol = __symbol;
        transferLocked = _transferLocked;
        metadataResolver = IMetadataResolver(_metadataResolver);

        _isInitialized = true;
    }

    // Only Minter
    function mint(
        address _to,
        uint256[] memory _ids,
        uint256[] memory _values
    ) external onlyMinter mintIsNotLocked {
        _mintBatch(_to, _ids, _values, "");

        uint256 _totalMinted;
        for (uint256 i; i < _values.length; i++) {
            _totalMinted += _values[i];
        }
        totalMinted += _totalMinted;
    }

    function batchMint(
        BatchMint[] memory bm
    ) external onlyMinter mintIsNotLocked {
        uint256 _totalMinted;
        for (uint256 i; i < bm.length; i++) {
            _mintBatch(bm[i].addr, bm[i].ids, bm[i].values, "");

            for (uint256 f; f < bm[i].values.length; f++) {
                _totalMinted += bm[i].values[f];
            }
        }

        totalMinted += _totalMinted;
    }

    // Only Burner
    function burn(
        address _from,
        uint256[] memory _ids,
        uint256[] memory _values
    ) external onlyBurner burnIsNotLocked {
        _burnBatch(_from, _ids, _values);

        uint256 _totalBurned;
        for (uint256 i; i < _values.length; i++) {
            _totalBurned += _values[i];
        }
        totalBurned += _totalBurned;
    }

    // Only owner
    function setDefaultRoyalty(
        address _receiver,
        uint96 _feeNumerator
    ) external onlyOwner {
        _setDefaultRoyalty(_receiver, _feeNumerator);
    }

    function setTokenRoyalty(
        uint256 _tokenId,
        address _receiver,
        uint96 _feeNumerator
    ) external onlyOwner {
        _setTokenRoyalty(_tokenId, _receiver, _feeNumerator);
    }

    function setMetadataResolver(
        address _metadataResolverAddress
    ) external onlyOwner metadataIsNotLocked {
        metadataResolver = IMetadataResolver(_metadataResolverAddress);
    }

    function setTransferLocked(bool _transferLocked) external onlyOwner {
        transferLocked = _transferLocked;

        emit TransferLocked(_transferLocked);
    }

    // Public
    function name() public view virtual returns (string memory) {
        return _name;
    }

    function symbol() public view virtual returns (string memory) {
        return _symbol;
    }

    function uri(
        uint256 _tokenId
    ) public view virtual override returns (string memory) {
        return metadataResolver.getTokenURI(address(this), _tokenId);
    }

    function totalSupply() public view returns (uint256) {
        return totalMinted - totalBurned;
    }

    function supportsInterface(
        bytes4 _interfaceId
    ) public view virtual override(ERC1155, ERC2981) returns (bool) {
        return super.supportsInterface(_interfaceId);
    }

    function _update(
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory values
    ) internal virtual override {
        // Check that either the token is being minted
        // or that the transfer is unlocked
        require(
            from == address(0) || !transferLocked,
            "The token can not be transferred at this time."
        );

        return super._update(from, to, ids, values);
    }
}

File 46 of 46 : Base721.sol
// SPDX-License-Identifier: MIT
// @author: Buildtree - Powered by NFT Studios

pragma solidity ^0.8.18;

import "@openzeppelin/contracts/access/Ownable.sol";
import {ERC721} from "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import {ERC2981} from "@openzeppelin/contracts/token/common/ERC2981.sol";
import {Lockable} from "./../libraries/Lockable.sol";
import {ProtectedMintBurn} from "./../libraries/ProtectedMintBurn.sol";
import {IMetadataResolver} from "./../interfaces/IMetadataResolver.sol";
import {IERC721Mintable} from "./../interfaces/IERC721Mintable.sol";
import {AccessControl} from "@openzeppelin/contracts/access/AccessControl.sol";

contract Base721 is
    ERC721,
    ERC2981,
    Ownable,
    Lockable,
    ProtectedMintBurn,
    IERC721Mintable
{
    event TransferLocked(bool isTransferLocked);

    string public constant contractType = "ERC-721";
    string public constant version = "1.0.0";

    IMetadataResolver public metadataResolver;
    uint256 public totalMinted;
    uint256 public totalBurned;
    bool public transferLocked;

    string private _name;
    string private _symbol;
    bool private _isInitialized;

    constructor() ERC721("", "") Ownable(msg.sender) {}

    function init(
        address owner,
        uint96 royalty,
        string memory __name,
        string memory __symbol,
        bool _transferLocked,
        address _metadataResolver
    ) public {
        require(_isInitialized == false, "Contract already initialized.");
        _transferOwnership(msg.sender);
        _setDefaultRoyalty(owner, royalty);
        _name = __name;
        _symbol = __symbol;
        transferLocked = _transferLocked;
        metadataResolver = IMetadataResolver(_metadataResolver);

        _isInitialized = true;
    }

    // Only Minter
    function mint(
        address _to,
        uint256[] memory _ids
    ) external onlyMinter mintIsNotLocked {
        for (uint i; i < _ids.length; i++) {
            _safeMint(_to, _ids[i]);
        }

        totalMinted += _ids.length;
    }

    function batchMint(
        address[] memory _addresses,
        uint256[] memory _ids
    ) external onlyMinter mintIsNotLocked {
        for (uint i; i < _ids.length; i++) {
            _safeMint(_addresses[i], _ids[i]);
        }

        totalMinted += _ids.length;
    }

    // Only Burner
    function burn(uint256[] memory _ids) external onlyBurner burnIsNotLocked {
        for (uint i; i < _ids.length; i++) {
            _burn(_ids[i]);
        }

        totalBurned += _ids.length;
    }

    // Only owner
    function setDefaultRoyalty(
        address _receiver,
        uint96 _feeNumerator
    ) external onlyOwner {
        _setDefaultRoyalty(_receiver, _feeNumerator);
    }

    function setTokenRoyalty(
        uint256 _tokenId,
        address _receiver,
        uint96 _feeNumerator
    ) external onlyOwner {
        _setTokenRoyalty(_tokenId, _receiver, _feeNumerator);
    }

    function setMetadataResolver(
        address _metadataResolverAddress
    ) external onlyOwner metadataIsNotLocked {
        metadataResolver = IMetadataResolver(_metadataResolverAddress);
    }

    function setTransferLocked(bool _transferLocked) external onlyOwner {
        transferLocked = _transferLocked;

        emit TransferLocked(_transferLocked);
    }

    // Public
    function name() public view virtual override returns (string memory) {
        return _name;
    }

    function symbol() public view virtual override returns (string memory) {
        return _symbol;
    }

    function tokenURI(
        uint256 _tokenId
    ) public view virtual override returns (string memory) {
        require(_ownerOf(_tokenId) != address(0), "Token does not exists");

        return metadataResolver.getTokenURI(address(this), _tokenId);
    }

    function totalSupply() public view returns (uint256) {
        return totalMinted - totalBurned;
    }

    function exists(uint256 _tokenId) external view returns (bool) {
        return _ownerOf(_tokenId) != address(0);
    }

    function supportsInterface(
        bytes4 _interfaceId
    ) public view virtual override(ERC721, ERC2981) returns (bool) {
        return super.supportsInterface(_interfaceId);
    }

    function _update(
        address to,
        uint256 tokenId,
        address auth
    ) internal virtual override returns (address) {
        address from = _ownerOf(tokenId);

        // Check that either the token is being minted
        // or that the transfer is unlocked
        require(
            from == address(0) || !transferLocked,
            "The token can not be transferred at this time."
        );

        return super._update(to, tokenId, auth);
    }
}

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

Contract Security Audit

Contract ABI

[{"inputs":[],"name":"ECDSAInvalidSignature","type":"error"},{"inputs":[{"internalType":"uint256","name":"length","type":"uint256"}],"name":"ECDSAInvalidSignatureLength","type":"error"},{"inputs":[{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"ECDSAInvalidSignatureS","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[],"name":"contractType","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"erc721Contract","outputs":[{"internalType":"contract IERC721Mintable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feeRecipient","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAvailableTokens","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"maxSupply","type":"uint256"},{"internalType":"address","name":"signerAddress","type":"address"},{"internalType":"address","name":"feeRecipient","type":"address"},{"components":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"uint256","name":"percentage","type":"uint256"}],"internalType":"struct DTOs.Recipient[]","name":"recipients","type":"tuple[]"},{"internalType":"address","name":"erc721Address","type":"address"}],"name":"init","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"maxSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint256","name":"_maxPerWallet","type":"uint256"},{"internalType":"uint256","name":"_pricePerToken","type":"uint256"},{"internalType":"uint256","name":"_feePerToken","type":"uint256"},{"internalType":"bytes","name":"_signature","type":"bytes"}],"name":"mint","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"mintsPerWallet","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"recipients","outputs":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"uint256","name":"percentage","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_signerAddress","type":"address"}],"name":"setSignerAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"signerAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalEarnings","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"version","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]

60806040523480156200001157600080fd5b5033600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603620000885760006040517f1e4fbdf70000000000000000000000000000000000000000000000000000000081526004016200007f9190620001ab565b60405180910390fd5b6200009981620000a060201b60201c565b50620001c8565b6000600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000620001938262000166565b9050919050565b620001a58162000186565b82525050565b6000602082019050620001c260008301846200019a565b92915050565b6129d880620001d86000396000f3fe6080604052600436106100fe5760003560e01c80638da5cb5b11610095578063d638aefb11610064578063d638aefb14610302578063d7c97fb41461032b578063e35568cb14610356578063f2fde38b14610381578063f8ea8f16146103aa576100fe565b80638da5cb5b14610243578063cb2ef6f71461026e578063d1bc76a114610299578063d5abeb01146102d7576100fe565b80634d0df5fc116100d15780634d0df5fc1461019957806354fd4d50146101d65780635b7633d014610201578063715018a61461022c576100fe565b8063046dc166146101035780632df3eba41461012c5780633ccfd60b14610157578063469048401461016e575b600080fd5b34801561010f57600080fd5b5061012a600480360381019061012591906119bc565b6103c6565b005b34801561013857600080fd5b50610141610412565b60405161014e9190611a02565b60405180910390f35b34801561016357600080fd5b5061016c610427565b005b34801561017a57600080fd5b5061018361066a565b6040516101909190611a2c565b60405180910390f35b3480156101a557600080fd5b506101c060048036038101906101bb91906119bc565b61068e565b6040516101cd9190611a02565b60405180910390f35b3480156101e257600080fd5b506101eb6106a6565b6040516101f89190611ad7565b60405180910390f35b34801561020d57600080fd5b506102166106df565b6040516102239190611a2c565b60405180910390f35b34801561023857600080fd5b50610241610705565b005b34801561024f57600080fd5b50610258610719565b6040516102659190611a2c565b60405180910390f35b34801561027a57600080fd5b50610283610743565b6040516102909190611ad7565b60405180910390f35b3480156102a557600080fd5b506102c060048036038101906102bb9190611b25565b61077c565b6040516102ce929190611b52565b60405180910390f35b3480156102e357600080fd5b506102ec6107d0565b6040516102f99190611a02565b60405180910390f35b34801561030e57600080fd5b5061032960048036038101906103249190611d18565b6107d6565b005b34801561033757600080fd5b506103406108b5565b60405161034d9190611e20565b60405180910390f35b34801561036257600080fd5b5061036b6108db565b6040516103789190611a02565b60405180910390f35b34801561038d57600080fd5b506103a860048036038101906103a391906119bc565b610a56565b005b6103c460048036038101906103bf9190611e96565b610adc565b005b6103ce610cfa565b80600660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000476001546104229190611f5f565b905090565b6000805b6002805490508110156104c6573373ffffffffffffffffffffffffffffffffffffffff166002828154811061046357610462611f93565b5b906000526020600020906002020160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16036104b957600191506104c6565b808060010191505061042b565b5080610507576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104fe90612034565b60405180910390fd5b6000479050806001600082825461051e9190611f5f565b9250508190555060005b6002805490508110156106655760006002828154811061054b5761054a611f93565b5b906000526020600020906002020160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166105c584600285815481106105ab576105aa611f93565b5b906000526020600020906002020160010154612710610d81565b6040516105d190612085565b60006040518083038185875af1925050503d806000811461060e576040519150601f19603f3d011682016040523d82523d6000602084013e610613565b606091505b5050905080610657576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161064e906120e6565b60405180910390fd5b508080600101915050610528565b505050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60046020528060005260406000206000915090505481565b6040518060400160405280600581526020017f312e302e3000000000000000000000000000000000000000000000000000000081525081565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b61070d610cfa565b6107176000610e33565b565b6000600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6040518060400160405280601181526020017f52414e444f4d2d4d494e5445522d37323100000000000000000000000000000081525081565b6002818154811061078c57600080fd5b90600052602060002090600202016000915090508060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16908060010154905082565b60035481565b60001515600860149054906101000a900460ff1615151461082c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161082390612152565b60405180910390fd5b61083586610e33565b61083e85610ef9565b61084784610f03565b6108518383610f47565b80600860006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506001600860146101000a81548160ff021916908315150217905550505050505050565b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000806000600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166040516024016040516020818303038152906040527fa2309ff8000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516109a991906121ae565b600060405180830381855afa9150503d80600081146109e4576040519150601f19603f3d011682016040523d82523d6000602084013e6109e9565b606091505b509150915081610a2e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a2590612211565b60405180910390fd5b80806020019051810190610a429190612246565b600354610a4f9190612273565b9250505090565b610a5e610cfa565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603610ad05760006040517f1e4fbdf7000000000000000000000000000000000000000000000000000000008152600401610ac79190611a2c565b60405180910390fd5b610ad981610e33565b50565b610b0a858585604051602001610af4939291906122c8565b604051602081830303815290604052838361103e565b6000600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a2309ff86040518163ffffffff1660e01b81526004016020604051808303816000875af1158015610b7b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b9f9190612246565b9050610bab8782611128565b9650610bb7878761119a565b9650610bc48786866112ee565b60008767ffffffffffffffff811115610be057610bdf611b80565b5b604051908082528060200260200182016040528015610c0e5781602001602082028036833780820191505090505b50905060005b8151811015610c6057610c348184610c2c9190611f5f565b60035461149c565b828281518110610c4757610c46611f93565b5b6020026020010181815250508080600101915050610c14565b50600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663de836ebd33836040518363ffffffff1660e01b8152600401610cbe9291906123c3565b600060405180830381600087803b158015610cd857600080fd5b505af1158015610cec573d6000803e3d6000fd5b505050505050505050505050565b610d02611585565b73ffffffffffffffffffffffffffffffffffffffff16610d20610719565b73ffffffffffffffffffffffffffffffffffffffff1614610d7f57610d43611585565b6040517f118cdaa7000000000000000000000000000000000000000000000000000000008152600401610d769190611a2c565b60405180910390fd5b565b6000808285610d909190612422565b905060008386610da09190612453565b905060008486610db09190612422565b905060008587610dc09190612453565b9050858184610dcf9190612484565b610dd99190612422565b8284610de59190612484565b8286610df19190612484565b888588610dfe9190612484565b610e089190612484565b610e129190611f5f565b610e1c9190611f5f565b610e269190611f5f565b9450505050509392505050565b6000600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b8060038190555050565b80600660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060005b8151811015611039576002828281518110610fa857610fa7611f93565b5b6020026020010151908060018154018082558091505060019003906000526020600020906002020160009091909190915060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506020820151816001015550508080600101915050610f8a565b505050565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166110cd6110838561158d565b84848080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050611611565b73ffffffffffffffffffffffffffffffffffffffff1614611123576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161111a90612538565b60405180910390fd5b505050565b600080826003546111399190612273565b90506000811161117e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611175906125ca565b60405180910390fd5b8381101561118f5780915050611194565b839150505b92915050565b60008082036111ab578290506112e8565b8183600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546111f79190611f5f565b111561124b57600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054826112489190612273565b92505b6000831161128e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112859061265c565b60405180910390fd5b82600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546112dd9190611f5f565b925050819055508290505b92915050565b600082846112fc9190612484565b90506000828561130c9190612484565b90506000818361131c9190611f5f565b905080341015611361576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611358906126ee565b60405180910390fd5b803411156113bc573373ffffffffffffffffffffffffffffffffffffffff166108fc823461138f9190612273565b9081150290604051600060405180830381858888f193505050501580156113ba573d6000803e3d6000fd5b505b60008211156114945760008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168360405161140c90612085565b60006040518083038185875af1925050503d8060008114611449576040519150601f19603f3d011682016040523d82523d6000602084013e61144e565b606091505b5050905080611492576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611489906120e6565b60405180910390fd5b505b505050505050565b60008083836114ab9190612273565b905060006114b9828661163d565b905060006007600083815260200190815260200160002054905060006007600084815260200190815260200160002054036114f2578190505b6000600760006001866115059190612273565b81526020019081526020016000205414611554576007600060018561152a9190612273565b81526020019081526020016000205460076000848152602001908152602001600020819055611578565b6001836115619190612273565b600760008481526020019081526020016000208190555b5080935050505092915050565b600033905090565b60008030336040516020016115a3929190612756565b604051602081830303815290604052836040516020016115c4929190612782565b6040516020818303038152906040528051906020012090506000816040516020016115ef9190612828565b6040516020818303038152906040529050808051906020012092505050919050565b6000806000806116218686611696565b92509250925061163182826116f2565b82935050505092915050565b6000808260014361164e9190612273565b40414433604051602001611666959493929190612889565b6040516020818303038152906040528051906020012060001c9050838161168d9190612453565b91505092915050565b600080600060418451036116db5760008060006020870151925060408701519150606087015160001a90506116cd88828585611856565b9550955095505050506116eb565b60006002855160001b9250925092505b9250925092565b60006003811115611706576117056128e8565b5b826003811115611719576117186128e8565b5b03156118525760016003811115611733576117326128e8565b5b826003811115611746576117456128e8565b5b0361177d576040517ff645eedf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60026003811115611791576117906128e8565b5b8260038111156117a4576117a36128e8565b5b036117e9578060001c6040517ffce698f70000000000000000000000000000000000000000000000000000000081526004016117e09190611a02565b60405180910390fd5b6003808111156117fc576117fb6128e8565b5b82600381111561180f5761180e6128e8565b5b0361185157806040517fd78bce0c0000000000000000000000000000000000000000000000000000000081526004016118489190612926565b60405180910390fd5b5b5050565b60008060007f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08460001c1115611896576000600385925092509250611940565b6000600188888888604051600081526020016040526040516118bb949392919061295d565b6020604051602081039080840390855afa1580156118dd573d6000803e3d6000fd5b505050602060405103519050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff160361193157600060016000801b93509350935050611940565b8060008060001b935093509350505b9450945094915050565b6000604051905090565b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006119898261195e565b9050919050565b6119998161197e565b81146119a457600080fd5b50565b6000813590506119b681611990565b92915050565b6000602082840312156119d2576119d1611954565b5b60006119e0848285016119a7565b91505092915050565b6000819050919050565b6119fc816119e9565b82525050565b6000602082019050611a1760008301846119f3565b92915050565b611a268161197e565b82525050565b6000602082019050611a416000830184611a1d565b92915050565b600081519050919050565b600082825260208201905092915050565b60005b83811015611a81578082015181840152602081019050611a66565b60008484015250505050565b6000601f19601f8301169050919050565b6000611aa982611a47565b611ab38185611a52565b9350611ac3818560208601611a63565b611acc81611a8d565b840191505092915050565b60006020820190508181036000830152611af18184611a9e565b905092915050565b611b02816119e9565b8114611b0d57600080fd5b50565b600081359050611b1f81611af9565b92915050565b600060208284031215611b3b57611b3a611954565b5b6000611b4984828501611b10565b91505092915050565b6000604082019050611b676000830185611a1d565b611b7460208301846119f3565b9392505050565b600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b611bb882611a8d565b810181811067ffffffffffffffff82111715611bd757611bd6611b80565b5b80604052505050565b6000611bea61194a565b9050611bf68282611baf565b919050565b600067ffffffffffffffff821115611c1657611c15611b80565b5b602082029050602081019050919050565b600080fd5b600080fd5b600060408284031215611c4757611c46611c2c565b5b611c516040611be0565b90506000611c61848285016119a7565b6000830152506020611c7584828501611b10565b60208301525092915050565b6000611c94611c8f84611bfb565b611be0565b90508083825260208201905060408402830185811115611cb757611cb6611c27565b5b835b81811015611ce05780611ccc8882611c31565b845260208401935050604081019050611cb9565b5050509392505050565b600082601f830112611cff57611cfe611b7b565b5b8135611d0f848260208601611c81565b91505092915050565b60008060008060008060c08789031215611d3557611d34611954565b5b6000611d4389828a016119a7565b9650506020611d5489828a01611b10565b9550506040611d6589828a016119a7565b9450506060611d7689828a016119a7565b935050608087013567ffffffffffffffff811115611d9757611d96611959565b5b611da389828a01611cea565b92505060a0611db489828a016119a7565b9150509295509295509295565b6000819050919050565b6000611de6611de1611ddc8461195e565b611dc1565b61195e565b9050919050565b6000611df882611dcb565b9050919050565b6000611e0a82611ded565b9050919050565b611e1a81611dff565b82525050565b6000602082019050611e356000830184611e11565b92915050565b600080fd5b60008083601f840112611e5657611e55611b7b565b5b8235905067ffffffffffffffff811115611e7357611e72611e3b565b5b602083019150836001820283011115611e8f57611e8e611c27565b5b9250929050565b60008060008060008060a08789031215611eb357611eb2611954565b5b6000611ec189828a01611b10565b9650506020611ed289828a01611b10565b9550506040611ee389828a01611b10565b9450506060611ef489828a01611b10565b935050608087013567ffffffffffffffff811115611f1557611f14611959565b5b611f2189828a01611e40565b92509250509295509295509295565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000611f6a826119e9565b9150611f75836119e9565b9250828201905080821115611f8d57611f8c611f30565b5b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f50617961626c653a205468652063616c6c6572206973206e6f7420616e20616c60008201527f6c6f776564207769746864726177657200000000000000000000000000000000602082015250565b600061201e603083611a52565b915061202982611fc2565b604082019050919050565b6000602082019050818103600083015261204d81612011565b9050919050565b600081905092915050565b50565b600061206f600083612054565b915061207a8261205f565b600082019050919050565b600061209082612062565b9150819050919050565b7f50617961626c653a205472616e73666572206661696c65640000000000000000600082015250565b60006120d0601883611a52565b91506120db8261209a565b602082019050919050565b600060208201905081810360008301526120ff816120c3565b9050919050565b7f436f6e747261637420616c726561647920696e697469616c697a65642e000000600082015250565b600061213c601d83611a52565b915061214782612106565b602082019050919050565b6000602082019050818103600083015261216b8161212f565b9050919050565b600081519050919050565b600061218882612172565b6121928185612054565b93506121a2818560208601611a63565b80840191505092915050565b60006121ba828461217d565b915081905092915050565b7f43616c6c20746f20746f74616c537570706c79206661696c6564000000000000600082015250565b60006121fb601a83611a52565b9150612206826121c5565b602082019050919050565b6000602082019050818103600083015261222a816121ee565b9050919050565b60008151905061224081611af9565b92915050565b60006020828403121561225c5761225b611954565b5b600061226a84828501612231565b91505092915050565b600061227e826119e9565b9150612289836119e9565b92508282039050818111156122a1576122a0611f30565b5b92915050565b6000819050919050565b6122c26122bd826119e9565b6122a7565b82525050565b60006122d482866122b1565b6020820191506122e482856122b1565b6020820191506122f482846122b1565b602082019150819050949350505050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b61233a816119e9565b82525050565b600061234c8383612331565b60208301905092915050565b6000602082019050919050565b600061237082612305565b61237a8185612310565b935061238583612321565b8060005b838110156123b657815161239d8882612340565b97506123a883612358565b925050600181019050612389565b5085935050505092915050565b60006040820190506123d86000830185611a1d565b81810360208301526123ea8184612365565b90509392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b600061242d826119e9565b9150612438836119e9565b925082612448576124476123f3565b5b828204905092915050565b600061245e826119e9565b9150612469836119e9565b925082612479576124786123f3565b5b828206905092915050565b600061248f826119e9565b915061249a836119e9565b92508282026124a8816119e9565b915082820484148315176124bf576124be611f30565b5b5092915050565b7f5369676e617475726550726f7465637465643a20496e76616c6964207369676e60008201527f617475726520666f72207468652063616c6c6572000000000000000000000000602082015250565b6000612522603483611a52565b915061252d826124c6565b604082019050919050565b6000602082019050818103600083015261255181612515565b9050919050565b7f537570706c79436f6e74726f6c3a204e6f20746f6b656e73206c65667420746f60008201527f206d696e74000000000000000000000000000000000000000000000000000000602082015250565b60006125b4602583611a52565b91506125bf82612558565b604082019050919050565b600060208201905081810360008301526125e3816125a7565b9050919050565b7f4c696d697450657257616c6c65743a205468652063616c6c657220616464726560008201527f73732063616e206e6f74206d696e74206d6f726520746f6b656e730000000000602082015250565b6000612646603b83611a52565b9150612651826125ea565b604082019050919050565b6000602082019050818103600083015261267581612639565b9050919050565b7f50617961626c653a204e6f7420656e6f7567682045746865722070726f76696460008201527f656420746f206d696e7400000000000000000000000000000000000000000000602082015250565b60006126d8602a83611a52565b91506126e38261267c565b604082019050919050565b60006020820190508181036000830152612707816126cb565b9050919050565b60008160601b9050919050565b60006127268261270e565b9050919050565b60006127388261271b565b9050919050565b61275061274b8261197e565b61272d565b82525050565b6000612762828561273f565b601482019150612772828461273f565b6014820191508190509392505050565b600061278e828561217d565b915061279a828461217d565b91508190509392505050565b600081905092915050565b7f19457468657265756d205369676e6564204d6573736167653a0a333200000000600082015250565b60006127e7601c836127a6565b91506127f2826127b1565b601c82019050919050565b6000819050919050565b6000819050919050565b61282261281d826127fd565b612807565b82525050565b6000612833826127da565b915061283f8284612811565b60208201915081905092915050565b60006128598261195e565b9050919050565b600061286b8261271b565b9050919050565b61288361287e8261284e565b612860565b82525050565b600061289582886122b1565b6020820191506128a58287612811565b6020820191506128b58286612872565b6014820191506128c582856122b1565b6020820191506128d5828461273f565b6014820191508190509695505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b612920816127fd565b82525050565b600060208201905061293b6000830184612917565b92915050565b600060ff82169050919050565b61295781612941565b82525050565b60006080820190506129726000830187612917565b61297f602083018661294e565b61298c6040830185612917565b6129996060830184612917565b9594505050505056fea264697066735822122099ac1e7a422622417c0918fdbd77b42ae08ce82eafffdae2f28581f0552e7cf664736f6c63430008180033

Deployed Bytecode

0x6080604052600436106100fe5760003560e01c80638da5cb5b11610095578063d638aefb11610064578063d638aefb14610302578063d7c97fb41461032b578063e35568cb14610356578063f2fde38b14610381578063f8ea8f16146103aa576100fe565b80638da5cb5b14610243578063cb2ef6f71461026e578063d1bc76a114610299578063d5abeb01146102d7576100fe565b80634d0df5fc116100d15780634d0df5fc1461019957806354fd4d50146101d65780635b7633d014610201578063715018a61461022c576100fe565b8063046dc166146101035780632df3eba41461012c5780633ccfd60b14610157578063469048401461016e575b600080fd5b34801561010f57600080fd5b5061012a600480360381019061012591906119bc565b6103c6565b005b34801561013857600080fd5b50610141610412565b60405161014e9190611a02565b60405180910390f35b34801561016357600080fd5b5061016c610427565b005b34801561017a57600080fd5b5061018361066a565b6040516101909190611a2c565b60405180910390f35b3480156101a557600080fd5b506101c060048036038101906101bb91906119bc565b61068e565b6040516101cd9190611a02565b60405180910390f35b3480156101e257600080fd5b506101eb6106a6565b6040516101f89190611ad7565b60405180910390f35b34801561020d57600080fd5b506102166106df565b6040516102239190611a2c565b60405180910390f35b34801561023857600080fd5b50610241610705565b005b34801561024f57600080fd5b50610258610719565b6040516102659190611a2c565b60405180910390f35b34801561027a57600080fd5b50610283610743565b6040516102909190611ad7565b60405180910390f35b3480156102a557600080fd5b506102c060048036038101906102bb9190611b25565b61077c565b6040516102ce929190611b52565b60405180910390f35b3480156102e357600080fd5b506102ec6107d0565b6040516102f99190611a02565b60405180910390f35b34801561030e57600080fd5b5061032960048036038101906103249190611d18565b6107d6565b005b34801561033757600080fd5b506103406108b5565b60405161034d9190611e20565b60405180910390f35b34801561036257600080fd5b5061036b6108db565b6040516103789190611a02565b60405180910390f35b34801561038d57600080fd5b506103a860048036038101906103a391906119bc565b610a56565b005b6103c460048036038101906103bf9190611e96565b610adc565b005b6103ce610cfa565b80600660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000476001546104229190611f5f565b905090565b6000805b6002805490508110156104c6573373ffffffffffffffffffffffffffffffffffffffff166002828154811061046357610462611f93565b5b906000526020600020906002020160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16036104b957600191506104c6565b808060010191505061042b565b5080610507576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104fe90612034565b60405180910390fd5b6000479050806001600082825461051e9190611f5f565b9250508190555060005b6002805490508110156106655760006002828154811061054b5761054a611f93565b5b906000526020600020906002020160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166105c584600285815481106105ab576105aa611f93565b5b906000526020600020906002020160010154612710610d81565b6040516105d190612085565b60006040518083038185875af1925050503d806000811461060e576040519150601f19603f3d011682016040523d82523d6000602084013e610613565b606091505b5050905080610657576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161064e906120e6565b60405180910390fd5b508080600101915050610528565b505050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60046020528060005260406000206000915090505481565b6040518060400160405280600581526020017f312e302e3000000000000000000000000000000000000000000000000000000081525081565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b61070d610cfa565b6107176000610e33565b565b6000600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6040518060400160405280601181526020017f52414e444f4d2d4d494e5445522d37323100000000000000000000000000000081525081565b6002818154811061078c57600080fd5b90600052602060002090600202016000915090508060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16908060010154905082565b60035481565b60001515600860149054906101000a900460ff1615151461082c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161082390612152565b60405180910390fd5b61083586610e33565b61083e85610ef9565b61084784610f03565b6108518383610f47565b80600860006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506001600860146101000a81548160ff021916908315150217905550505050505050565b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000806000600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166040516024016040516020818303038152906040527fa2309ff8000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516109a991906121ae565b600060405180830381855afa9150503d80600081146109e4576040519150601f19603f3d011682016040523d82523d6000602084013e6109e9565b606091505b509150915081610a2e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a2590612211565b60405180910390fd5b80806020019051810190610a429190612246565b600354610a4f9190612273565b9250505090565b610a5e610cfa565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603610ad05760006040517f1e4fbdf7000000000000000000000000000000000000000000000000000000008152600401610ac79190611a2c565b60405180910390fd5b610ad981610e33565b50565b610b0a858585604051602001610af4939291906122c8565b604051602081830303815290604052838361103e565b6000600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a2309ff86040518163ffffffff1660e01b81526004016020604051808303816000875af1158015610b7b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b9f9190612246565b9050610bab8782611128565b9650610bb7878761119a565b9650610bc48786866112ee565b60008767ffffffffffffffff811115610be057610bdf611b80565b5b604051908082528060200260200182016040528015610c0e5781602001602082028036833780820191505090505b50905060005b8151811015610c6057610c348184610c2c9190611f5f565b60035461149c565b828281518110610c4757610c46611f93565b5b6020026020010181815250508080600101915050610c14565b50600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663de836ebd33836040518363ffffffff1660e01b8152600401610cbe9291906123c3565b600060405180830381600087803b158015610cd857600080fd5b505af1158015610cec573d6000803e3d6000fd5b505050505050505050505050565b610d02611585565b73ffffffffffffffffffffffffffffffffffffffff16610d20610719565b73ffffffffffffffffffffffffffffffffffffffff1614610d7f57610d43611585565b6040517f118cdaa7000000000000000000000000000000000000000000000000000000008152600401610d769190611a2c565b60405180910390fd5b565b6000808285610d909190612422565b905060008386610da09190612453565b905060008486610db09190612422565b905060008587610dc09190612453565b9050858184610dcf9190612484565b610dd99190612422565b8284610de59190612484565b8286610df19190612484565b888588610dfe9190612484565b610e089190612484565b610e129190611f5f565b610e1c9190611f5f565b610e269190611f5f565b9450505050509392505050565b6000600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b8060038190555050565b80600660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060005b8151811015611039576002828281518110610fa857610fa7611f93565b5b6020026020010151908060018154018082558091505060019003906000526020600020906002020160009091909190915060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506020820151816001015550508080600101915050610f8a565b505050565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166110cd6110838561158d565b84848080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050611611565b73ffffffffffffffffffffffffffffffffffffffff1614611123576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161111a90612538565b60405180910390fd5b505050565b600080826003546111399190612273565b90506000811161117e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611175906125ca565b60405180910390fd5b8381101561118f5780915050611194565b839150505b92915050565b60008082036111ab578290506112e8565b8183600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546111f79190611f5f565b111561124b57600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054826112489190612273565b92505b6000831161128e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112859061265c565b60405180910390fd5b82600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546112dd9190611f5f565b925050819055508290505b92915050565b600082846112fc9190612484565b90506000828561130c9190612484565b90506000818361131c9190611f5f565b905080341015611361576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611358906126ee565b60405180910390fd5b803411156113bc573373ffffffffffffffffffffffffffffffffffffffff166108fc823461138f9190612273565b9081150290604051600060405180830381858888f193505050501580156113ba573d6000803e3d6000fd5b505b60008211156114945760008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168360405161140c90612085565b60006040518083038185875af1925050503d8060008114611449576040519150601f19603f3d011682016040523d82523d6000602084013e61144e565b606091505b5050905080611492576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611489906120e6565b60405180910390fd5b505b505050505050565b60008083836114ab9190612273565b905060006114b9828661163d565b905060006007600083815260200190815260200160002054905060006007600084815260200190815260200160002054036114f2578190505b6000600760006001866115059190612273565b81526020019081526020016000205414611554576007600060018561152a9190612273565b81526020019081526020016000205460076000848152602001908152602001600020819055611578565b6001836115619190612273565b600760008481526020019081526020016000208190555b5080935050505092915050565b600033905090565b60008030336040516020016115a3929190612756565b604051602081830303815290604052836040516020016115c4929190612782565b6040516020818303038152906040528051906020012090506000816040516020016115ef9190612828565b6040516020818303038152906040529050808051906020012092505050919050565b6000806000806116218686611696565b92509250925061163182826116f2565b82935050505092915050565b6000808260014361164e9190612273565b40414433604051602001611666959493929190612889565b6040516020818303038152906040528051906020012060001c9050838161168d9190612453565b91505092915050565b600080600060418451036116db5760008060006020870151925060408701519150606087015160001a90506116cd88828585611856565b9550955095505050506116eb565b60006002855160001b9250925092505b9250925092565b60006003811115611706576117056128e8565b5b826003811115611719576117186128e8565b5b03156118525760016003811115611733576117326128e8565b5b826003811115611746576117456128e8565b5b0361177d576040517ff645eedf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60026003811115611791576117906128e8565b5b8260038111156117a4576117a36128e8565b5b036117e9578060001c6040517ffce698f70000000000000000000000000000000000000000000000000000000081526004016117e09190611a02565b60405180910390fd5b6003808111156117fc576117fb6128e8565b5b82600381111561180f5761180e6128e8565b5b0361185157806040517fd78bce0c0000000000000000000000000000000000000000000000000000000081526004016118489190612926565b60405180910390fd5b5b5050565b60008060007f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08460001c1115611896576000600385925092509250611940565b6000600188888888604051600081526020016040526040516118bb949392919061295d565b6020604051602081039080840390855afa1580156118dd573d6000803e3d6000fd5b505050602060405103519050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff160361193157600060016000801b93509350935050611940565b8060008060001b935093509350505b9450945094915050565b6000604051905090565b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006119898261195e565b9050919050565b6119998161197e565b81146119a457600080fd5b50565b6000813590506119b681611990565b92915050565b6000602082840312156119d2576119d1611954565b5b60006119e0848285016119a7565b91505092915050565b6000819050919050565b6119fc816119e9565b82525050565b6000602082019050611a1760008301846119f3565b92915050565b611a268161197e565b82525050565b6000602082019050611a416000830184611a1d565b92915050565b600081519050919050565b600082825260208201905092915050565b60005b83811015611a81578082015181840152602081019050611a66565b60008484015250505050565b6000601f19601f8301169050919050565b6000611aa982611a47565b611ab38185611a52565b9350611ac3818560208601611a63565b611acc81611a8d565b840191505092915050565b60006020820190508181036000830152611af18184611a9e565b905092915050565b611b02816119e9565b8114611b0d57600080fd5b50565b600081359050611b1f81611af9565b92915050565b600060208284031215611b3b57611b3a611954565b5b6000611b4984828501611b10565b91505092915050565b6000604082019050611b676000830185611a1d565b611b7460208301846119f3565b9392505050565b600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b611bb882611a8d565b810181811067ffffffffffffffff82111715611bd757611bd6611b80565b5b80604052505050565b6000611bea61194a565b9050611bf68282611baf565b919050565b600067ffffffffffffffff821115611c1657611c15611b80565b5b602082029050602081019050919050565b600080fd5b600080fd5b600060408284031215611c4757611c46611c2c565b5b611c516040611be0565b90506000611c61848285016119a7565b6000830152506020611c7584828501611b10565b60208301525092915050565b6000611c94611c8f84611bfb565b611be0565b90508083825260208201905060408402830185811115611cb757611cb6611c27565b5b835b81811015611ce05780611ccc8882611c31565b845260208401935050604081019050611cb9565b5050509392505050565b600082601f830112611cff57611cfe611b7b565b5b8135611d0f848260208601611c81565b91505092915050565b60008060008060008060c08789031215611d3557611d34611954565b5b6000611d4389828a016119a7565b9650506020611d5489828a01611b10565b9550506040611d6589828a016119a7565b9450506060611d7689828a016119a7565b935050608087013567ffffffffffffffff811115611d9757611d96611959565b5b611da389828a01611cea565b92505060a0611db489828a016119a7565b9150509295509295509295565b6000819050919050565b6000611de6611de1611ddc8461195e565b611dc1565b61195e565b9050919050565b6000611df882611dcb565b9050919050565b6000611e0a82611ded565b9050919050565b611e1a81611dff565b82525050565b6000602082019050611e356000830184611e11565b92915050565b600080fd5b60008083601f840112611e5657611e55611b7b565b5b8235905067ffffffffffffffff811115611e7357611e72611e3b565b5b602083019150836001820283011115611e8f57611e8e611c27565b5b9250929050565b60008060008060008060a08789031215611eb357611eb2611954565b5b6000611ec189828a01611b10565b9650506020611ed289828a01611b10565b9550506040611ee389828a01611b10565b9450506060611ef489828a01611b10565b935050608087013567ffffffffffffffff811115611f1557611f14611959565b5b611f2189828a01611e40565b92509250509295509295509295565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000611f6a826119e9565b9150611f75836119e9565b9250828201905080821115611f8d57611f8c611f30565b5b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f50617961626c653a205468652063616c6c6572206973206e6f7420616e20616c60008201527f6c6f776564207769746864726177657200000000000000000000000000000000602082015250565b600061201e603083611a52565b915061202982611fc2565b604082019050919050565b6000602082019050818103600083015261204d81612011565b9050919050565b600081905092915050565b50565b600061206f600083612054565b915061207a8261205f565b600082019050919050565b600061209082612062565b9150819050919050565b7f50617961626c653a205472616e73666572206661696c65640000000000000000600082015250565b60006120d0601883611a52565b91506120db8261209a565b602082019050919050565b600060208201905081810360008301526120ff816120c3565b9050919050565b7f436f6e747261637420616c726561647920696e697469616c697a65642e000000600082015250565b600061213c601d83611a52565b915061214782612106565b602082019050919050565b6000602082019050818103600083015261216b8161212f565b9050919050565b600081519050919050565b600061218882612172565b6121928185612054565b93506121a2818560208601611a63565b80840191505092915050565b60006121ba828461217d565b915081905092915050565b7f43616c6c20746f20746f74616c537570706c79206661696c6564000000000000600082015250565b60006121fb601a83611a52565b9150612206826121c5565b602082019050919050565b6000602082019050818103600083015261222a816121ee565b9050919050565b60008151905061224081611af9565b92915050565b60006020828403121561225c5761225b611954565b5b600061226a84828501612231565b91505092915050565b600061227e826119e9565b9150612289836119e9565b92508282039050818111156122a1576122a0611f30565b5b92915050565b6000819050919050565b6122c26122bd826119e9565b6122a7565b82525050565b60006122d482866122b1565b6020820191506122e482856122b1565b6020820191506122f482846122b1565b602082019150819050949350505050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b61233a816119e9565b82525050565b600061234c8383612331565b60208301905092915050565b6000602082019050919050565b600061237082612305565b61237a8185612310565b935061238583612321565b8060005b838110156123b657815161239d8882612340565b97506123a883612358565b925050600181019050612389565b5085935050505092915050565b60006040820190506123d86000830185611a1d565b81810360208301526123ea8184612365565b90509392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b600061242d826119e9565b9150612438836119e9565b925082612448576124476123f3565b5b828204905092915050565b600061245e826119e9565b9150612469836119e9565b925082612479576124786123f3565b5b828206905092915050565b600061248f826119e9565b915061249a836119e9565b92508282026124a8816119e9565b915082820484148315176124bf576124be611f30565b5b5092915050565b7f5369676e617475726550726f7465637465643a20496e76616c6964207369676e60008201527f617475726520666f72207468652063616c6c6572000000000000000000000000602082015250565b6000612522603483611a52565b915061252d826124c6565b604082019050919050565b6000602082019050818103600083015261255181612515565b9050919050565b7f537570706c79436f6e74726f6c3a204e6f20746f6b656e73206c65667420746f60008201527f206d696e74000000000000000000000000000000000000000000000000000000602082015250565b60006125b4602583611a52565b91506125bf82612558565b604082019050919050565b600060208201905081810360008301526125e3816125a7565b9050919050565b7f4c696d697450657257616c6c65743a205468652063616c6c657220616464726560008201527f73732063616e206e6f74206d696e74206d6f726520746f6b656e730000000000602082015250565b6000612646603b83611a52565b9150612651826125ea565b604082019050919050565b6000602082019050818103600083015261267581612639565b9050919050565b7f50617961626c653a204e6f7420656e6f7567682045746865722070726f76696460008201527f656420746f206d696e7400000000000000000000000000000000000000000000602082015250565b60006126d8602a83611a52565b91506126e38261267c565b604082019050919050565b60006020820190508181036000830152612707816126cb565b9050919050565b60008160601b9050919050565b60006127268261270e565b9050919050565b60006127388261271b565b9050919050565b61275061274b8261197e565b61272d565b82525050565b6000612762828561273f565b601482019150612772828461273f565b6014820191508190509392505050565b600061278e828561217d565b915061279a828461217d565b91508190509392505050565b600081905092915050565b7f19457468657265756d205369676e6564204d6573736167653a0a333200000000600082015250565b60006127e7601c836127a6565b91506127f2826127b1565b601c82019050919050565b6000819050919050565b6000819050919050565b61282261281d826127fd565b612807565b82525050565b6000612833826127da565b915061283f8284612811565b60208201915081905092915050565b60006128598261195e565b9050919050565b600061286b8261271b565b9050919050565b61288361287e8261284e565b612860565b82525050565b600061289582886122b1565b6020820191506128a58287612811565b6020820191506128b58286612872565b6014820191506128c582856122b1565b6020820191506128d5828461273f565b6014820191508190509695505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b612920816127fd565b82525050565b600060208201905061293b6000830184612917565b92915050565b600060ff82169050919050565b61295781612941565b82525050565b60006080820190506129726000830187612917565b61297f602083018661294e565b61298c6040830185612917565b6129996060830184612917565b9594505050505056fea264697066735822122099ac1e7a422622417c0918fdbd77b42ae08ce82eafffdae2f28581f0552e7cf664736f6c63430008180033

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

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

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