ETH Price: $3,438.93 (+1.72%)
Gas: 3 Gwei

Contract

0x9DBd0FFD43A3D440CEc5Eb76c3dc02B9eeA56912
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Value
Buy With Referra...186983452023-12-02 11:12:59211 days ago1701515579IN
0x9DBd0FFD...9eeA56912
0.25 ETH0.0007377823.56
Buy With Referra...186944782023-12-01 22:15:23212 days ago1701468923IN
0x9DBd0FFD...9eeA56912
0.25 ETH0.0009186628.87521717
Buy With Referra...186934422023-12-01 18:46:47212 days ago1701456407IN
0x9DBd0FFD...9eeA56912
0.069 ETH0.0013754343.93925604
Buy With Referra...186934242023-12-01 18:43:11212 days ago1701456191IN
0x9DBd0FFD...9eeA56912
0.25 ETH0.0015657550
Buy With Referra...186926132023-12-01 16:00:11212 days ago1701446411IN
0x9DBd0FFD...9eeA56912
0.245 ETH0.0025974682.91462745
Buy With Referra...186926112023-12-01 15:59:47212 days ago1701446387IN
0x9DBd0FFD...9eeA56912
0.25 ETH0.0058478183.91537615
Buy With Referra...186926112023-12-01 15:59:47212 days ago1701446387IN
0x9DBd0FFD...9eeA56912
0.07 ETH0.0058484283.92537615
Buy With Referra...186926092023-12-01 15:59:23212 days ago1701446363IN
0x9DBd0FFD...9eeA56912
0.1 ETH0.0055363179.45908309
Buy With Referra...186926092023-12-01 15:59:23212 days ago1701446363IN
0x9DBd0FFD...9eeA56912
0.2274 ETH0.0055363179.45908309
Buy With Referra...186926082023-12-01 15:59:11212 days ago1701446351IN
0x9DBd0FFD...9eeA56912
0.25 ETH0.0057223282.12993526
Buy With Referra...186926072023-12-01 15:58:59212 days ago1701446339IN
0x9DBd0FFD...9eeA56912
0.05 ETH0.0056140580.55866614
Buy With Referra...186926072023-12-01 15:58:59212 days ago1701446339IN
0x9DBd0FFD...9eeA56912
0.25 ETH0.0056140580.55866614
Buy With Referra...186926062023-12-01 15:58:47212 days ago1701446327IN
0x9DBd0FFD...9eeA56912
0.25 ETH0.0062023289
Buy With Referra...186926052023-12-01 15:58:35212 days ago1701446315IN
0x9DBd0FFD...9eeA56912
0.23 ETH0.0056702681.42373152
Buy With Referra...186926032023-12-01 15:58:11212 days ago1701446291IN
0x9DBd0FFD...9eeA56912
0.25 ETH0.0054393277.1349043
Buy With Referra...186926032023-12-01 15:58:11212 days ago1701446291IN
0x9DBd0FFD...9eeA56912
0.12 ETH0.0061311388
Buy With Referra...186926022023-12-01 15:57:59212 days ago1701446279IN
0x9DBd0FFD...9eeA56912
0.2274 ETH0.0053886477.31314828
Buy With Referra...186926022023-12-01 15:57:59212 days ago1701446279IN
0x9DBd0FFD...9eeA56912
0.25 ETH0.0053857877.31314828
Buy With Referra...186926002023-12-01 15:57:35212 days ago1701446255IN
0x9DBd0FFD...9eeA56912
0.06003616 ETH0.0051379673.72600772
Buy With Referra...186926002023-12-01 15:57:35212 days ago1701446255IN
0x9DBd0FFD...9eeA56912
0.23 ETH0.005141373.77600772
Buy With Referra...186925992023-12-01 15:57:23212 days ago1701446243IN
0x9DBd0FFD...9eeA56912
0.248 ETH0.005189674.45528788
Buy With Referra...186925992023-12-01 15:57:23212 days ago1701446243IN
0x9DBd0FFD...9eeA56912
0.2 ETH0.0051884974.45528788
Buy With Referra...186925982023-12-01 15:57:11212 days ago1701446231IN
0x9DBd0FFD...9eeA56912
0.232 ETH0.0051823574.37892976
Buy With Referra...186925962023-12-01 15:56:47212 days ago1701446207IN
0x9DBd0FFD...9eeA56912
0.25 ETH0.0052409675.20402567
Buy With Referra...186925962023-12-01 15:56:47212 days ago1701446207IN
0x9DBd0FFD...9eeA56912
0.25 ETH0.0052449775.25402567
View all transactions

Latest 25 internal transactions (View All)

Advanced mode:
Parent Transaction Hash Block From To Value
186926112023-12-01 15:59:47212 days ago1701446387
0x9DBd0FFD...9eeA56912
0.25 ETH
186926112023-12-01 15:59:47212 days ago1701446387
0x9DBd0FFD...9eeA56912
0.07 ETH
186926092023-12-01 15:59:23212 days ago1701446363
0x9DBd0FFD...9eeA56912
0.1 ETH
186926092023-12-01 15:59:23212 days ago1701446363
0x9DBd0FFD...9eeA56912
0.2274 ETH
186926082023-12-01 15:59:11212 days ago1701446351
0x9DBd0FFD...9eeA56912
0.25 ETH
186926072023-12-01 15:58:59212 days ago1701446339
0x9DBd0FFD...9eeA56912
0.05 ETH
186926072023-12-01 15:58:59212 days ago1701446339
0x9DBd0FFD...9eeA56912
0.25 ETH
186926062023-12-01 15:58:47212 days ago1701446327
0x9DBd0FFD...9eeA56912
0.25 ETH
186926052023-12-01 15:58:35212 days ago1701446315
0x9DBd0FFD...9eeA56912
0.23 ETH
186926032023-12-01 15:58:11212 days ago1701446291
0x9DBd0FFD...9eeA56912
0.25 ETH
186926032023-12-01 15:58:11212 days ago1701446291
0x9DBd0FFD...9eeA56912
0.12 ETH
186926022023-12-01 15:57:59212 days ago1701446279
0x9DBd0FFD...9eeA56912
0.2274 ETH
186926022023-12-01 15:57:59212 days ago1701446279
0x9DBd0FFD...9eeA56912
0.25 ETH
186926002023-12-01 15:57:35212 days ago1701446255
0x9DBd0FFD...9eeA56912
0.06003616 ETH
186926002023-12-01 15:57:35212 days ago1701446255
0x9DBd0FFD...9eeA56912
0.23 ETH
186925992023-12-01 15:57:23212 days ago1701446243
0x9DBd0FFD...9eeA56912
0.248 ETH
186925992023-12-01 15:57:23212 days ago1701446243
0x9DBd0FFD...9eeA56912
0.2 ETH
186925982023-12-01 15:57:11212 days ago1701446231
0x9DBd0FFD...9eeA56912
0.232 ETH
186925962023-12-01 15:56:47212 days ago1701446207
0x9DBd0FFD...9eeA56912
0.25 ETH
186925962023-12-01 15:56:47212 days ago1701446207
0x9DBd0FFD...9eeA56912
0.25 ETH
186925952023-12-01 15:56:35212 days ago1701446195
0x9DBd0FFD...9eeA56912
0.25 ETH
186925952023-12-01 15:56:35212 days ago1701446195
0x9DBd0FFD...9eeA56912
0.25 ETH
186925942023-12-01 15:56:23212 days ago1701446183
0x9DBd0FFD...9eeA56912
0.25 ETH
186925932023-12-01 15:56:11212 days ago1701446171
0x9DBd0FFD...9eeA56912
0.25 ETH
186925932023-12-01 15:56:11212 days ago1701446171
0x9DBd0FFD...9eeA56912
0.23 ETH
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
GrapePreSale

Compiler Version
v0.8.20+commit.a1b79de6

Optimization Enabled:
Yes with 200 runs

Other Settings:
paris EvmVersion, None license
File 1 of 28 : GrapePreSale.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.20;

import '@openzeppelin/contracts/token/ERC721/IERC721.sol';
import '@openzeppelin/contracts/access/Ownable.sol';
import '@openzeppelin/contracts/utils/cryptography/MerkleProof.sol';
import '@openzeppelin/contracts/utils/math/Math.sol';
import '@openzeppelin/contracts/utils/Pausable.sol';
import './IDelegateRegistry.sol';
import './IDelegationRegistry.sol';

contract GrapePreSale is Ownable, Pausable {
    /**
     * @dev Public immutable state
     */
    IERC721 public immutable grapeNFT;
    uint256 public immutable minimumSpendAmount; // must be in WEI. set by constructor only
    bytes32 public immutable referralCodeMerkleRoot;
    uint256 public immutable referralCapPerBuyer; // must be in WEI. set by constructor only
    uint256 public immutable capPerNFT; // must be in WEI. set by constructor only
    uint256 public immutable nftStartDate;
    uint256 public immutable referralStartDate;
    uint256 public immutable endDate;
    uint256 public immutable nftSaleCap;
    address payable public immutable receiverWallet;
    IDelegateRegistry public immutable delegateRegistryV2 =
        IDelegateRegistry(0x00000000000000447e69651d841bD8D104Bed493);
    IDelegationRegistry public immutable delegateRegistryV1 =
        IDelegationRegistry(0x00000000000076A84feF008CDAbe6409d2FE638B);

    /**
     * @dev Public mutable state
     */
    uint256 public nftSoldSupply = 0; // managed internally
    mapping(uint256 tokenId => uint256 amount) public nftPurchases; // managed internally
    mapping(address buyer => uint256 amount) public referralPurchases; // managed internally

    /**
     * @notice Emitted when a purchase is made with an NFT
     */
    event PurchaseWithNFT(address indexed buyer, uint256 amount);

    /**
     * @notice Emitted when a purchase is made with a referral code
     */
    event PurchaseWithReferralCode(address indexed buyer, uint256 amount);

    /**
     * @dev Errors
     */
    error BelowMinimumSpend();
    error Closed();
    error AmountExceedsSupply();
    error NotTokenOwner(uint256 tokenId);
    error InvalidPaymentAmount();
    error InvalidReferralCode();

    /**
     * @notice Creates a new instance of the GrapePreSale contract.
     * @param grapeNFTAddress_ The address of the ERC721 token (Grape NFT) involved in the pre-sale.
     * @param initialOwner_ The initial owner of the contract, typically the deployer or the main administrative account.
     * @param receiverWallet_ The wallet address where funds (ETH) collected from the pre-sale will be sent.
     * @param referralCodeMerkleRoot_ The root of the Merkle tree used for validating referral codes.
     * @param config_ Array containing the following config in order:
     *        referralCapPerBuyer: The maximum amount of WEI a buyer can spend using referral codes.
     *        capPerNFT: The maximum amount of WEI that can be spent per NFT in the pre-sale.
     *        nftStartDate: The start date of the NFT pre-sale, represented as a Unix timestamp.
     *        referralStartDate: The start date of the referral pre-sale, represented as a Unix timestamp.
     *        endDate: The end date of the pre-sale, represented as a Unix timestamp.
     *        minimumSpendAmount: The minimum amount of WEI that can be spent in the pre-sale.
     *        nftSaleCap: The maximum amount of WEI that can be spend for NFT purchases.
     */
    constructor(
        address grapeNFTAddress_,
        address initialOwner_,
        address payable receiverWallet_,
        bytes32 referralCodeMerkleRoot_,
        uint256[7] memory config_
    ) Ownable(initialOwner_) {
        grapeNFT = IERC721(grapeNFTAddress_);
        receiverWallet = receiverWallet_;
        referralCodeMerkleRoot = referralCodeMerkleRoot_;
        referralCapPerBuyer = config_[0];
        capPerNFT = config_[1];
        nftStartDate = config_[2];
        referralStartDate = config_[3];
        endDate = config_[4];
        minimumSpendAmount = config_[5];
        nftSaleCap = config_[6];
    }

    /**
     * @dev Modifiers
     */

    /**
     * @notice Require the amount to spend to be greater than the minimum spend value
     */
    modifier checkMinimumSpend() {
        if (msg.value < minimumSpendAmount) revert BelowMinimumSpend();
        _;
    }

    /**
     * @dev Public functions
     */

    /**
     * @notice Allows a buyer to purchase with a list of NFTs
     * @dev This function calculates the total amount of Ether sent and ensures it does not exceed the NFT Sale Cap.
     *      It checks each NFT provided, verifies ownership, and calculates the amount included for each NFT.
     *      It reverts if the NFT is not owned by the sender or their delegate, if the NFT Sale Cap is reached,
     *      or if the payment amount is not valid.
     * @param tokenIds_ An array of token IDs which the buyer uses to make the purchase.
     */
    function buyWithNFTs(
        uint256[] calldata tokenIds_
    ) external payable whenNotPaused checkMinimumSpend {
        // check if the nft sale is closed
        if (block.timestamp < nftStartDate || block.timestamp > endDate) {
            revert Closed();
        }

        // calculate new nft sold supply
        uint256 _newNftSoldSupply = nftSoldSupply + msg.value;

        // verify nft sold supply is not greater than the nft sale cap
        if (_newNftSoldSupply > nftSaleCap) {
            revert AmountExceedsSupply();
        }

        // update nft sold supply
        nftSoldSupply = _newNftSoldSupply;

        // track amount included in NFT
        uint256 _amountIncluded = 0;

        // check each provided NFTs
        uint256 _i;
        do {
            uint256 _tokenId = tokenIds_[_i];

            // verify tokenId is owned by sender
            _verifyTokenOwner(_tokenId);

            // grab current NFT purchase amount
            uint256 _nftPurchaseAmount = nftPurchases[_tokenId];

            // calculate how much amount can be used for this NFT
            uint256 _maxAmount = Math.min(
                capPerNFT - _nftPurchaseAmount, // maximum the cap per NFT minus the amount previously purchase with this NFT
                msg.value - _amountIncluded // otherwise the difference between the total amount and the amount already included in other NFT
            );

            // update amount used for this NFT
            nftPurchases[_tokenId] = _nftPurchaseAmount + _maxAmount;

            // increase amount included
            _amountIncluded += _maxAmount;
        } while (++_i < tokenIds_.length && _amountIncluded < msg.value);

        // check amount is fully included across the NFTs
        if (_amountIncluded != msg.value) {
            revert InvalidPaymentAmount();
        }

        // transfer ETH to receiver wallet
        receiverWallet.transfer(_amountIncluded);

        // emit event
        emit PurchaseWithNFT(msg.sender, _amountIncluded);
    }

    /**
     * @notice Allows a buyer to purchase using a referral code.
     * @dev This function allows users to buy with a referral code and ensures purchases per wallet do not exceed the referralCapPerBuyer
     *      It validates the referral code and calculates the total sold per wallet.
     *      It transfers the ETH to the receiver wallet.
     * @param referralCode_ An array of bytes32 representing the referral code used for the purchase.
     */
    function buyWithReferralCode(
        bytes32[] calldata referralCode_
    ) external payable whenNotPaused checkMinimumSpend {
        // check if the referral sale is closed
        if (block.timestamp < referralStartDate || block.timestamp > endDate) {
            revert Closed();
        }

        // verify referral code is valid
        if (!verifyReferralCode(msg.sender, referralCode_)) {
            revert InvalidReferralCode();
        }

        // calculate new referral purchase for this sender
        uint256 _newReferralPurchase = referralPurchases[msg.sender] +
            msg.value;

        // verify amount is not greater than the referral cap per buyer
        if (_newReferralPurchase > referralCapPerBuyer) {
            revert InvalidPaymentAmount();
        }

        // update referral amount bought by sender
        referralPurchases[msg.sender] = _newReferralPurchase;

        // transfer ETH to receiver wallet
        receiverWallet.transfer(msg.value);

        // emit event
        emit PurchaseWithReferralCode(msg.sender, msg.value);
    }

    /**
     * @notice Verifies if a given referral code is valid for a specific wallet address.
     * @dev Uses a Merkle proof to verify if the provided referral code is part of the Merkle tree
     *      represented by the referralCodeMerkleRoot. This is used to validate the authenticity of the referral codes.
     * @param wallet_ The address of the wallet for which the referral code is being verified.
     * @param referralCode_ Merkle Proof to check against.
     * @return bool True if the referral code is valid for the given wallet address, false otherwise.
     */
    function verifyReferralCode(
        address wallet_,
        bytes32[] calldata referralCode_
    ) public view returns (bool) {
        return
            MerkleProof.verify(
                referralCode_,
                referralCodeMerkleRoot,
                keccak256(bytes.concat(keccak256(abi.encode(wallet_))))
            );
    }

    /**
     * @dev Only owner functions
     */

    /**
     * @notice Pause the purchase functions, only owner can call this function
     */
    function pause() external onlyOwner {
        _pause();
    }

    /**
     * @notice Unpause the purchase functions, only owner can call this function
     */
    function unpause() external onlyOwner {
        _unpause();
    }

    /**
     * @dev Internal functions
     */

    /**
     * @notice Verifies if the sender is the owner of a given token or a valid delegate.
     * @dev This internal function checks if the sender is either the owner of the specified token or an authorized delegate.
     *      It supports two versions of delegate checks: a newer version (`dcV2`) and an older one (`dc`).
     *      The function reverts with `NotTokenOwner` if the sender is neither the owner nor a valid delegate.
     * @param tokenId_ The token ID to verify ownership or delegation for.
     */
    function _verifyTokenOwner(uint256 tokenId_) internal view {
        address _tokenOwner = grapeNFT.ownerOf(tokenId_);

        // check sender is owner
        if (_tokenOwner == msg.sender) return;

        // check with delegate registry v2
        if (
            delegateRegistryV2.checkDelegateForERC721(
                msg.sender,
                _tokenOwner,
                address(grapeNFT),
                tokenId_,
                ''
            )
        ) return;

        // check with delegate registry v1
        if (
            delegateRegistryV1.checkDelegateForToken(
                msg.sender,
                _tokenOwner,
                address(grapeNFT),
                tokenId_
            )
        ) return;

        // revert if not owner or delegate
        revert NotTokenOwner(tokenId_);
    }
}

File 2 of 28 : 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 3 of 28 : draft-IERC6093.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC6093.sol)
pragma solidity ^0.8.20;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC1271 standard signature validation method for
 * contracts as defined in https://eips.ethereum.org/EIPS/eip-1271[ERC-1271].
 */
interface IERC1271 {
    /**
     * @dev Should return whether the signature provided is valid for the provided data
     * @param hash      Hash of the data to be signed
     * @param signature Signature byte array associated with _data
     */
    function isValidSignature(bytes32 hash, bytes memory signature) external view returns (bytes4 magicValue);
}

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

pragma solidity ^0.8.20;

import {IERC20} from "./IERC20.sol";
import {IERC20Metadata} from "./extensions/IERC20Metadata.sol";
import {Context} from "../../utils/Context.sol";
import {IERC20Errors} from "../../interfaces/draft-IERC6093.sol";

/**
 * @dev Implementation of the {IERC20} interface.
 *
 * This implementation is agnostic to the way tokens are created. This means
 * that a supply mechanism has to be added in a derived contract using {_mint}.
 *
 * TIP: For a detailed writeup see our guide
 * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
 * to implement supply mechanisms].
 *
 * The default value of {decimals} is 18. To change this, you should override
 * this function so it returns a different value.
 *
 * We have followed general OpenZeppelin Contracts guidelines: functions revert
 * instead returning `false` on failure. This behavior is nonetheless
 * conventional and does not conflict with the expectations of ERC20
 * applications.
 *
 * Additionally, an {Approval} event is emitted on calls to {transferFrom}.
 * This allows applications to reconstruct the allowance for all accounts just
 * by listening to said events. Other implementations of the EIP may not emit
 * these events, as it isn't required by the specification.
 */
abstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors {
    mapping(address account => uint256) private _balances;

    mapping(address account => mapping(address spender => uint256)) private _allowances;

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;

    /**
     * @dev Sets the values for {name} and {symbol}.
     *
     * All two of these values are immutable: they can only be set once during
     * construction.
     */
    constructor(string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
    }

    /**
     * @dev Returns the name of the token.
     */
    function name() public view virtual returns (string memory) {
        return _name;
    }

    /**
     * @dev Returns the symbol of the token, usually a shorter version of the
     * name.
     */
    function symbol() public view virtual returns (string memory) {
        return _symbol;
    }

    /**
     * @dev Returns the number of decimals used to get its user representation.
     * For example, if `decimals` equals `2`, a balance of `505` tokens should
     * be displayed to a user as `5.05` (`505 / 10 ** 2`).
     *
     * Tokens usually opt for a value of 18, imitating the relationship between
     * Ether and Wei. This is the default value returned by this function, unless
     * it's overridden.
     *
     * NOTE: This information is only used for _display_ purposes: it in
     * no way affects any of the arithmetic of the contract, including
     * {IERC20-balanceOf} and {IERC20-transfer}.
     */
    function decimals() public view virtual returns (uint8) {
        return 18;
    }

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

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

    /**
     * @dev See {IERC20-transfer}.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - the caller must have a balance of at least `value`.
     */
    function transfer(address to, uint256 value) public virtual returns (bool) {
        address owner = _msgSender();
        _transfer(owner, to, value);
        return true;
    }

    /**
     * @dev See {IERC20-allowance}.
     */
    function allowance(address owner, address spender) public view virtual returns (uint256) {
        return _allowances[owner][spender];
    }

    /**
     * @dev See {IERC20-approve}.
     *
     * NOTE: If `value` is the maximum `uint256`, the allowance is not updated on
     * `transferFrom`. This is semantically equivalent to an infinite approval.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 value) public virtual returns (bool) {
        address owner = _msgSender();
        _approve(owner, spender, value);
        return true;
    }

    /**
     * @dev See {IERC20-transferFrom}.
     *
     * Emits an {Approval} event indicating the updated allowance. This is not
     * required by the EIP. See the note at the beginning of {ERC20}.
     *
     * NOTE: Does not update the allowance if the current allowance
     * is the maximum `uint256`.
     *
     * Requirements:
     *
     * - `from` and `to` cannot be the zero address.
     * - `from` must have a balance of at least `value`.
     * - the caller must have allowance for ``from``'s tokens of at least
     * `value`.
     */
    function transferFrom(address from, address to, uint256 value) public virtual returns (bool) {
        address spender = _msgSender();
        _spendAllowance(from, spender, value);
        _transfer(from, to, value);
        return true;
    }

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to`.
     *
     * This internal function is equivalent to {transfer}, and can be used to
     * e.g. implement automatic token fees, slashing mechanisms, etc.
     *
     * Emits a {Transfer} event.
     *
     * NOTE: This function is not virtual, {_update} should be overridden instead.
     */
    function _transfer(address from, address to, uint256 value) internal {
        if (from == address(0)) {
            revert ERC20InvalidSender(address(0));
        }
        if (to == address(0)) {
            revert ERC20InvalidReceiver(address(0));
        }
        _update(from, to, value);
    }

    /**
     * @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from`
     * (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding
     * this function.
     *
     * Emits a {Transfer} event.
     */
    function _update(address from, address to, uint256 value) internal virtual {
        if (from == address(0)) {
            // Overflow check required: The rest of the code assumes that totalSupply never overflows
            _totalSupply += value;
        } else {
            uint256 fromBalance = _balances[from];
            if (fromBalance < value) {
                revert ERC20InsufficientBalance(from, fromBalance, value);
            }
            unchecked {
                // Overflow not possible: value <= fromBalance <= totalSupply.
                _balances[from] = fromBalance - value;
            }
        }

        if (to == address(0)) {
            unchecked {
                // Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply.
                _totalSupply -= value;
            }
        } else {
            unchecked {
                // Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256.
                _balances[to] += value;
            }
        }

        emit Transfer(from, to, value);
    }

    /**
     * @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0).
     * Relies on the `_update` mechanism
     *
     * Emits a {Transfer} event with `from` set to the zero address.
     *
     * NOTE: This function is not virtual, {_update} should be overridden instead.
     */
    function _mint(address account, uint256 value) internal {
        if (account == address(0)) {
            revert ERC20InvalidReceiver(address(0));
        }
        _update(address(0), account, value);
    }

    /**
     * @dev Destroys a `value` amount of tokens from `account`, lowering the total supply.
     * Relies on the `_update` mechanism.
     *
     * Emits a {Transfer} event with `to` set to the zero address.
     *
     * NOTE: This function is not virtual, {_update} should be overridden instead
     */
    function _burn(address account, uint256 value) internal {
        if (account == address(0)) {
            revert ERC20InvalidSender(address(0));
        }
        _update(account, address(0), value);
    }

    /**
     * @dev Sets `value` as the allowance of `spender` over the `owner` s tokens.
     *
     * This internal function is equivalent to `approve`, and can be used to
     * e.g. set automatic allowances for certain subsystems, etc.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `owner` cannot be the zero address.
     * - `spender` cannot be the zero address.
     *
     * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.
     */
    function _approve(address owner, address spender, uint256 value) internal {
        _approve(owner, spender, value, true);
    }

    /**
     * @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event.
     *
     * By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by
     * `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any
     * `Approval` event during `transferFrom` operations.
     *
     * Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to
     * true using the following override:
     * ```
     * function _approve(address owner, address spender, uint256 value, bool) internal virtual override {
     *     super._approve(owner, spender, value, true);
     * }
     * ```
     *
     * Requirements are the same as {_approve}.
     */
    function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual {
        if (owner == address(0)) {
            revert ERC20InvalidApprover(address(0));
        }
        if (spender == address(0)) {
            revert ERC20InvalidSpender(address(0));
        }
        _allowances[owner][spender] = value;
        if (emitEvent) {
            emit Approval(owner, spender, value);
        }
    }

    /**
     * @dev Updates `owner` s allowance for `spender` based on spent `value`.
     *
     * Does not update the allowance value in case of infinite allowance.
     * Revert if not enough allowance is available.
     *
     * Does not emit an {Approval} event.
     */
    function _spendAllowance(address owner, address spender, uint256 value) internal virtual {
        uint256 currentAllowance = allowance(owner, spender);
        if (currentAllowance != type(uint256).max) {
            if (currentAllowance < value) {
                revert ERC20InsufficientAllowance(spender, currentAllowance, value);
            }
            unchecked {
                _approve(owner, spender, currentAllowance - value, false);
            }
        }
    }
}

File 6 of 28 : IERC20Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity ^0.8.20;

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

/**
 * @dev Interface for the optional metadata functions from the ERC20 standard.
 */
interface IERC20Metadata is IERC20 {
    /**
     * @dev Returns the name of the token.
     */
    function name() external view returns (string memory);

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

    /**
     * @dev Returns the decimals places of the token.
     */
    function decimals() external view returns (uint8);
}

File 7 of 28 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

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

    /**
     * @dev Returns the value of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

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

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

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

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

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

File 8 of 28 : 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 9 of 28 : 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 10 of 28 : 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 11 of 28 : 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 12 of 28 : Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (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;
    }
}

File 13 of 28 : 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 14 of 28 : MerkleProof.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/MerkleProof.sol)

pragma solidity ^0.8.20;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.20;

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

/**
 * @dev Signature message hash utilities for producing digests to be consumed by {ECDSA} recovery or signing.
 *
 * The library provides methods for generating a hash of a message that conforms to the
 * https://eips.ethereum.org/EIPS/eip-191[EIP 191] and https://eips.ethereum.org/EIPS/eip-712[EIP 712]
 * specifications.
 */
library MessageHashUtils {
    /**
     * @dev Returns the keccak256 digest of an EIP-191 signed data with version
     * `0x45` (`personal_sign` messages).
     *
     * The digest is calculated by prefixing a bytes32 `messageHash` with
     * `"\x19Ethereum Signed Message:\n32"` and hashing the result. It corresponds with the
     * hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method.
     *
     * NOTE: The `messageHash` parameter is intended to be the result of hashing a raw message with
     * keccak256, although any bytes32 value can be safely used because the final digest will
     * be re-hashed.
     *
     * See {ECDSA-recover}.
     */
    function toEthSignedMessageHash(bytes32 messageHash) internal pure returns (bytes32 digest) {
        /// @solidity memory-safe-assembly
        assembly {
            mstore(0x00, "\x19Ethereum Signed Message:\n32") // 32 is the bytes-length of messageHash
            mstore(0x1c, messageHash) // 0x1c (28) is the length of the prefix
            digest := keccak256(0x00, 0x3c) // 0x3c is the length of the prefix (0x1c) + messageHash (0x20)
        }
    }

    /**
     * @dev Returns the keccak256 digest of an EIP-191 signed data with version
     * `0x45` (`personal_sign` messages).
     *
     * The digest is calculated by prefixing an arbitrary `message` with
     * `"\x19Ethereum Signed Message:\n" + len(message)` and hashing the result. It corresponds with the
     * hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method.
     *
     * See {ECDSA-recover}.
     */
    function toEthSignedMessageHash(bytes memory message) internal pure returns (bytes32) {
        return
            keccak256(bytes.concat("\x19Ethereum Signed Message:\n", bytes(Strings.toString(message.length)), message));
    }

    /**
     * @dev Returns the keccak256 digest of an EIP-191 signed data with version
     * `0x00` (data with intended validator).
     *
     * The digest is calculated by prefixing an arbitrary `data` with `"\x19\x00"` and the intended
     * `validator` address. Then hashing the result.
     *
     * See {ECDSA-recover}.
     */
    function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked(hex"19_00", validator, data));
    }

    /**
     * @dev Returns the keccak256 digest of an EIP-712 typed data (EIP-191 version `0x01`).
     *
     * The digest is calculated from a `domainSeparator` and a `structHash`, by prefixing them with
     * `\x19\x01` and hashing the result. It corresponds to the hash signed by the
     * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] JSON-RPC method as part of EIP-712.
     *
     * See {ECDSA-recover}.
     */
    function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 digest) {
        /// @solidity memory-safe-assembly
        assembly {
            let ptr := mload(0x40)
            mstore(ptr, hex"19_01")
            mstore(add(ptr, 0x02), domainSeparator)
            mstore(add(ptr, 0x22), structHash)
            digest := keccak256(ptr, 0x42)
        }
    }
}

File 16 of 28 : SignatureChecker.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/SignatureChecker.sol)

pragma solidity ^0.8.20;

import {ECDSA} from "./ECDSA.sol";
import {IERC1271} from "../../interfaces/IERC1271.sol";

/**
 * @dev Signature verification helper that can be used instead of `ECDSA.recover` to seamlessly support both ECDSA
 * signatures from externally owned accounts (EOAs) as well as ERC1271 signatures from smart contract wallets like
 * Argent and Safe Wallet (previously Gnosis Safe).
 */
library SignatureChecker {
    /**
     * @dev Checks if a signature is valid for a given signer and data hash. If the signer is a smart contract, the
     * signature is validated against that smart contract using ERC1271, otherwise it's validated using `ECDSA.recover`.
     *
     * NOTE: Unlike ECDSA signatures, contract signatures are revocable, and the outcome of this function can thus
     * change through time. It could return true at block N and false at block N+1 (or the opposite).
     */
    function isValidSignatureNow(address signer, bytes32 hash, bytes memory signature) internal view returns (bool) {
        (address recovered, ECDSA.RecoverError error, ) = ECDSA.tryRecover(hash, signature);
        return
            (error == ECDSA.RecoverError.NoError && recovered == signer) ||
            isValidERC1271SignatureNow(signer, hash, signature);
    }

    /**
     * @dev Checks if a signature is valid for a given signer and data hash. The signature is validated
     * against the signer smart contract using ERC1271.
     *
     * NOTE: Unlike ECDSA signatures, contract signatures are revocable, and the outcome of this function can thus
     * change through time. It could return true at block N and false at block N+1 (or the opposite).
     */
    function isValidERC1271SignatureNow(
        address signer,
        bytes32 hash,
        bytes memory signature
    ) internal view returns (bool) {
        (bool success, bytes memory result) = signer.staticcall(
            abi.encodeCall(IERC1271.isValidSignature, (hash, signature))
        );
        return (success &&
            result.length >= 32 &&
            abi.decode(result, (bytes32)) == bytes32(IERC1271.isValidSignature.selector));
    }
}

File 17 of 28 : 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 18 of 28 : 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 19 of 28 : 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 20 of 28 : SignedMath.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SignedMath.sol)

pragma solidity ^0.8.20;

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

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

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

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

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

pragma solidity ^0.8.20;

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

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

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

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

    /**
     * @dev The operation failed because the contract is paused.
     */
    error EnforcedPause();

    /**
     * @dev The operation failed because the contract is not paused.
     */
    error ExpectedPause();

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

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

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

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

    /**
     * @dev Throws if the contract is paused.
     */
    function _requireNotPaused() internal view virtual {
        if (paused()) {
            revert EnforcedPause();
        }
    }

    /**
     * @dev Throws if the contract is not paused.
     */
    function _requirePaused() internal view virtual {
        if (!paused()) {
            revert ExpectedPause();
        }
    }

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

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

File 22 of 28 : 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 23 of 28 : Grape.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.20;

import '@openzeppelin/contracts/token/ERC20/ERC20.sol';

contract Grape is ERC20 {
    constructor(address preMintWallet_) ERC20('Grape coin', 'GRAPE') {
        _mint(preMintWallet_, 2_000_000_000 * 10 ** decimals());
    }
}

File 24 of 28 : GrapePublicVesting.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.20;

import '@openzeppelin/contracts/access/Ownable.sol';
import '@openzeppelin/contracts/token/ERC20/IERC20.sol';
import '@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol';
import '@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol';

contract GrapePublicVesting is Ownable {
    /**
     * @dev Public immutable state
     */
    IERC20 public immutable grapeToken;
    uint256 public immutable tgeUnlockPercent = 25;
    uint256 public immutable bonusPercent = 10;
    address public immutable signerWallet;
    uint256 public immutable signatureValidity = 1 hours;

    /**
     * @dev Public mutable state
     */
    uint256 public tgeDate;
    uint256 public vestingEndDate;
    mapping(address investor => uint256 amountWithoutBonus) public withdraws; // managed internally

    /**
     * @notice Emitted when a investor withdraws
     */
    event Withdraw(
        address indexed investor,
        uint256 amount,
        uint256 bonusAmount
    );

    /**
     * @dev Errors
     */
    error ExpiredSignature();
    error InvalidSignature();
    error TGEPending();
    error ZeroWithdrawAmount();

    /**
     * @notice Initializes a new Grape Token Vesting contract.
     * @dev Sets up the Grape token vesting contract with the specified parameters.
     *      This includes the Grape token address, the initial owner of the contract, the TGE (Token Generation Event) date,
     *      the end date for the vesting period, and the signer wallet address.
     *      The constructor sets the initial state of the contract and transfers ownership to the specified initial owner.
     * @param grapeToken_ The address of the Grape ERC20 token that will be vested through this contract.
     * @param initialOwner_ The address of the initial owner of the contract, typically the deployer or the main administrative account.
     * @param tgeDate_ The date of the Token Generation Event (TGE), represented as a Unix timestamp,
     *        indicating when token distribution begins.
     * @param vestingEndDate_ The end date of the vesting period, represented as a Unix timestamp.
     * @param signerWallet_ The address of the wallet used for signing transactions or authorizations related to this contract.
     */
    constructor(
        address grapeToken_,
        address initialOwner_,
        uint256 tgeDate_,
        uint256 vestingEndDate_,
        address signerWallet_
    ) Ownable(initialOwner_) {
        grapeToken = IERC20(grapeToken_);
        tgeDate = tgeDate_;
        vestingEndDate = vestingEndDate_;
        signerWallet = signerWallet_;
    }

    /**
     * @dev Public functions
     */

    /**
     * @notice Calculates the amount of tokens that have vested for a user based on their NFT and referral purchases.
     * @dev This function computes the vested token amount using a linear vesting schedule. It takes into account
     *      both NFT and referral purchases. The vested amount depends on whether the cliff period has ended and
     *      if the vesting period is still ongoing.
     *      - If the cliff period (TGE date) hasn't started, no tokens are vested.
     *      - If the vesting period has ended, the total of NFT and referral purchases is returned.
     *      - Otherwise, a linear vesting calculation is applied.
     * @param nftAmountPurchased_ The total amount of tokens purchased through NFTs.
     * @param referralAmountPurchased_ The total amount of tokens purchased using referral codes.
     * @return uint256 The total vested amount of tokens for the given purchases at the current time.
     */
    function vestedAmount(
        uint256 nftAmountPurchased_,
        uint256 referralAmountPurchased_
    ) public view returns (uint256) {
        // check if cliff period has ended
        if (block.timestamp < tgeDate) return 0;

        // check if vesting period has ended
        if (block.timestamp >= vestingEndDate)
            return nftAmountPurchased_ + referralAmountPurchased_;

        // calculate vested amount using a linear vesting schedule
        uint256 _allowance = nftAmountPurchased_ + referralAmountPurchased_;
        return
            ((_allowance * tgeUnlockPercent) / 100) + // 25% unlocked at TGE
            (((_allowance * (100 - tgeUnlockPercent)) / 100) * // rest linearly unlocked
                (block.timestamp - tgeDate)) /
            (vestingEndDate - tgeDate);
    }

    /**
     * @notice Calculates the amount of tokens that an investor can currently withdraw, excluding any bonus amounts.
     * @dev This function determines the withdrawable amount by subtracting the total amount already withdrawn
     *      by the investor from their total vested amount. The vested amount is calculated based on the sum of
     *      NFT and referral purchases. This function does not account for any additional bonuses that might apply.
     * @param investor_ The address of the investor for whom the withdrawable amount is being calculated.
     * @param nftAmountPurchased_ The total amount of tokens purchased by the investor through NFTs.
     * @param referralAmountPurchased_ The total amount of tokens purchased by the investor using referral codes.
     * @return uint256 The total amount of tokens that the investor can withdraw at the current time,
     * excluding any bonus amounts.
     */
    function withdrawableAmountWithoutBonus(
        address investor_,
        uint256 nftAmountPurchased_,
        uint256 referralAmountPurchased_
    ) public view returns (uint256) {
        return
            vestedAmount(nftAmountPurchased_, referralAmountPurchased_) -
            withdraws[investor_];
    }

    /**
     * @notice Allows an investor to withdraw their vested tokens, with an option to apply a bonus.
     * @dev This function enables investors to withdraw their vested tokens based on their NFT and referral purchases.
     *      It checks the validity of a signature to authorize the withdrawal, ensures the token generation event (TGE) has occurred,
     *      and calculates the amount to withdraw, potentially including a bonus.
     *      - The signature is validated for expiry and authenticity.
     *      - The function reverts if the TGE hasn't occurred or if the signature is invalid or expired.
     *      - If there's nothing to withdraw, it also reverts.
     * @param nftAmountPurchased_ The amount of tokens purchased through NFTs by the investor.
     * @param referralAmountPurchased_ The amount of tokens purchased using referral codes by the investor.
     * @param applyBonus_ A boolean indicating whether to apply a bonus to the withdrawal amount.
     * @param signature_ The signature to validate the withdrawal request.
     * @param signatureTimestamp_ The timestamp associated with the signature.
     */
    function withdraw(
        uint256 nftAmountPurchased_,
        uint256 referralAmountPurchased_,
        bool applyBonus_,
        bytes calldata signature_,
        uint256 signatureTimestamp_
    ) external {
        // check signature is not expired
        if (block.timestamp > signatureTimestamp_ + signatureValidity) {
            revert ExpiredSignature();
        }

        // check signature is signed by signerWallet
        if (
            !SignatureChecker.isValidSignatureNow(
                signerWallet,
                MessageHashUtils.toEthSignedMessageHash(
                    keccak256(
                        abi.encodePacked(
                            msg.sender,
                            signatureTimestamp_,
                            nftAmountPurchased_,
                            referralAmountPurchased_,
                            applyBonus_
                        )
                    )
                ),
                signature_
            )
        ) {
            revert InvalidSignature();
        }

        // check if token generation event is reached
        if (block.timestamp < tgeDate) {
            revert TGEPending();
        }

        // calculate withdrawable amount without bonus
        uint256 _withdrawableAmountWithoutBonus = withdrawableAmountWithoutBonus(
                msg.sender,
                nftAmountPurchased_,
                referralAmountPurchased_
            );

        // check if there is anything to withdraw
        if (_withdrawableAmountWithoutBonus == 0) {
            revert ZeroWithdrawAmount();
        }

        // update withdraws state
        withdraws[msg.sender] += _withdrawableAmountWithoutBonus;

        // calculate bonus amount
        uint256 _bonusAmount = applyBonus_
            ? (((_withdrawableAmountWithoutBonus * bonusPercent) / 100) *
                nftAmountPurchased_) /
                (nftAmountPurchased_ + referralAmountPurchased_) // apply bonus only on nftAmountPurchased
            : 0;

        // transfer tokens
        grapeToken.transfer(
            msg.sender,
            _withdrawableAmountWithoutBonus + _bonusAmount
        );

        // emit event
        emit Withdraw(
            msg.sender,
            _withdrawableAmountWithoutBonus,
            _bonusAmount
        );
    }

    /**
     * @dev Only owner functions
     */

    /**
     * @notice Updates the Token Generation Event (TGE) date of the contract.
     * @dev Allows the contract owner to change the TGE date. This function can only be called by the owner.
     *      Changing the TGE date affects when investors can start withdrawing their vested tokens.
     * @param tgeDate_ The new TGE date, represented as a Unix timestamp.
     */
    function changeTgeDate(uint256 tgeDate_) external onlyOwner {
        tgeDate = tgeDate_;
    }

    /**
     * @notice Sets a new vesting end date for the contract.
     * @dev This function allows the contract owner to update the end date of the vesting period.
     *      It can only be called by the contract owner. Changing the vesting end date affects when the vesting period
     *      concludes and, as a result, impacts how vested amounts are calculated for investors.
     * @param vestingEndDate_ The new vesting end date, represented as a Unix timestamp.
     */
    function changeVestingEndDate(uint256 vestingEndDate_) external onlyOwner {
        vestingEndDate = vestingEndDate_;
    }

    /**
     * @notice Allows the contract owner to withdraw all Grape tokens held by the contract.
     * @dev This function enables the owner of the contract to transfer all Grape tokens currently stored in the contract
     *      to their own address. It's a mechanism for retrieving tokens from the contract, possibly for redistribution or other purposes.
     *      The transfer is executed via the Grape token's `transfer` method.
     */
    function withdrawAllGrapeToken() external onlyOwner {
        grapeToken.transfer(owner(), grapeToken.balanceOf(address(this)));
    }
}

File 25 of 28 : GrapeVesting.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.20;

import '@openzeppelin/contracts/token/ERC20/IERC20.sol';
import '@openzeppelin/contracts/access/Ownable.sol';

contract GrapeVesting is Ownable {
    /**
     * @dev Public immutable state
     */
    IERC20 public immutable grapeToken;
    uint256 public immutable cliffUnlockPercent = 5;
    mapping(address investor => uint256 amount) public allowances;

    /**
     * @dev Public mutable state
     */
    uint256 public cliffEndDate;
    uint256 public vestingEndDate;
    mapping(address investor => uint256 amount) public withdraws; // managed internally

    /**
     * @notice Emitted when a investor withdraws
     */
    event Withdraw(address indexed investor, uint256 amount);

    /**
     * @dev Errors
     */
    error LengthMismatch();
    error CliffPending();
    error ZeroWithdrawAmount();

    /**
     * @notice Constructs a new GrapeVesting contract, initializing investor allowances and vesting parameters.
     * @dev Initializes the contract with Grape token address, vesting parameters, and investor allowances.
     *      It sets up a vesting schedule for each investor, specifying how much they are allowed to withdraw and when.
     *      This constructor also transfers the ownership of the contract to the specified initial owner.
     *      The constructor will revert if the lengths of the investors and allowances arrays do not match.
     * @param grapeToken_ The address of the Grape ERC20 token to be vested.
     * @param initialOwner_ The initial owner of the contract, responsible for administrative functions.
     * @param cliffEndDate_ The Unix timestamp representing the end date of the cliff period, after which vesting begins.
     * @param vestingEndDate_ The Unix timestamp representing the end date of the total vesting period.
     * @param investors_ An array of addresses representing investors who are eligible for vesting.
     * @param allowances_ An array of token amounts representing the allowances for each investor.
     */
    constructor(
        address grapeToken_,
        address initialOwner_,
        uint256 cliffEndDate_,
        uint256 vestingEndDate_,
        address[] memory investors_,
        uint256[] memory allowances_
    ) Ownable(initialOwner_) {
        grapeToken = IERC20(grapeToken_);
        cliffEndDate = cliffEndDate_;
        vestingEndDate = vestingEndDate_;

        if (investors_.length != allowances_.length) {
            revert LengthMismatch();
        }
        for (uint256 i = 0; i < investors_.length; i++) {
            allowances[investors_[i]] = allowances_[i];
        }
    }

    /**
     * @dev Public functions
     */

    /**
     * @notice Calculates the vested amount of tokens for a given investor based on the vesting schedule.
     * @dev This function computes the vested token amount for an investor considering the cliff period and the
     *      linear vesting schedule.
     *      - If the current time is before the cliff end date, the vested amount is 0.
     *      - If the current time is after the vesting end date, the entire allowance is considered vested.
     *      - Otherwise, a portion of the allowance is vested based on the time elapsed since the cliff end date.
     *      The vesting is linear between the cliff end date and the vesting end date.
     * @param investor_ The address of the investor for whom to calculate the vested amount.
     * @return uint256 The amount of tokens that have vested for the given investor as of now.
     */
    function vestedAmount(address investor_) public view returns (uint256) {
        // check if cliff period has ended
        if (block.timestamp < cliffEndDate) return 0;

        // check if vesting period has ended
        if (block.timestamp >= vestingEndDate) return allowances[investor_];

        // calculate vested amount using a linear vesting schedule
        return
            ((allowances[investor_] * cliffUnlockPercent) / 100) + // 5% unlocked at cliff
            ((((allowances[investor_] * (100 - cliffUnlockPercent)) / 100) * // rest linearly unlocked
                (block.timestamp - cliffEndDate)) /
                (vestingEndDate - cliffEndDate));
    }

    /**
     * @notice Calculates the amount of tokens that an investor can currently withdraw.
     * @dev Determines the withdrawable amount by subtracting the total amount already withdrawn
     *      by the investor from their vested amount. The vested amount is calculated based on the vesting schedule
     *      and the investor's total token allowance.
     * @param investor_ The address of the investor for whom to calculate the withdrawable amount.
     * @return uint256 The total amount of tokens that the investor can withdraw at the current time.
     */
    function withdrawableAmount(
        address investor_
    ) public view returns (uint256) {
        return vestedAmount(investor_) - withdraws[investor_];
    }

    /**
     * @notice Allows an investor to withdraw their vested tokens.
     * @dev This function enables an investor to withdraw the amount of tokens that have vested for them
     *      as of the current time. It checks if the cliff period has ended and if the investor has any tokens available to withdraw.
     *      The function updates the state to reflect the withdrawal and transfers the vested tokens to the investor.
     *      It reverts if the cliff period hasn't ended or if there are no tokens available for withdrawal.
     */
    function withdraw() external {
        // check if cliff period has ended
        if (block.timestamp < cliffEndDate) {
            revert CliffPending();
        }

        // calculate withdrawable amount
        uint256 _withdrawableAmount = withdrawableAmount(msg.sender);

        // check if there is anything to withdraw
        if (_withdrawableAmount == 0) {
            revert ZeroWithdrawAmount();
        }

        // update withdraws state
        withdraws[msg.sender] += _withdrawableAmount;

        // transfer tokens
        grapeToken.transfer(msg.sender, _withdrawableAmount);

        // emit event
        emit Withdraw(msg.sender, _withdrawableAmount);
    }

    /**
     * @dev Only owner functions
     */

    /**
     * @notice Updates the cliff end date for the vesting schedule.
     * @dev Allows the contract owner to modify the end date of the cliff period.
     *      Changing this date affects the start of the token vesting schedule for all investors.
     *      This function can only be called by the contract owner.
     * @param cliffEndDate_ The new end date for the cliff period, specified as a Unix timestamp.
     */
    function changeCliffEndDate(uint256 cliffEndDate_) external onlyOwner {
        cliffEndDate = cliffEndDate_;
    }

    /**
     * @notice Sets a new end date for the overall vesting period.
     * @dev Allows the contract owner to update the vesting end date. This change affects the duration
     *      of the vesting period for all investors. It can only be executed by the contract owner.
     *      Changing this date impacts how vested amounts are calculated for each investor.
     * @param vestingEndDate_ The new end date for the vesting period, represented as a Unix timestamp.
     */
    function changeVestingEndDate(uint256 vestingEndDate_) external onlyOwner {
        vestingEndDate = vestingEndDate_;
    }

    /**
     * @notice Enables the contract owner to withdraw all Grape tokens held by this contract.
     * @dev This function allows the owner to transfer all the Grape tokens from the contract's balance to their own address.
     *      This action can only be performed by the contract owner.
     */
    function withdrawAllGrapeToken() external onlyOwner {
        grapeToken.transfer(owner(), grapeToken.balanceOf(address(this)));
    }
}

File 26 of 28 : IDelegateRegistry.sol
// SPDX-License-Identifier: CC0-1.0
pragma solidity >=0.8.13;

/**
 * @title IDelegateRegistry
 * @custom:version 2.0
 * @custom:author foobar (0xfoobar)
 * @notice A standalone immutable registry storing delegated permissions from one address to another
 */
interface IDelegateRegistry {
    /// @notice Delegation type, NONE is used when a delegation does not exist or is revoked
    enum DelegationType {
        NONE,
        ALL,
        CONTRACT,
        ERC721,
        ERC20,
        ERC1155
    }

    /// @notice Struct for returning delegations
    struct Delegation {
        DelegationType type_;
        address to;
        address from;
        bytes32 rights;
        address contract_;
        uint256 tokenId;
        uint256 amount;
    }

    /// @notice Emitted when an address delegates or revokes rights for their entire wallet
    event DelegateAll(address indexed from, address indexed to, bytes32 rights, bool enable);

    /// @notice Emitted when an address delegates or revokes rights for a contract address
    event DelegateContract(address indexed from, address indexed to, address indexed contract_, bytes32 rights, bool enable);

    /// @notice Emitted when an address delegates or revokes rights for an ERC721 tokenId
    event DelegateERC721(address indexed from, address indexed to, address indexed contract_, uint256 tokenId, bytes32 rights, bool enable);

    /// @notice Emitted when an address delegates or revokes rights for an amount of ERC20 tokens
    event DelegateERC20(address indexed from, address indexed to, address indexed contract_, bytes32 rights, uint256 amount);

    /// @notice Emitted when an address delegates or revokes rights for an amount of an ERC1155 tokenId
    event DelegateERC1155(address indexed from, address indexed to, address indexed contract_, uint256 tokenId, bytes32 rights, uint256 amount);

    /// @notice Thrown if multicall calldata is malformed
    error MulticallFailed();

    /**
     * -----------  WRITE -----------
     */

    /**
     * @notice Call multiple functions in the current contract and return the data from all of them if they all succeed
     * @param data The encoded function data for each of the calls to make to this contract
     * @return results The results from each of the calls passed in via data
     */
    function multicall(bytes[] calldata data) external payable returns (bytes[] memory results);

    /**
     * @notice Allow the delegate to act on behalf of `msg.sender` for all contracts
     * @param to The address to act as delegate
     * @param rights Specific subdelegation rights granted to the delegate, pass an empty bytestring to encompass all rights
     * @param enable Whether to enable or disable this delegation, true delegates and false revokes
     * @return delegationHash The unique identifier of the delegation
     */
    function delegateAll(address to, bytes32 rights, bool enable) external payable returns (bytes32 delegationHash);

    /**
     * @notice Allow the delegate to act on behalf of `msg.sender` for a specific contract
     * @param to The address to act as delegate
     * @param contract_ The contract whose rights are being delegated
     * @param rights Specific subdelegation rights granted to the delegate, pass an empty bytestring to encompass all rights
     * @param enable Whether to enable or disable this delegation, true delegates and false revokes
     * @return delegationHash The unique identifier of the delegation
     */
    function delegateContract(address to, address contract_, bytes32 rights, bool enable) external payable returns (bytes32 delegationHash);

    /**
     * @notice Allow the delegate to act on behalf of `msg.sender` for a specific ERC721 token
     * @param to The address to act as delegate
     * @param contract_ The contract whose rights are being delegated
     * @param tokenId The token id to delegate
     * @param rights Specific subdelegation rights granted to the delegate, pass an empty bytestring to encompass all rights
     * @param enable Whether to enable or disable this delegation, true delegates and false revokes
     * @return delegationHash The unique identifier of the delegation
     */
    function delegateERC721(address to, address contract_, uint256 tokenId, bytes32 rights, bool enable) external payable returns (bytes32 delegationHash);

    /**
     * @notice Allow the delegate to act on behalf of `msg.sender` for a specific amount of ERC20 tokens
     * @dev The actual amount is not encoded in the hash, just the existence of a amount (since it is an upper bound)
     * @param to The address to act as delegate
     * @param contract_ The address for the fungible token contract
     * @param rights Specific subdelegation rights granted to the delegate, pass an empty bytestring to encompass all rights
     * @param amount The amount to delegate, > 0 delegates and 0 revokes
     * @return delegationHash The unique identifier of the delegation
     */
    function delegateERC20(address to, address contract_, bytes32 rights, uint256 amount) external payable returns (bytes32 delegationHash);

    /**
     * @notice Allow the delegate to act on behalf of `msg.sender` for a specific amount of ERC1155 tokens
     * @dev The actual amount is not encoded in the hash, just the existence of a amount (since it is an upper bound)
     * @param to The address to act as delegate
     * @param contract_ The address of the contract that holds the token
     * @param tokenId The token id to delegate
     * @param rights Specific subdelegation rights granted to the delegate, pass an empty bytestring to encompass all rights
     * @param amount The amount of that token id to delegate, > 0 delegates and 0 revokes
     * @return delegationHash The unique identifier of the delegation
     */
    function delegateERC1155(address to, address contract_, uint256 tokenId, bytes32 rights, uint256 amount) external payable returns (bytes32 delegationHash);

    /**
     * ----------- CHECKS -----------
     */

    /**
     * @notice Check if `to` is a delegate of `from` for the entire wallet
     * @param to The potential delegate address
     * @param from The potential address who delegated rights
     * @param rights Specific rights to check for, pass the zero value to ignore subdelegations and check full delegations only
     * @return valid Whether delegate is granted to act on the from's behalf
     */
    function checkDelegateForAll(address to, address from, bytes32 rights) external view returns (bool);

    /**
     * @notice Check if `to` is a delegate of `from` for the specified `contract_` or the entire wallet
     * @param to The delegated address to check
     * @param contract_ The specific contract address being checked
     * @param from The cold wallet who issued the delegation
     * @param rights Specific rights to check for, pass the zero value to ignore subdelegations and check full delegations only
     * @return valid Whether delegate is granted to act on from's behalf for entire wallet or that specific contract
     */
    function checkDelegateForContract(address to, address from, address contract_, bytes32 rights) external view returns (bool);

    /**
     * @notice Check if `to` is a delegate of `from` for the specific `contract` and `tokenId`, the entire `contract_`, or the entire wallet
     * @param to The delegated address to check
     * @param contract_ The specific contract address being checked
     * @param tokenId The token id for the token to delegating
     * @param from The wallet that issued the delegation
     * @param rights Specific rights to check for, pass the zero value to ignore subdelegations and check full delegations only
     * @return valid Whether delegate is granted to act on from's behalf for entire wallet, that contract, or that specific tokenId
     */
    function checkDelegateForERC721(address to, address from, address contract_, uint256 tokenId, bytes32 rights) external view returns (bool);

    /**
     * @notice Returns the amount of ERC20 tokens the delegate is granted rights to act on the behalf of
     * @param to The delegated address to check
     * @param contract_ The address of the token contract
     * @param from The cold wallet who issued the delegation
     * @param rights Specific rights to check for, pass the zero value to ignore subdelegations and check full delegations only
     * @return balance The delegated balance, which will be 0 if the delegation does not exist
     */
    function checkDelegateForERC20(address to, address from, address contract_, bytes32 rights) external view returns (uint256);

    /**
     * @notice Returns the amount of a ERC1155 tokens the delegate is granted rights to act on the behalf of
     * @param to The delegated address to check
     * @param contract_ The address of the token contract
     * @param tokenId The token id to check the delegated amount of
     * @param from The cold wallet who issued the delegation
     * @param rights Specific rights to check for, pass the zero value to ignore subdelegations and check full delegations only
     * @return balance The delegated balance, which will be 0 if the delegation does not exist
     */
    function checkDelegateForERC1155(address to, address from, address contract_, uint256 tokenId, bytes32 rights) external view returns (uint256);

    /**
     * ----------- ENUMERATIONS -----------
     */

    /**
     * @notice Returns all enabled delegations a given delegate has received
     * @param to The address to retrieve delegations for
     * @return delegations Array of Delegation structs
     */
    function getIncomingDelegations(address to) external view returns (Delegation[] memory delegations);

    /**
     * @notice Returns all enabled delegations an address has given out
     * @param from The address to retrieve delegations for
     * @return delegations Array of Delegation structs
     */
    function getOutgoingDelegations(address from) external view returns (Delegation[] memory delegations);

    /**
     * @notice Returns all hashes associated with enabled delegations an address has received
     * @param to The address to retrieve incoming delegation hashes for
     * @return delegationHashes Array of delegation hashes
     */
    function getIncomingDelegationHashes(address to) external view returns (bytes32[] memory delegationHashes);

    /**
     * @notice Returns all hashes associated with enabled delegations an address has given out
     * @param from The address to retrieve outgoing delegation hashes for
     * @return delegationHashes Array of delegation hashes
     */
    function getOutgoingDelegationHashes(address from) external view returns (bytes32[] memory delegationHashes);

    /**
     * @notice Returns the delegations for a given array of delegation hashes
     * @param delegationHashes is an array of hashes that correspond to delegations
     * @return delegations Array of Delegation structs, return empty structs for nonexistent or revoked delegations
     */
    function getDelegationsFromHashes(bytes32[] calldata delegationHashes) external view returns (Delegation[] memory delegations);

    /**
     * ----------- STORAGE ACCESS -----------
     */

    /**
     * @notice Allows external contracts to read arbitrary storage slots
     */
    function readSlot(bytes32 location) external view returns (bytes32);

    /**
     * @notice Allows external contracts to read an arbitrary array of storage slots
     */
    function readSlots(bytes32[] calldata locations) external view returns (bytes32[] memory);
}

File 27 of 28 : IDelegationRegistry.sol
// SPDX-License-Identifier: CC0-1.0
pragma solidity ^0.8.17;

/**
 * @title An immutable registry contract to be deployed as a standalone primitive
 * @dev See EIP-5639, new project launches can read previous cold wallet -> hot wallet delegations
 * from here and integrate those permissions into their flow
 */
interface IDelegationRegistry {
    /// @notice Delegation type
    enum DelegationType {
        NONE,
        ALL,
        CONTRACT,
        TOKEN
    }

    /// @notice Info about a single delegation, used for onchain enumeration
    struct DelegationInfo {
        DelegationType type_;
        address vault;
        address delegate;
        address contract_;
        uint256 tokenId;
    }

    /// @notice Info about a single contract-level delegation
    struct ContractDelegation {
        address contract_;
        address delegate;
    }

    /// @notice Info about a single token-level delegation
    struct TokenDelegation {
        address contract_;
        uint256 tokenId;
        address delegate;
    }

    /// @notice Emitted when a user delegates their entire wallet
    event DelegateForAll(address vault, address delegate, bool value);

    /// @notice Emitted when a user delegates a specific contract
    event DelegateForContract(address vault, address delegate, address contract_, bool value);

    /// @notice Emitted when a user delegates a specific token
    event DelegateForToken(address vault, address delegate, address contract_, uint256 tokenId, bool value);

    /// @notice Emitted when a user revokes all delegations
    event RevokeAllDelegates(address vault);

    /// @notice Emitted when a user revoes all delegations for a given delegate
    event RevokeDelegate(address vault, address delegate);

    /**
     * -----------  WRITE -----------
     */

    /**
     * @notice Allow the delegate to act on your behalf for all contracts
     * @param delegate The hotwallet to act on your behalf
     * @param value Whether to enable or disable delegation for this address, true for setting and false for revoking
     */
    function delegateForAll(address delegate, bool value) external;

    /**
     * @notice Allow the delegate to act on your behalf for a specific contract
     * @param delegate The hotwallet to act on your behalf
     * @param contract_ The address for the contract you're delegating
     * @param value Whether to enable or disable delegation for this address, true for setting and false for revoking
     */
    function delegateForContract(address delegate, address contract_, bool value) external;

    /**
     * @notice Allow the delegate to act on your behalf for a specific token
     * @param delegate The hotwallet to act on your behalf
     * @param contract_ The address for the contract you're delegating
     * @param tokenId The token id for the token you're delegating
     * @param value Whether to enable or disable delegation for this address, true for setting and false for revoking
     */
    function delegateForToken(address delegate, address contract_, uint256 tokenId, bool value) external;

    /**
     * @notice Revoke all delegates
     */
    function revokeAllDelegates() external;

    /**
     * @notice Revoke a specific delegate for all their permissions
     * @param delegate The hotwallet to revoke
     */
    function revokeDelegate(address delegate) external;

    /**
     * @notice Remove yourself as a delegate for a specific vault
     * @param vault The vault which delegated to the msg.sender, and should be removed
     */
    function revokeSelf(address vault) external;

    /**
     * -----------  READ -----------
     */

    /**
     * @notice Returns all active delegations a given delegate is able to claim on behalf of
     * @param delegate The delegate that you would like to retrieve delegations for
     * @return info Array of DelegationInfo structs
     */
    function getDelegationsByDelegate(address delegate) external view returns (DelegationInfo[] memory);

    /**
     * @notice Returns an array of wallet-level delegates for a given vault
     * @param vault The cold wallet who issued the delegation
     * @return addresses Array of wallet-level delegates for a given vault
     */
    function getDelegatesForAll(address vault) external view returns (address[] memory);

    /**
     * @notice Returns an array of contract-level delegates for a given vault and contract
     * @param vault The cold wallet who issued the delegation
     * @param contract_ The address for the contract you're delegating
     * @return addresses Array of contract-level delegates for a given vault and contract
     */
    function getDelegatesForContract(address vault, address contract_) external view returns (address[] memory);

    /**
     * @notice Returns an array of contract-level delegates for a given vault's token
     * @param vault The cold wallet who issued the delegation
     * @param contract_ The address for the contract holding the token
     * @param tokenId The token id for the token you're delegating
     * @return addresses Array of contract-level delegates for a given vault's token
     */
    function getDelegatesForToken(address vault, address contract_, uint256 tokenId)
        external
        view
        returns (address[] memory);

    /**
     * @notice Returns all contract-level delegations for a given vault
     * @param vault The cold wallet who issued the delegations
     * @return delegations Array of ContractDelegation structs
     */
    function getContractLevelDelegations(address vault)
        external
        view
        returns (ContractDelegation[] memory delegations);

    /**
     * @notice Returns all token-level delegations for a given vault
     * @param vault The cold wallet who issued the delegations
     * @return delegations Array of TokenDelegation structs
     */
    function getTokenLevelDelegations(address vault) external view returns (TokenDelegation[] memory delegations);

    /**
     * @notice Returns true if the address is delegated to act on the entire vault
     * @param delegate The hotwallet to act on your behalf
     * @param vault The cold wallet who issued the delegation
     */
    function checkDelegateForAll(address delegate, address vault) external view returns (bool);

    /**
     * @notice Returns true if the address is delegated to act on your behalf for a token contract or an entire vault
     * @param delegate The hotwallet to act on your behalf
     * @param contract_ The address for the contract you're delegating
     * @param vault The cold wallet who issued the delegation
     */
    function checkDelegateForContract(address delegate, address vault, address contract_)
        external
        view
        returns (bool);

    /**
     * @notice Returns true if the address is delegated to act on your behalf for a specific token, the token's contract or an entire vault
     * @param delegate The hotwallet to act on your behalf
     * @param contract_ The address for the contract you're delegating
     * @param tokenId The token id for the token you're delegating
     * @param vault The cold wallet who issued the delegation
     */
    function checkDelegateForToken(address delegate, address vault, address contract_, uint256 tokenId)
        external
        view
        returns (bool);
}

File 28 of 28 : TestNFT.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.20;

import '@openzeppelin/contracts/token/ERC721/ERC721.sol';

contract TestNFT is ERC721 {
    constructor(uint256 premint_) ERC721('NFT', 'NFT') {
        for (uint256 i = 0; i < premint_; i++) {
            _mint(msg.sender, i);
        }
    }
}

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"grapeNFTAddress_","type":"address"},{"internalType":"address","name":"initialOwner_","type":"address"},{"internalType":"address payable","name":"receiverWallet_","type":"address"},{"internalType":"bytes32","name":"referralCodeMerkleRoot_","type":"bytes32"},{"internalType":"uint256[7]","name":"config_","type":"uint256[7]"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AmountExceedsSupply","type":"error"},{"inputs":[],"name":"BelowMinimumSpend","type":"error"},{"inputs":[],"name":"Closed","type":"error"},{"inputs":[],"name":"EnforcedPause","type":"error"},{"inputs":[],"name":"ExpectedPause","type":"error"},{"inputs":[],"name":"InvalidPaymentAmount","type":"error"},{"inputs":[],"name":"InvalidReferralCode","type":"error"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"NotTokenOwner","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"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"buyer","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"PurchaseWithNFT","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"buyer","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"PurchaseWithReferralCode","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[{"internalType":"uint256[]","name":"tokenIds_","type":"uint256[]"}],"name":"buyWithNFTs","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes32[]","name":"referralCode_","type":"bytes32[]"}],"name":"buyWithReferralCode","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"capPerNFT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"delegateRegistryV1","outputs":[{"internalType":"contract IDelegationRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"delegateRegistryV2","outputs":[{"internalType":"contract IDelegateRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"endDate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"grapeNFT","outputs":[{"internalType":"contract IERC721","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minimumSpendAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"nftPurchases","outputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nftSaleCap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nftSoldSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nftStartDate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"receiverWallet","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"referralCapPerBuyer","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"referralCodeMerkleRoot","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"buyer","type":"address"}],"name":"referralPurchases","outputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"referralStartDate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"wallet_","type":"address"},{"internalType":"bytes32[]","name":"referralCode_","type":"bytes32[]"}],"name":"verifyReferralCode","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}]

6102006040526c447e69651d841bd8d104bed4936101c0526d76a84fef008cdabe6409d2fe638b6101e05260006001553480156200003c57600080fd5b50604051620014ad380380620014ad8339810160408190526200005f9162000183565b836001600160a01b0381166200008f57604051631e4fbdf760e01b81526000600482015260240160405180910390fd5b6200009a8162000104565b506000805460ff60a01b191690556001600160a01b039485166080908152929094166101a05260c0908152835160e052602084015161010052604084015161012052606084015161014052908301516101605260a080840151905290910151610180525062000259565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6001600160a01b03811681146200016a57600080fd5b50565b634e487b7160e01b600052604160045260246000fd5b60008060008060006101608087890312156200019e57600080fd5b8651620001ab8162000154565b80965050602080880151620001c08162000154565b6040890151909650620001d38162000154565b809550506060880151935088609f890112620001ee57600080fd5b60405160e081016001600160401b03811182821017156200021357620002136200016d565b60405291880191808a8411156200022957600080fd5b60808a015b848110156200024757805182529083019083016200022e565b50508093505050509295509295909350565b60805160a05160c05160e05161010051610120516101405161016051610180516101a0516101c0516101e05161114b62000362600039600081816102df0152610de60152600081816104b60152610d1e015260008181610235015281816107c10152610a45015260008181610296015261091401526000818161044e015281816106e501526108c001526000818161020101526106bc0152600081816103e6015261089701526000818161018b015261099b015260008181610365015261076c01526000818161033101526105ca0152600081816104820152818161067b015261085601526000818161041a01528181610c3a01528181610ce80152610db7015261114b6000f3fe60806040526004361061014b5760003560e01c8063969bb878116100b6578063da071a9f1161006f578063da071a9f14610470578063db584d25146104a4578063df7a290d146104d8578063f2fde38b14610505578063f994144d14610525578063fae68b1c1461053857600080fd5b8063969bb87814610353578063a9eef5de14610387578063aac693c3146103a7578063afdf831c146103d4578063b61119b214610408578063c24a0f8b1461043c57600080fd5b8063715018a611610108578063715018a61461026f57806382e4a39a146102845780638456cb59146102b8578063856ed8c9146102cd5780638da5cb5b1461030157806391aacca71461031f57600080fd5b80630916b9c91461015057806329f848ee146101795780633f4ba83a146101ad5780635c975abb146101c4578063652f4cce146101ef578063677342ab14610223575b600080fd5b34801561015c57600080fd5b5061016660015481565b6040519081526020015b60405180910390f35b34801561018557600080fd5b506101667f000000000000000000000000000000000000000000000000000000000000000081565b3480156101b957600080fd5b506101c261054b565b005b3480156101d057600080fd5b50600054600160a01b900460ff165b6040519015158152602001610170565b3480156101fb57600080fd5b506101667f000000000000000000000000000000000000000000000000000000000000000081565b34801561022f57600080fd5b506102577f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b039091168152602001610170565b34801561027b57600080fd5b506101c261055d565b34801561029057600080fd5b506101667f000000000000000000000000000000000000000000000000000000000000000081565b3480156102c457600080fd5b506101c261056f565b3480156102d957600080fd5b506102577f000000000000000000000000000000000000000000000000000000000000000081565b34801561030d57600080fd5b506000546001600160a01b0316610257565b34801561032b57600080fd5b506101667f000000000000000000000000000000000000000000000000000000000000000081565b34801561035f57600080fd5b506101667f000000000000000000000000000000000000000000000000000000000000000081565b34801561039357600080fd5b506101df6103a2366004610f97565b61057f565b3480156103b357600080fd5b506101666103c2366004610fec565b60036020526000908152604090205481565b3480156103e057600080fd5b506101667f000000000000000000000000000000000000000000000000000000000000000081565b34801561041457600080fd5b506102577f000000000000000000000000000000000000000000000000000000000000000081565b34801561044857600080fd5b506101667f000000000000000000000000000000000000000000000000000000000000000081565b34801561047c57600080fd5b506101667f000000000000000000000000000000000000000000000000000000000000000081565b3480156104b057600080fd5b506102577f000000000000000000000000000000000000000000000000000000000000000081565b3480156104e457600080fd5b506101666104f3366004611010565b60026020526000908152604090205481565b34801561051157600080fd5b506101c2610520366004610fec565b61062e565b6101c2610533366004611029565b610671565b6101c2610546366004611029565b61084c565b610553610acb565b61055b610af8565b565b610565610acb565b61055b6000610b4d565b610577610acb565b61055b610b9d565b600061062683838080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525050604080516001600160a01b038a1660208201527f0000000000000000000000000000000000000000000000000000000000000000935001905060408051601f198184030181528282528051602091820120908301520160405160208183030381529060405280519060200120610be0565b949350505050565b610636610acb565b6001600160a01b03811661066557604051631e4fbdf760e01b8152600060048201526024015b60405180910390fd5b61066e81610b4d565b50565b610679610bf6565b7f00000000000000000000000000000000000000000000000000000000000000003410156106ba5760405163d8c8818360e01b815260040160405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000000042108061070757507f000000000000000000000000000000000000000000000000000000000000000042115b1561072557604051631cdde67b60e01b815260040160405180910390fd5b61073033838361057f565b61074d5760405163e55b462960e01b815260040160405180910390fd5b33600090815260036020526040812054610768903490611081565b90507f00000000000000000000000000000000000000000000000000000000000000008111156107ab57604051637e2897ef60e11b815260040160405180910390fd5b33600090815260036020526040808220839055517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316913480156108fc02929091818181858888f19350505050158015610811573d6000803e3d6000fd5b5060405134815233907f76e8c2b1505ce37aa2f76217eb919d771a1292bcfa2916dce0fcdadb9d0091739060200160405180910390a2505050565b610854610bf6565b7f00000000000000000000000000000000000000000000000000000000000000003410156108955760405163d8c8818360e01b815260040160405180910390fd5b7f00000000000000000000000000000000000000000000000000000000000000004210806108e257507f000000000000000000000000000000000000000000000000000000000000000042115b1561090057604051631cdde67b60e01b815260040160405180910390fd5b6000346001546109109190611081565b90507f00000000000000000000000000000000000000000000000000000000000000008111156109535760405163da7cdff760e01b815260040160405180910390fd5b60018190556000805b600085858381811061097057610970611094565b90506020020135905061098281610c21565b600081815260026020526040812054906109ce6109bf837f00000000000000000000000000000000000000000000000000000000000000006110aa565b6109c987346110aa565b610e76565b90506109da8183611081565b6000848152600260205260409020556109f38186611081565b9450869250610a0591508390506110bd565b915081108015610a1457503482105b61095c57348214610a3857604051637e2897ef60e11b815260040160405180910390fd5b6040516001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169083156108fc029084906000818181858888f19350505050158015610a8e573d6000803e3d6000fd5b5060405182815233907f870a64ba7f49fb38d4972474a244e3e49f6cdf6a21eb6afb66ae2d56a79882d39060200160405180910390a25050505050565b6000546001600160a01b0316331461055b5760405163118cdaa760e01b815233600482015260240161065c565b610b00610e90565b6000805460ff60a01b191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b610ba5610bf6565b6000805460ff60a01b1916600160a01b1790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258610b303390565b600082610bed8584610eba565b14949350505050565b600054600160a01b900460ff161561055b5760405163d93c066560e01b815260040160405180910390fd5b6040516331a9108f60e11b8152600481018290526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690636352211e90602401602060405180830381865afa158015610c89573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cad91906110d6565b9050336001600160a01b03821603610cc3575050565b604051632e7cda1d60e21b81523360048201526001600160a01b0382811660248301527f00000000000000000000000000000000000000000000000000000000000000008116604483015260648201849052600060848301527f0000000000000000000000000000000000000000000000000000000000000000169063b9f368749060a401602060405180830381865afa158015610d65573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d8991906110f3565b15610d92575050565b604051631574d39f60e31b81523360048201526001600160a01b0382811660248301527f000000000000000000000000000000000000000000000000000000000000000081166044830152606482018490527f0000000000000000000000000000000000000000000000000000000000000000169063aba69cf890608401602060405180830381865afa158015610e2d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e5191906110f3565b15610e5a575050565b604051630e35d34560e11b81526004810183905260240161065c565b6000818310610e855781610e87565b825b90505b92915050565b600054600160a01b900460ff1661055b57604051638dfc202b60e01b815260040160405180910390fd5b600081815b8451811015610eff57610eeb82868381518110610ede57610ede611094565b6020026020010151610f07565b915080610ef7816110bd565b915050610ebf565b509392505050565b6000818310610f23576000828152602084905260409020610e87565b6000838152602083905260409020610e87565b6001600160a01b038116811461066e57600080fd5b60008083601f840112610f5d57600080fd5b50813567ffffffffffffffff811115610f7557600080fd5b6020830191508360208260051b8501011115610f9057600080fd5b9250929050565b600080600060408486031215610fac57600080fd5b8335610fb781610f36565b9250602084013567ffffffffffffffff811115610fd357600080fd5b610fdf86828701610f4b565b9497909650939450505050565b600060208284031215610ffe57600080fd5b813561100981610f36565b9392505050565b60006020828403121561102257600080fd5b5035919050565b6000806020838503121561103c57600080fd5b823567ffffffffffffffff81111561105357600080fd5b61105f85828601610f4b565b90969095509350505050565b634e487b7160e01b600052601160045260246000fd5b80820180821115610e8a57610e8a61106b565b634e487b7160e01b600052603260045260246000fd5b81810381811115610e8a57610e8a61106b565b6000600182016110cf576110cf61106b565b5060010190565b6000602082840312156110e857600080fd5b815161100981610f36565b60006020828403121561110557600080fd5b8151801515811461100957600080fdfea264697066735822122009733d6a2fc7b689de8a8d5e460b5a89c0e95f1856f1a6ed7a637b6f2744394d64736f6c63430008140033000000000000000000000000e1dc516b1486aba548eecd2947a11273518434a4000000000000000000000000b6263616c46a8e92b440b728dec3aadfb3a780120000000000000000000000003b4e0b1747d2f44920d6281c751ff3a2b46a4aacdb6c7c557ca72794b249fa0c5ec78eadc86a7b1e3535de5e9c3fe0a1125aae8700000000000000000000000000000000000000000000000003782dace9d900000000000000000000000000000000000000000000000000000a688906bd8b00000000000000000000000000000000000000000000000000000000000065687940000000000000000000000000000000000000000000000000000000006568b18000000000000000000000000000000000000000000000000000000000656a030000000000000000000000000000000000000000000000000000b1a2bc2ec50000000000000000000000000000000000000000000000000074717cfb6883100000

Deployed Bytecode

0x60806040526004361061014b5760003560e01c8063969bb878116100b6578063da071a9f1161006f578063da071a9f14610470578063db584d25146104a4578063df7a290d146104d8578063f2fde38b14610505578063f994144d14610525578063fae68b1c1461053857600080fd5b8063969bb87814610353578063a9eef5de14610387578063aac693c3146103a7578063afdf831c146103d4578063b61119b214610408578063c24a0f8b1461043c57600080fd5b8063715018a611610108578063715018a61461026f57806382e4a39a146102845780638456cb59146102b8578063856ed8c9146102cd5780638da5cb5b1461030157806391aacca71461031f57600080fd5b80630916b9c91461015057806329f848ee146101795780633f4ba83a146101ad5780635c975abb146101c4578063652f4cce146101ef578063677342ab14610223575b600080fd5b34801561015c57600080fd5b5061016660015481565b6040519081526020015b60405180910390f35b34801561018557600080fd5b506101667f0000000000000000000000000000000000000000000000000a688906bd8b000081565b3480156101b957600080fd5b506101c261054b565b005b3480156101d057600080fd5b50600054600160a01b900460ff165b6040519015158152602001610170565b3480156101fb57600080fd5b506101667f000000000000000000000000000000000000000000000000000000006568b18081565b34801561022f57600080fd5b506102577f0000000000000000000000003b4e0b1747d2f44920d6281c751ff3a2b46a4aac81565b6040516001600160a01b039091168152602001610170565b34801561027b57600080fd5b506101c261055d565b34801561029057600080fd5b506101667f000000000000000000000000000000000000000000000074717cfb688310000081565b3480156102c457600080fd5b506101c261056f565b3480156102d957600080fd5b506102577f00000000000000000000000000000000000076a84fef008cdabe6409d2fe638b81565b34801561030d57600080fd5b506000546001600160a01b0316610257565b34801561032b57600080fd5b506101667fdb6c7c557ca72794b249fa0c5ec78eadc86a7b1e3535de5e9c3fe0a1125aae8781565b34801561035f57600080fd5b506101667f00000000000000000000000000000000000000000000000003782dace9d9000081565b34801561039357600080fd5b506101df6103a2366004610f97565b61057f565b3480156103b357600080fd5b506101666103c2366004610fec565b60036020526000908152604090205481565b3480156103e057600080fd5b506101667f000000000000000000000000000000000000000000000000000000006568794081565b34801561041457600080fd5b506102577f000000000000000000000000e1dc516b1486aba548eecd2947a11273518434a481565b34801561044857600080fd5b506101667f00000000000000000000000000000000000000000000000000000000656a030081565b34801561047c57600080fd5b506101667f00000000000000000000000000000000000000000000000000b1a2bc2ec5000081565b3480156104b057600080fd5b506102577f00000000000000000000000000000000000000447e69651d841bd8d104bed49381565b3480156104e457600080fd5b506101666104f3366004611010565b60026020526000908152604090205481565b34801561051157600080fd5b506101c2610520366004610fec565b61062e565b6101c2610533366004611029565b610671565b6101c2610546366004611029565b61084c565b610553610acb565b61055b610af8565b565b610565610acb565b61055b6000610b4d565b610577610acb565b61055b610b9d565b600061062683838080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525050604080516001600160a01b038a1660208201527fdb6c7c557ca72794b249fa0c5ec78eadc86a7b1e3535de5e9c3fe0a1125aae87935001905060408051601f198184030181528282528051602091820120908301520160405160208183030381529060405280519060200120610be0565b949350505050565b610636610acb565b6001600160a01b03811661066557604051631e4fbdf760e01b8152600060048201526024015b60405180910390fd5b61066e81610b4d565b50565b610679610bf6565b7f00000000000000000000000000000000000000000000000000b1a2bc2ec500003410156106ba5760405163d8c8818360e01b815260040160405180910390fd5b7f000000000000000000000000000000000000000000000000000000006568b18042108061070757507f00000000000000000000000000000000000000000000000000000000656a030042115b1561072557604051631cdde67b60e01b815260040160405180910390fd5b61073033838361057f565b61074d5760405163e55b462960e01b815260040160405180910390fd5b33600090815260036020526040812054610768903490611081565b90507f00000000000000000000000000000000000000000000000003782dace9d900008111156107ab57604051637e2897ef60e11b815260040160405180910390fd5b33600090815260036020526040808220839055517f0000000000000000000000003b4e0b1747d2f44920d6281c751ff3a2b46a4aac6001600160a01b0316913480156108fc02929091818181858888f19350505050158015610811573d6000803e3d6000fd5b5060405134815233907f76e8c2b1505ce37aa2f76217eb919d771a1292bcfa2916dce0fcdadb9d0091739060200160405180910390a2505050565b610854610bf6565b7f00000000000000000000000000000000000000000000000000b1a2bc2ec500003410156108955760405163d8c8818360e01b815260040160405180910390fd5b7f00000000000000000000000000000000000000000000000000000000656879404210806108e257507f00000000000000000000000000000000000000000000000000000000656a030042115b1561090057604051631cdde67b60e01b815260040160405180910390fd5b6000346001546109109190611081565b90507f000000000000000000000000000000000000000000000074717cfb68831000008111156109535760405163da7cdff760e01b815260040160405180910390fd5b60018190556000805b600085858381811061097057610970611094565b90506020020135905061098281610c21565b600081815260026020526040812054906109ce6109bf837f0000000000000000000000000000000000000000000000000a688906bd8b00006110aa565b6109c987346110aa565b610e76565b90506109da8183611081565b6000848152600260205260409020556109f38186611081565b9450869250610a0591508390506110bd565b915081108015610a1457503482105b61095c57348214610a3857604051637e2897ef60e11b815260040160405180910390fd5b6040516001600160a01b037f0000000000000000000000003b4e0b1747d2f44920d6281c751ff3a2b46a4aac169083156108fc029084906000818181858888f19350505050158015610a8e573d6000803e3d6000fd5b5060405182815233907f870a64ba7f49fb38d4972474a244e3e49f6cdf6a21eb6afb66ae2d56a79882d39060200160405180910390a25050505050565b6000546001600160a01b0316331461055b5760405163118cdaa760e01b815233600482015260240161065c565b610b00610e90565b6000805460ff60a01b191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b610ba5610bf6565b6000805460ff60a01b1916600160a01b1790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258610b303390565b600082610bed8584610eba565b14949350505050565b600054600160a01b900460ff161561055b5760405163d93c066560e01b815260040160405180910390fd5b6040516331a9108f60e11b8152600481018290526000907f000000000000000000000000e1dc516b1486aba548eecd2947a11273518434a46001600160a01b031690636352211e90602401602060405180830381865afa158015610c89573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cad91906110d6565b9050336001600160a01b03821603610cc3575050565b604051632e7cda1d60e21b81523360048201526001600160a01b0382811660248301527f000000000000000000000000e1dc516b1486aba548eecd2947a11273518434a48116604483015260648201849052600060848301527f00000000000000000000000000000000000000447e69651d841bd8d104bed493169063b9f368749060a401602060405180830381865afa158015610d65573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d8991906110f3565b15610d92575050565b604051631574d39f60e31b81523360048201526001600160a01b0382811660248301527f000000000000000000000000e1dc516b1486aba548eecd2947a11273518434a481166044830152606482018490527f00000000000000000000000000000000000076a84fef008cdabe6409d2fe638b169063aba69cf890608401602060405180830381865afa158015610e2d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e5191906110f3565b15610e5a575050565b604051630e35d34560e11b81526004810183905260240161065c565b6000818310610e855781610e87565b825b90505b92915050565b600054600160a01b900460ff1661055b57604051638dfc202b60e01b815260040160405180910390fd5b600081815b8451811015610eff57610eeb82868381518110610ede57610ede611094565b6020026020010151610f07565b915080610ef7816110bd565b915050610ebf565b509392505050565b6000818310610f23576000828152602084905260409020610e87565b6000838152602083905260409020610e87565b6001600160a01b038116811461066e57600080fd5b60008083601f840112610f5d57600080fd5b50813567ffffffffffffffff811115610f7557600080fd5b6020830191508360208260051b8501011115610f9057600080fd5b9250929050565b600080600060408486031215610fac57600080fd5b8335610fb781610f36565b9250602084013567ffffffffffffffff811115610fd357600080fd5b610fdf86828701610f4b565b9497909650939450505050565b600060208284031215610ffe57600080fd5b813561100981610f36565b9392505050565b60006020828403121561102257600080fd5b5035919050565b6000806020838503121561103c57600080fd5b823567ffffffffffffffff81111561105357600080fd5b61105f85828601610f4b565b90969095509350505050565b634e487b7160e01b600052601160045260246000fd5b80820180821115610e8a57610e8a61106b565b634e487b7160e01b600052603260045260246000fd5b81810381811115610e8a57610e8a61106b565b6000600182016110cf576110cf61106b565b5060010190565b6000602082840312156110e857600080fd5b815161100981610f36565b60006020828403121561110557600080fd5b8151801515811461100957600080fdfea264697066735822122009733d6a2fc7b689de8a8d5e460b5a89c0e95f1856f1a6ed7a637b6f2744394d64736f6c63430008140033

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

000000000000000000000000e1dc516b1486aba548eecd2947a11273518434a4000000000000000000000000b6263616c46a8e92b440b728dec3aadfb3a780120000000000000000000000003b4e0b1747d2f44920d6281c751ff3a2b46a4aacdb6c7c557ca72794b249fa0c5ec78eadc86a7b1e3535de5e9c3fe0a1125aae8700000000000000000000000000000000000000000000000003782dace9d900000000000000000000000000000000000000000000000000000a688906bd8b00000000000000000000000000000000000000000000000000000000000065687940000000000000000000000000000000000000000000000000000000006568b18000000000000000000000000000000000000000000000000000000000656a030000000000000000000000000000000000000000000000000000b1a2bc2ec50000000000000000000000000000000000000000000000000074717cfb6883100000

-----Decoded View---------------
Arg [0] : grapeNFTAddress_ (address): 0xe1dC516B1486Aba548eecD2947A11273518434a4
Arg [1] : initialOwner_ (address): 0xb6263616C46A8e92B440B728deC3aaDfb3A78012
Arg [2] : receiverWallet_ (address): 0x3b4e0b1747D2F44920d6281C751ff3a2B46a4aaC
Arg [3] : referralCodeMerkleRoot_ (bytes32): 0xdb6c7c557ca72794b249fa0c5ec78eadc86a7b1e3535de5e9c3fe0a1125aae87
Arg [4] : config_ (uint256[7]): 250000000000000000,750000000000000000,1701345600,1701360000,1701446400,50000000000000000,2148000000000000000000

-----Encoded View---------------
11 Constructor Arguments found :
Arg [0] : 000000000000000000000000e1dc516b1486aba548eecd2947a11273518434a4
Arg [1] : 000000000000000000000000b6263616c46a8e92b440b728dec3aadfb3a78012
Arg [2] : 0000000000000000000000003b4e0b1747d2f44920d6281c751ff3a2b46a4aac
Arg [3] : db6c7c557ca72794b249fa0c5ec78eadc86a7b1e3535de5e9c3fe0a1125aae87
Arg [4] : 00000000000000000000000000000000000000000000000003782dace9d90000
Arg [5] : 0000000000000000000000000000000000000000000000000a688906bd8b0000
Arg [6] : 0000000000000000000000000000000000000000000000000000000065687940
Arg [7] : 000000000000000000000000000000000000000000000000000000006568b180
Arg [8] : 00000000000000000000000000000000000000000000000000000000656a0300
Arg [9] : 00000000000000000000000000000000000000000000000000b1a2bc2ec50000
Arg [10] : 000000000000000000000000000000000000000000000074717cfb6883100000


Deployed Bytecode Sourcemap

423:10832:22:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1422:32;;;;;;;;;;;;;;;;;;;160:25:28;;;148:2;133:18;1422:32:22;;;;;;;;800:34;;;;;;;;;;;;;;;9780:65;;;;;;;;;;;;;:::i;:::-;;1850:84:11;;;;;;;;;;-1:-1:-1;1897:4:11;1920:7;-1:-1:-1;;;1920:7:11;;;;1850:84;;;361:14:28;;354:22;336:41;;324:2;309:18;1850:84:11;196:187:28;926:42:22;;;;;;;;;;;;;;;1053:47;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;568:32:28;;;550:51;;538:2;523:18;1053:47:22;388:219:28;2293:101:0;;;;;;;;;;;;;:::i;1012:35:22:-;;;;;;;;;;;;;;;9616:61;;;;;;;;;;;;;:::i;1237:129::-;;;;;;;;;;;;;;;1638:85:0;;;;;;;;;;-1:-1:-1;1684:7:0;1710:6;-1:-1:-1;;;;;1710:6:0;1638:85;;654:47:22;;;;;;;;;;;;;;;707:44;;;;;;;;;;;;;;;9125:340;;;;;;;;;;-1:-1:-1;9125:340:22;;;;;:::i;:::-;;:::i;1572:65::-;;;;;;;;;;-1:-1:-1;1572:65:22;;;;;:::i;:::-;;;;;;;;;;;;;;883:37;;;;;;;;;;;;;;;523:33;;;;;;;;;;;;;;;974:32;;;;;;;;;;;;;;;562:43;;;;;;;;;;;;;;;1106:125;;;;;;;;;;;;;;;1482:62;;;;;;;;;;-1:-1:-1;1482:62:22;;;;;:::i;:::-;;;;;;;;;;;;;;2543:215:0;;;;;;;;;;-1:-1:-1;2543:215:0;;;;;:::i;:::-;;:::i;7458:1081:22:-;;;;;;:::i;:::-;;:::i;4958:2031::-;;;;;;:::i;:::-;;:::i;9780:65::-;1531:13:0;:11;:13::i;:::-;9828:10:22::1;:8;:10::i;:::-;9780:65::o:0;2293:101:0:-;1531:13;:11;:13::i;:::-;2357:30:::1;2384:1;2357:18;:30::i;9616:61:22:-:0;1531:13:0;:11;:13::i;:::-;9662:8:22::1;:6;:8::i;9125:340::-:0;9247:4;9282:176;9318:13;;9282:176;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;9422:19:22;;;-1:-1:-1;;;;;568:32:28;;9422:19:22;;;550:51:28;9349:22:22;;-1:-1:-1;523:18:28;;-1:-1:-1;9422:19:22;;;-1:-1:-1;;9422:19:22;;;;;;;;;9412:30;;9422:19;9412:30;;;;9399:44;;;4231:19:28;4266:12;9399:44:22;;;;;;;;;;;;9389:55;;;;;;9282:18;:176::i;:::-;9263:195;9125:340;-1:-1:-1;;;;9125:340:22:o;2543:215:0:-;1531:13;:11;:13::i;:::-;-1:-1:-1;;;;;2627:22:0;::::1;2623:91;;2672:31;::::0;-1:-1:-1;;;2672:31:0;;2700:1:::1;2672:31;::::0;::::1;550:51:28::0;523:18;;2672:31:0::1;;;;;;;;2623:91;2723:28;2742:8;2723:18;:28::i;:::-;2543:215:::0;:::o;7458:1081:22:-;1474:19:11;:17;:19::i;:::-;4285:18:22::1;4273:9;:30;4269:62;;;4312:19;;-1:-1:-1::0;;;4312:19:22::1;;;;;;;;;;;4269:62;7664:17:::2;7646:15;:35;:64;;;;7703:7;7685:15;:25;7646:64;7642:110;;;7733:8;;-1:-1:-1::0;;;7733:8:22::2;;;;;;;;;;;7642:110;7808:45;7827:10;7839:13;;7808:18;:45::i;:::-;7803:105;;7876:21;;-1:-1:-1::0;;;7876:21:22::2;;;;;;;;;;;7803:105;8026:10;7977:28;8008:29:::0;;;:17:::2;:29;::::0;;;;;:53:::2;::::0;8052:9:::2;::::0;8008:53:::2;:::i;:::-;7977:84;;8171:19;8148:20;:42;8144:102;;;8213:22;;-1:-1:-1::0;;;8213:22:22::2;;;;;;;;;;;8144:102;8325:10;8307:29;::::0;;;:17:::2;:29;::::0;;;;;:52;;;8413:34;:14:::2;-1:-1:-1::0;;;;;8413:23:22::2;::::0;8437:9:::2;8413:34:::0;::::2;;;::::0;8437:9;;8413:34;8307:29;8413:34;8437:9;8413:23;:34;::::2;;;;;;;;;;;;;::::0;::::2;;;;;-1:-1:-1::0;8485:47:22::2;::::0;8522:9:::2;160:25:28::0;;8510:10:22::2;::::0;8485:47:::2;::::0;148:2:28;133:18;8485:47:22::2;;;;;;;7584:955;7458:1081:::0;;:::o;4958:2031::-;1474:19:11;:17;:19::i;:::-;4285:18:22::1;4273:9;:30;4269:62;;;4312:19;;-1:-1:-1::0;;;4312:19:22::1;;;;;;;;;;;4269:62;5147:12:::2;5129:15;:30;:59;;;;5181:7;5163:15;:25;5129:59;5125:105;;;5211:8;;-1:-1:-1::0;;;5211:8:22::2;;;;;;;;;;;5125:105;5281:25;5325:9;5309:13;;:25;;;;:::i;:::-;5281:53;;5440:10;5420:17;:30;5416:89;;;5473:21;;-1:-1:-1::0;;;5473:21:22::2;;;;;;;;;;;5416:89;5549:13;:33:::0;;;5633:23:::2;::::0;5727:924:::2;5744:16;5763:9;;5773:2;5763:13;;;;;;;:::i;:::-;;;;;;;5744:32;;5840:27;5858:8;5840:17;:27::i;:::-;5930:26;5959:22:::0;;;:12:::2;:22;::::0;;;;;;6083:291:::2;6109:30;5959:22:::0;6109:9:::2;:30;:::i;:::-;6235:27;6247:15:::0;6235:9:::2;:27;:::i;:::-;6083:8;:291::i;:::-;6062:312:::0;-1:-1:-1;6461:31:22::2;6062:312:::0;6461:18;:31:::2;:::i;:::-;6436:22;::::0;;;:12:::2;:22;::::0;;;;:56;6547:29:::2;6566:10:::0;6547:29;::::2;:::i;:::-;::::0;-1:-1:-1;6602:9:22;;-1:-1:-1;6595:4:22::2;::::0;-1:-1:-1;6595:4:22;;-1:-1:-1;6595:4:22::2;:::i;:::-;;;;:23;:54;;;;;6640:9;6622:15;:27;6595:54;5727:924;;6742:9;6723:15;:28;6719:88;;6774:22;;-1:-1:-1::0;;;6774:22:22::2;;;;;;;;;;;6719:88;6860:40;::::0;-1:-1:-1;;;;;6860:14:22::2;:23;::::0;:40;::::2;;;::::0;6884:15;;6860:40:::2;::::0;;;6884:15;6860:23;:40;::::2;;;;;;;;;;;;;::::0;::::2;;;;;-1:-1:-1::0;6938:44:22::2;::::0;160:25:28;;;6954:10:22::2;::::0;6938:44:::2;::::0;148:2:28;133:18;6938:44:22::2;;;;;;;5072:1917;;;4958:2031:::0;;:::o;1796:162:0:-;1684:7;1710:6;-1:-1:-1;;;;;1710:6:0;735:10:10;1855:23:0;1851:101;;1901:40;;-1:-1:-1;;;1901:40:0;;735:10:10;1901:40:0;;;550:51:28;523:18;;1901:40:0;388:219:28;2710:117:11;1721:16;:14;:16::i;:::-;2778:5:::1;2768:15:::0;;-1:-1:-1;;;;2768:15:11::1;::::0;;2798:22:::1;735:10:10::0;2807:12:11::1;2798:22;::::0;-1:-1:-1;;;;;568:32:28;;;550:51;;538:2;523:18;2798:22:11::1;;;;;;;2710:117::o:0;2912:187:0:-;2985:16;3004:6;;-1:-1:-1;;;;;3020:17:0;;;-1:-1:-1;;;;;;3020:17:0;;;;;;3052:40;;3004:6;;;;;;;3052:40;;2985:16;3052:40;2975:124;2912:187;:::o;2463:115:11:-;1474:19;:17;:19::i;:::-;2522:7:::1;:14:::0;;-1:-1:-1;;;;2522:14:11::1;-1:-1:-1::0;;;2522:14:11::1;::::0;;2551:20:::1;2558:12;735:10:10::0;;656:96;1265:154:14;1356:4;1408;1379:25;1392:5;1399:4;1379:12;:25::i;:::-;:33;;1265:154;-1:-1:-1;;;;1265:154:14:o;2002:128:11:-;1897:4;1920:7;-1:-1:-1;;;1920:7:11;;;;2063:61;;;2098:15;;-1:-1:-1;;;2098:15:11;;;;;;;;;;;10423:830:22;10514:26;;-1:-1:-1;;;10514:26:22;;;;;160:25:28;;;10492:19:22;;10514:8;-1:-1:-1;;;;;10514:16:22;;;;133:18:28;;10514:26:22;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;10492:48;-1:-1:-1;10603:10:22;-1:-1:-1;;;;;10588:25:22;;;10584:38;;10615:7;10423:830;:::o;10584:38::-;10692:193;;-1:-1:-1;;;10692:193:22;;10751:10;10692:193;;;5572:34:28;-1:-1:-1;;;;;5642:15:28;;;5622:18;;;5615:43;10816:8:22;5694:15:28;;5674:18;;;5667:43;5726:18;;;5719:34;;;-1:-1:-1;5769:19:28;;;5762:31;10692:18:22;:41;;;;5506:19:28;;10692:193:22;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;10675:228;;;10896:7;10423:830;:::o;10675:228::-;10973:172;;-1:-1:-1;;;10973:172:22;;11031:10;10973:172;;;6355:34:28;-1:-1:-1;;;;;6425:15:28;;;6405:18;;;6398:43;11096:8:22;6477:15:28;;6457:18;;;6450:43;6509:18;;;6502:34;;;10973:18:22;:40;;;;6289:19:28;;10973:172:22;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;10956:207;;;11156:7;10423:830;:::o;10956:207::-;11223:23;;-1:-1:-1;;;11223:23:22;;;;;160:25:28;;;133:18;;11223:23:22;14:177:28;2557:104:19;2615:7;2645:1;2641;:5;:13;;2653:1;2641:13;;;2649:1;2641:13;2634:20;;2557:104;;;;;:::o;2202:126:11:-;1897:4;1920:7;-1:-1:-1;;;1920:7:11;;;;2260:62;;2296:15;;-1:-1:-1;;;2296:15:11;;;;;;;;;;;1967:290:14;2050:7;2092:4;2050:7;2106:116;2130:5;:12;2126:1;:16;2106:116;;;2178:33;2188:12;2202:5;2208:1;2202:8;;;;;;;;:::i;:::-;;;;;;;2178:9;:33::i;:::-;2163:48;-1:-1:-1;2144:3:14;;;;:::i;:::-;;;;2106:116;;;-1:-1:-1;2238:12:14;1967:290;-1:-1:-1;;;1967:290:14:o;9229:147::-;9292:7;9322:1;9318;:5;:51;;9564:13;9655:15;;;9690:4;9683:15;;;9736:4;9720:21;;9318:51;;;9564:13;9655:15;;;9690:4;9683:15;;;9736:4;9720:21;;9326:20;9496:261;1238:131:28;-1:-1:-1;;;;;1313:31:28;;1303:42;;1293:70;;1359:1;1356;1349:12;1374:367;1437:8;1447:6;1501:3;1494:4;1486:6;1482:17;1478:27;1468:55;;1519:1;1516;1509:12;1468:55;-1:-1:-1;1542:20:28;;1585:18;1574:30;;1571:50;;;1617:1;1614;1607:12;1571:50;1654:4;1646:6;1642:17;1630:29;;1714:3;1707:4;1697:6;1694:1;1690:14;1682:6;1678:27;1674:38;1671:47;1668:67;;;1731:1;1728;1721:12;1668:67;1374:367;;;;;:::o;1746:572::-;1841:6;1849;1857;1910:2;1898:9;1889:7;1885:23;1881:32;1878:52;;;1926:1;1923;1916:12;1878:52;1965:9;1952:23;1984:31;2009:5;1984:31;:::i;:::-;2034:5;-1:-1:-1;2090:2:28;2075:18;;2062:32;2117:18;2106:30;;2103:50;;;2149:1;2146;2139:12;2103:50;2188:70;2250:7;2241:6;2230:9;2226:22;2188:70;:::i;:::-;1746:572;;2277:8;;-1:-1:-1;2162:96:28;;-1:-1:-1;;;;1746:572:28:o;2323:247::-;2382:6;2435:2;2423:9;2414:7;2410:23;2406:32;2403:52;;;2451:1;2448;2441:12;2403:52;2490:9;2477:23;2509:31;2534:5;2509:31;:::i;:::-;2559:5;2323:247;-1:-1:-1;;;2323:247:28:o;3033:180::-;3092:6;3145:2;3133:9;3124:7;3120:23;3116:32;3113:52;;;3161:1;3158;3151:12;3113:52;-1:-1:-1;3184:23:28;;3033:180;-1:-1:-1;3033:180:28:o;3218:437::-;3304:6;3312;3365:2;3353:9;3344:7;3340:23;3336:32;3333:52;;;3381:1;3378;3371:12;3333:52;3421:9;3408:23;3454:18;3446:6;3443:30;3440:50;;;3486:1;3483;3476:12;3440:50;3525:70;3587:7;3578:6;3567:9;3563:22;3525:70;:::i;:::-;3614:8;;3499:96;;-1:-1:-1;3218:437:28;-1:-1:-1;;;;3218:437:28:o;4289:127::-;4350:10;4345:3;4341:20;4338:1;4331:31;4381:4;4378:1;4371:15;4405:4;4402:1;4395:15;4421:125;4486:9;;;4507:10;;;4504:36;;;4520:18;;:::i;4551:127::-;4612:10;4607:3;4603:20;4600:1;4593:31;4643:4;4640:1;4633:15;4667:4;4664:1;4657:15;4683:128;4750:9;;;4771:11;;;4768:37;;;4785:18;;:::i;4816:135::-;4855:3;4876:17;;;4873:43;;4896:18;;:::i;:::-;-1:-1:-1;4943:1:28;4932:13;;4816:135::o;4956:251::-;5026:6;5079:2;5067:9;5058:7;5054:23;5050:32;5047:52;;;5095:1;5092;5085:12;5047:52;5127:9;5121:16;5146:31;5171:5;5146:31;:::i;5804:277::-;5871:6;5924:2;5912:9;5903:7;5899:23;5895:32;5892:52;;;5940:1;5937;5930:12;5892:52;5972:9;5966:16;6025:5;6018:13;6011:21;6004:5;6001:32;5991:60;;6047:1;6044;6037:12

Swarm Source

ipfs://09733d6a2fc7b689de8a8d5e460b5a89c0e95f1856f1a6ed7a637b6f2744394d

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
Loading...
Loading
[ Download: CSV Export  ]
[ 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.