ETH Price: $3,407.15 (+2.55%)

Contract

0x6DffB6415c96EC393Bf018fB824934d7b5B637a0
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Token Holdings

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Unstake198290722024-05-09 1:00:35229 days ago1715216435IN
0x6DffB641...7b5B637a0
0 ETH0.000108353.75208317
Unstake198290692024-05-09 0:59:59229 days ago1715216399IN
0x6DffB641...7b5B637a0
0 ETH0.000094323.26644978
Unstake198290692024-05-09 0:59:59229 days ago1715216399IN
0x6DffB641...7b5B637a0
0 ETH0.000367093
Unstake198266342024-05-08 16:49:23229 days ago1715186963IN
0x6DffB641...7b5B637a0
0 ETH0.001009158.24711688
Unstake195325932024-03-28 12:24:59270 days ago1711628699IN
0x6DffB641...7b5B637a0
0 ETH0.0049513340.46368441
Unstake194369082024-03-15 0:53:11284 days ago1710463991IN
0x6DffB641...7b5B637a0
0 ETH0.0042681540.54679176
Unstake193354552024-02-29 20:08:47298 days ago1709237327IN
0x6DffB641...7b5B637a0
0 ETH0.0052497865.41051487
Unstake189385972024-01-05 4:06:35354 days ago1704427595IN
0x6DffB641...7b5B637a0
0 ETH0.0015061417.08325957
Unstake189306582024-01-04 1:21:47355 days ago1704331307IN
0x6DffB641...7b5B637a0
0 ETH0.0088336726.03776491
Unstake188576132023-12-24 19:10:23365 days ago1703445023IN
0x6DffB641...7b5B637a0
0 ETH0.002659221.73176832
Unstake185773132023-11-15 12:33:47404 days ago1700051627IN
0x6DffB641...7b5B637a0
0 ETH0.0037806435.91546975
Unstake182880472023-10-06 1:01:23445 days ago1696554083IN
0x6DffB641...7b5B637a0
0 ETH0.001044278.53410691
Unstake182680632023-10-03 5:56:47447 days ago1696312607IN
0x6DffB641...7b5B637a0
0 ETH0.00107548.39362092
Unstake182321172023-09-28 5:19:59452 days ago1695878399IN
0x6DffB641...7b5B637a0
0 ETH0.000632716.01067522
Unstake181786662023-09-20 17:42:35460 days ago1695231755IN
0x6DffB641...7b5B637a0
0 ETH0.0008283432.07782839
Unstake181786622023-09-20 17:41:47460 days ago1695231707IN
0x6DffB641...7b5B637a0
0 ETH0.0034562332.83369106
Unstake181551762023-09-17 10:29:59463 days ago1694946599IN
0x6DffB641...7b5B637a0
0 ETH0.0011457610.88458336
Unstake181166372023-09-12 0:18:47469 days ago1694477927IN
0x6DffB641...7b5B637a0
0 ETH0.0003613913.9949363
Unstake181166272023-09-12 0:16:47469 days ago1694477807IN
0x6DffB641...7b5B637a0
0 ETH0.0013876315.73902128
Unstake180497922023-09-02 15:41:59478 days ago1693669319IN
0x6DffB641...7b5B637a0
0 ETH0.0036162418.93947442
Unstake180497672023-09-02 15:36:59478 days ago1693669019IN
0x6DffB641...7b5B637a0
0 ETH0.0014525116.47491364
Unstake180059292023-08-27 12:13:47484 days ago1693138427IN
0x6DffB641...7b5B637a0
0 ETH0.0011942211.34492786
Unstake180003812023-08-26 17:37:59485 days ago1693071479IN
0x6DffB641...7b5B637a0
0 ETH0.0019487815.21040924
Unstake179565142023-08-20 14:20:35491 days ago1692541235IN
0x6DffB641...7b5B637a0
0 ETH0.0018371113.72216899
Unstake178198152023-08-01 11:20:47510 days ago1690888847IN
0x6DffB641...7b5B637a0
0 ETH0.0015869617.999916
View all transactions

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
NFTStaking

Compiler Version
v0.8.9+commit.e5eed63a

Optimization Enabled:
Yes with 500 runs

Other Settings:
default evmVersion
File 1 of 21 : KahiruStaking.sol
// SPDX-License-Identifier: MIT LICENSE
// Developed by Thanic® Tech Labs

pragma solidity 0.8.9;

import "./StoneParticles.sol";
import "../KahiruMK.sol";
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
import "@openzeppelin/contracts/utils/Strings.sol";

contract NFTStaking is Ownable, IERC721Receiver {

  uint256 public totalStaked;


  
  struct Stake {
    uint24 tokenId;
    uint48 timestamp;
    uint256 cycles;
    address owner;
    uint8 rarity;
  }

  event NFTStaked(address owner, uint256 tokenId, uint256 value);
  event NFTUnstaked(address owner, uint256 tokenId, uint256 value);
  event Claimed(address owner, uint256 amount);

  KahiruF nft;
  StoneParticles token;

  mapping(uint256 => Stake) public vault;
  mapping(bytes => bool) public signatureUsed;

   constructor(KahiruF _nft, StoneParticles _token) { 
    nft = _nft;
    token = _token;
  }

  function stake(uint256[] calldata tokenIds,uint8[] calldata rarity, bytes32 hash, bytes memory signature) external {
    require(recoverSigner(hash, signature), "Sign not valid");
    require(!signatureUsed[signature], "Signature has already been used.");
    uint256 tokenId;
    totalStaked += tokenIds.length;
    for (uint i = 0; i < tokenIds.length; i++) {
      tokenId = tokenIds[i];
      require(nft.ownerOf(tokenId) == msg.sender, "not your token");
      require(vault[tokenId].tokenId == 0, 'already staked');

      nft.transferFrom(msg.sender, address(this), tokenId);
      emit NFTStaked(msg.sender, tokenId, block.timestamp);

      vault[tokenId] = Stake({
        owner: msg.sender,
        tokenId: uint24(tokenId),
        cycles: 0,
        timestamp: uint48(block.timestamp),
        rarity: rarity[i]
      });
    }
    signatureUsed[signature] = true;
  }

  function _unstakeMany(address account, uint256[] calldata tokenIds) internal {
    uint256 tokenId;
    totalStaked -= tokenIds.length;
    for (uint i = 0; i < tokenIds.length; i++) {
      tokenId = tokenIds[i];
      Stake memory staked = vault[tokenId];
      require(staked.owner == msg.sender, "not an owner");

      delete vault[tokenId];
      emit NFTUnstaked(account, tokenId, block.timestamp);
      nft.transferFrom(address(this), account, tokenId);
    }
  }

  function claim(uint256[] calldata tokenIds) external {
      _claim(msg.sender, tokenIds, false);
  }

  function claimForAddress(address account, uint256[] calldata tokenIds) external {
      _claim(account, tokenIds, false);
  }

  function unstake(uint256[] calldata tokenIds) external {
      _claim(msg.sender, tokenIds, true);
  }

  function _claim(address account, uint256[] calldata tokenIds, bool _unstake) internal{
     uint256 tokenId;
     uint256 earned = 0;
     uint256 withdraw = 0;
     uint256 _cycles = 0;
     uint256 bonus = 0;
     uint256 ammount = 0;
     uint256 rarityrewards = 0; 


    for (uint i = 0; i < tokenIds.length; i++) {
      tokenId = tokenIds[i];
      Stake memory staked = vault[tokenId];
      require(staked.owner == account, "not an owner");
      uint256 stakedAt = staked.timestamp; 
      _cycles = ((block.timestamp - stakedAt) / 86400);
      staked.cycles = _cycles;
      ammount = 7 * _cycles;
      rarityrewards = _cycles/7;
      if (staked.rarity == 0){
        bonus = 2 * rarityrewards;
      }
      if (staked.rarity == 1){
        bonus = 5 * rarityrewards;
      }
      if (staked.rarity == 2){
        bonus = 15 * rarityrewards;
      }
      withdraw = withdraw + ammount + bonus;
    }
    earned = withdraw * (1 ether);
    if (earned > 0) {
      token.mint(account, earned);
    }
    if (_unstake) {
      _unstakeMany(account, tokenIds);
    }
    emit Claimed(account, earned);
  }

  function earningInfo(address account, uint256[] calldata tokenIds) external view returns (uint256[1] memory info, uint256 cycles, uint256 total) {
     uint256 tokenId;
     uint256 earned = 0;
     uint256 withdraw = 0;
     uint256 _cycles = 0;
     uint256 bonus = 0;
     uint256 ammount = 0;
     uint256 rarityrewards = 0; 

    for (uint i = 0; i < tokenIds.length; i++) {
      tokenId = tokenIds[i];
      Stake memory staked = vault[tokenId];
      require(staked.owner == account, "not an owner");
      uint256 stakedAt = staked.timestamp; 
      _cycles = ((block.timestamp - stakedAt) / 86400);
      staked.cycles = _cycles;
      ammount = 7 * _cycles;
      rarityrewards = _cycles/7;
      if (staked.rarity == 0){
        bonus = 2 * rarityrewards;
      }
      if (staked.rarity == 1){
        bonus = 5 * rarityrewards;
      }
      if (staked.rarity == 2){
        bonus = 15 * rarityrewards;
      }
      withdraw = withdraw + ammount + bonus;
    }
    earned = withdraw * (1 ether);

    if (earned > 0) {
      return ([earned],_cycles, bonus);
    }
}

  function balanceOf(address account) public view returns (uint256) {
    uint256 balance = 0;
    uint256 supply = nft.totalSupply();
    for(uint i = 0; i <= supply; i++) {
      if (vault[i].owner == account) {
        balance += 1;
      }
    }
    return balance;
  }


  function tokensOfOwner(address account) public view returns (uint256[] memory ownerTokens) {

    uint256 supply = nft.totalSupply();
    uint256[] memory tmp = new uint256[](supply);

    uint256 index = 0;
    for(uint tokenId = 0; tokenId <= supply; tokenId++) {
      if (vault[tokenId].owner == account) {
        tmp[index] = vault[tokenId].tokenId;
        index +=1;
      }
    }

    uint256[] memory tokens = new uint256[](index);
    for(uint i = 0; i < index; i++) {
      tokens[i] = tmp[i];
    }

    return tokens;
  }

  function recoverSigner(bytes32 hash, bytes memory signature) private pure returns (bool) {
    bytes32 messageDigest = keccak256(
        abi.encodePacked(
            "\x19Ethereum Signed Message:\n32", 
            hash
        )
    );
    if (ECDSA.recover(messageDigest, signature) == 0x0aC6119362e892aeA0025BF00182CaD3673A9c79){
      return true;
    }
    else{
      return false;
    }
}

  function divide(uint256 uno) public pure returns (uint256) {

        uint division = uno / 20;
        return division;
    }

  function onERC721Received(
        address,
        address from,
        uint256,
        bytes calldata
    ) external pure override returns (bytes4) {
      require(from == address(0x0), "Cannot send nfts to Vault directly");
      return IERC721Receiver.onERC721Received.selector;
    }
  
}

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

pragma solidity ^0.8.0;

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

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

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

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

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

File 3 of 21 : MerkleProof.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (utils/cryptography/MerkleProof.sol)

pragma solidity ^0.8.0;

/**
 * @dev These functions deal with verification of Merkle Trees proofs.
 *
 * The proofs can be generated using the JavaScript library
 * https://github.com/miguelmota/merkletreejs[merkletreejs].
 * Note: the hashing algorithm should be keccak256 and pair sorting should be enabled.
 *
 * See `test/utils/cryptography/MerkleProof.test.js` for some examples.
 *
 * 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.
 */
library MerkleProof {
    /**
     * @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 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.
     *
     * _Available since v4.4._
     */
    function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) {
        bytes32 computedHash = leaf;
        for (uint256 i = 0; i < proof.length; i++) {
            bytes32 proofElement = proof[i];
            if (computedHash <= proofElement) {
                // Hash(current computed hash + current element of the proof)
                computedHash = _efficientHash(computedHash, proofElement);
            } else {
                // Hash(current element of the proof + current computed hash)
                computedHash = _efficientHash(proofElement, computedHash);
            }
        }
        return computedHash;
    }

    function _efficientHash(bytes32 a, bytes32 b) private pure returns (bytes32 value) {
        assembly {
            mstore(0x00, a)
            mstore(0x20, b)
            value := keccak256(0x00, 0x40)
        }
    }
}

File 4 of 21 : ECDSA.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (utils/cryptography/ECDSA.sol)

pragma solidity ^0.8.0;

import "../Strings.sol";

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

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

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

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

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
     *
     * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
     *
     * _Available since v4.3._
     */
    function tryRecover(
        bytes32 hash,
        bytes32 r,
        bytes32 vs
    ) internal pure returns (address, RecoverError) {
        bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
        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.
     *
     * _Available since v4.2._
     */
    function recover(
        bytes32 hash,
        bytes32 r,
        bytes32 vs
    ) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, r, vs);
        _throwError(error);
        return recovered;
    }

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

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

        return (signer, RecoverError.NoError);
    }

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

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

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

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

File 5 of 21 : KahiruMK.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

import '@openzeppelin/contracts/access/Ownable.sol';
import '@openzeppelin/contracts/security/ReentrancyGuard.sol';
import '@openzeppelin/contracts/utils/Counters.sol';
import 'erc721a/contracts/ERC721A.sol';
import '@openzeppelin/contracts/utils/Address.sol';
import '@openzeppelin/contracts/utils/cryptography/ECDSA.sol';
import '@openzeppelin/contracts/utils/cryptography/MerkleProof.sol';

contract KahiruF is ERC721A, ReentrancyGuard, Ownable {
    using Counters for Counters.Counter;  
    using Address for address;
    using ECDSA for bytes32;
    
    // Starting and stopping sale // Empezar y parar etapas
    bool public saleActive = false;
    bool public whitelistActive = false;
    bool public raffleActive = false;

    // Reserved for the team, customs, giveaways, collabs and so on // Reservado para equipo y otros
    uint256 public reserved = 222;

    // Price of each token // Precio inicial mint
    uint256 public Wl_price = 0.12 ether; // Price of Whitelisted Mints
    uint256 public Raffle_price = 0.14 ether; // Price of Raffled Mints

    // Public Sale Key // Key para verificación extra
    string publicKey; // Will change to hash instead of int

    // Maximum limit of tokens that can ever exist // Número de Tokens
    mapping(address => uint256) private mintCountMap;
    mapping(address => uint256) private allowedMintCountMap;
    
    uint256 public constant MAX_SUPPLY = 7222;
    uint256 public constant MAX_WL_SUPPLY = 5000;
    uint256 public constant MINT_LIMIT_PER_WALLET = 1;

    function max(uint256 a, uint256 b) private pure returns (uint256) {
    return a >= b ? a : b;
    }

    function allowedMintCount(address minter) public view returns (uint256) {
        if (saleActive || whitelistActive || raffleActive) {
        return (
            max(allowedMintCountMap[minter], MINT_LIMIT_PER_WALLET) -
            mintCountMap[minter]
        );
        }

        return allowedMintCountMap[minter] - mintCountMap[minter];
    }

    function updateMintCount(address minter, uint256 count) private {
        mintCountMap[minter] += count;
    }

    // The base link that leads to the image / video of the token // URL del arte-metadata
    //string public baseTokenURI = "https://api.kahiru.io/";
    string public baseTokenURI = "https://www.721.so/api/example/metadata/";

    // Team addresses for withdrawals // Carteras de retirada de balance
    address public a1;

    // List of addresses that have a number of reserved tokens for whitelist // Lista de direcciones para Whitelist y Raffle
    bytes32 private _whitelistMerkleRoot = 0xa55ed0edb0fc32171feb79ad2dc5b1551a4765612ce344057f1166c7ddcb7111;
    bytes32 private _whitelistNeutralMerkleRoot = 0x52551a51441048412a12edf749d65363e41af37ba1969a62caba0e45e39792bf;
    bytes32 private _raffleMerkleRoot = 0x420041bc817938d28f6ec183b5057d7189de1a99a5b6d3f6b33980a92b153d06;

    constructor () ERC721A ("Kahiru", "KAHIRU") {
    }

    // Override so the openzeppelin tokenURI() method will use this method to create the full tokenURI instead // Reemplazar URI
    function _baseURI() internal view virtual override returns (string memory) {
        return baseTokenURI;
    }

    // Exclusive whitelist minting // Función mint con Whitelist
    Counters.Counter private supplyCounter;

    function mintWhitelist(bytes32[] memory proof, string memory _pass) public payable nonReentrant {
        uint256 quantity = 1;
        uint256 supply = totalSupply();
        require( whitelistActive,                   "Whitelist isn't active" );
        require(
            MerkleProof.verify(
                proof,
                _whitelistMerkleRoot,
                keccak256(abi.encodePacked(msg.sender))
            ),
            "Whitelist validation failed"
        );
        require( keccak256(abi.encodePacked(publicKey)) == keccak256(abi.encodePacked(_pass)), "Key error"); // Key verifying web3 call // Key que "Verifica" la llamada al contract desde la web3
        require( supply + quantity <= MAX_WL_SUPPLY,    "Can't mint more than WL supply" );
        require( supply + quantity <= MAX_SUPPLY,    "Can't mint more than max supply" );
        require( msg.value == Wl_price * quantity,      "Wrong amount of ETH sent" );
        if (allowedMintCount(msg.sender) >= 1) {
        updateMintCount(msg.sender, 1);
        } else {
        revert("Minting limit exceeded");
        }
        _safeMint( msg.sender, quantity);
        
    }

    // Exclusive Neutral whitelist minting // Función mint con Neutral Whitelist

    function mintNeutralWhitelist(bytes32[] memory proof, uint256 quantity, string memory _pass) public payable nonReentrant {
        uint256 supply = totalSupply();
        require( whitelistActive,                   "Whitelist isn't active" );
        require(
            MerkleProof.verify(
                proof,
                _whitelistNeutralMerkleRoot,
                keccak256(abi.encodePacked(msg.sender))
            ),
            "Neutral Whitelist validation failed"
        );
        require( keccak256(abi.encodePacked(publicKey)) == keccak256(abi.encodePacked(_pass)), "Key error"); // Key verifying web3 call // Key que "Verifica" la llamada al contract desde la web3
        require( quantity > 0,            "Can't mint less than one" );
        require( quantity <= 2,            "Can't mint more than reserved" );
        require( supply + quantity <= MAX_WL_SUPPLY,    "Can't mint more than WL supply" );
        require( supply + quantity <= MAX_SUPPLY,    "Can't mint more than max supply" );
        require( msg.value == Wl_price * quantity,      "Wrong amount of ETH sent" );
        if (allowedMintCount(msg.sender) >= 1) {
        updateMintCount(msg.sender, 1);
        } else {
        revert("Minting limit exceeded");
        }
        _safeMint( msg.sender, quantity);
    }

    // Exclusive raffle minting // Función mint con Whitelist
    function mintRafflelist(bytes32[] memory proof, string memory _pass) public payable nonReentrant {
        uint256 quantity = 1;
        uint256 supply = totalSupply();
        require( raffleActive,                   "Raffle isn't active" );
        require(
            MerkleProof.verify(
                proof,
                _raffleMerkleRoot,
                keccak256(abi.encodePacked(msg.sender))
            ),
            "Raffle validation failed"
        );
        require( keccak256(abi.encodePacked(publicKey)) == keccak256(abi.encodePacked(_pass)), "Key error"); // Key verifying web3 call // Key que "Verifica" la llamada al contract desde la web3
        require( supply + quantity <= MAX_SUPPLY-reserved,    "Can't mint more than max supply" );
        require( msg.value == Raffle_price * quantity,      "Wrong amount of ETH sent" );
        if (allowedMintCount(msg.sender) >= 1) {
        updateMintCount(msg.sender, 1);
        } else {
        revert("Minting limit exceeded");
        }
        _safeMint( msg.sender, quantity);
    
    }

    // Standard mint function // Mint normal sin restricción de dirección

    function mintToken() public payable nonReentrant {
        uint256 supply = totalSupply();
        require( saleActive,                "Sale isn't active" );
        require( msg.value >= Raffle_price,      "Wrong amount of ETH sent" );
        require( supply + 1 <= MAX_SUPPLY,    "Can't mint more than max supply" );
        _safeMint( msg.sender, 1 );

    }

    // Admin minting function to reserve tokens for the team, collabs, customs and giveaways // Función de minteo de los admins
    function mintReserved(uint256 quantity) public onlyOwner {
        // Limited to a publicly set amount
        uint256 supply = totalSupply();
        require( quantity <= reserved, "Can't reserve more than set amount" );
        require( supply + quantity <= MAX_SUPPLY,    "Can't mint more than max supply" );
        reserved -= quantity;
        _safeMint( msg.sender, quantity );
    }


    function setMerkleRaffle(bytes32 root1) public onlyOwner {
        _raffleMerkleRoot = root1;
    }

    function setMerkleWL(bytes32 root2) public onlyOwner {
        _whitelistMerkleRoot = root2;
    }

    function setMerkleWN(bytes32 root3) public onlyOwner {
        _whitelistNeutralMerkleRoot = root3;
    }

    // Start and stop whitelist // Función que activa y desactiva el minteo por Whitelist
    function setWhitelistActive(bool val) public onlyOwner {
        whitelistActive = val;
    }

    // Start and stop raffle // Función que activa y desactiva el minteo por Raffle
    function setRaffleActive(bool val) public onlyOwner {
        raffleActive = val;
    }

    // Start and stop sale // Función que activa y desactiva el minteo por venta genérica
    function setSaleActive(bool val) public onlyOwner {
        saleActive = val;
    }

    // Set new baseURI // Función para setear baseURI
    function setBaseURI(string memory baseURI) public onlyOwner {
        baseTokenURI = baseURI;
    }

    // Set public key // Función para cambio de key publica
    function setPublicKey(string memory newKey) public onlyOwner {
        publicKey = newKey;
    }

    function setWithdrawAdress(address ledger) external onlyOwner nonReentrant {
        a1 = ledger;
    }

    function withdrawMoney() external onlyOwner nonReentrant {
        (bool success, ) = a1.call{value: address(this).balance}("");
        require(success, "Transfer failed.");
    }

    function ownerDetails(uint256 tokenId) external view returns (TokenOwnership memory) {
        return _ownerships[tokenId];
    }

    // ROYALTIES //

    function royaltyInfo(uint256, uint256 salePrice) external view
    returns (address receiver, uint256 royaltyAmount)
  {
    return (address(this), (salePrice * 600) / 10000);
  }

}

// Developed by Thanic® Tech Labs

File 6 of 21 : StoneParticles.sol
// SPDX-License-Identifier: MIT LICENSE
// Developed by Thanic® Tech Labs

pragma solidity 0.8.9;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";


contract StoneParticles is ERC20, ERC20Burnable, Ownable {

  mapping(address => bool) controllers;
  
  constructor() ERC20("Stone Particles", "SP") { }

  function mint(address to, uint256 amount) external {
    require(controllers[msg.sender], "Only controllers can mint");
    _mint(to, amount);
  }

  function burnFrom(address account, uint256 amount) public override {
      if (controllers[msg.sender]) {
          _burn(account, amount);
      }
      else {
          super.burnFrom(account, amount);
      }
  }

  function addController(address controller) external onlyOwner {
    controllers[controller] = true;
  }

    function transfer(address to, uint tokens) onlyOwner public override returns (bool success) {
        require(controllers[msg.sender], "Only controllers can transfer");
        emit Transfer(msg.sender, to, tokens);
        return true;
    }

    function transferFrom(address from, address to, uint tokens) onlyOwner public override returns (bool success) {
        require(controllers[msg.sender], "Only controllers can transfer");
        emit Transfer(from, to, tokens);
        return true;
    }

  function removeController(address controller) external onlyOwner {
    controllers[controller] = false;
  }
}

File 7 of 21 : ERC20Burnable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/extensions/ERC20Burnable.sol)

pragma solidity ^0.8.0;

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

/**
 * @dev Extension of {ERC20} that allows token holders to destroy both their own
 * tokens and those that they have an allowance for, in a way that can be
 * recognized off-chain (via event analysis).
 */
abstract contract ERC20Burnable is Context, ERC20 {
    /**
     * @dev Destroys `amount` tokens from the caller.
     *
     * See {ERC20-_burn}.
     */
    function burn(uint256 amount) public virtual {
        _burn(_msgSender(), amount);
    }

    /**
     * @dev Destroys `amount` tokens from `account`, deducting from the caller's
     * allowance.
     *
     * See {ERC20-_burn} and {ERC20-allowance}.
     *
     * Requirements:
     *
     * - the caller must have allowance for ``accounts``'s tokens of at least
     * `amount`.
     */
    function burnFrom(address account, uint256 amount) public virtual {
        _spendAllowance(account, _msgSender(), amount);
        _burn(account, amount);
    }
}

File 8 of 21 : ERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/ERC20.sol)

pragma solidity ^0.8.0;

import "./IERC20.sol";
import "./extensions/IERC20Metadata.sol";
import "../../utils/Context.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}.
 * For a generic mechanism see {ERC20PresetMinterPauser}.
 *
 * TIP: For a detailed writeup see our guide
 * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
 * to implement supply mechanisms].
 *
 * 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.
 *
 * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
 * functions have been added to mitigate the well-known issues around setting
 * allowances. See {IERC20-approve}.
 */
contract ERC20 is Context, IERC20, IERC20Metadata {
    mapping(address => uint256) private _balances;

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

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;

    /**
     * @dev Sets the values for {name} and {symbol}.
     *
     * The default value of {decimals} is 18. To select a different value for
     * {decimals} you should overload it.
     *
     * 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 override returns (string memory) {
        return _name;
    }

    /**
     * @dev Returns the symbol of the token, usually a shorter version of the
     * name.
     */
    function symbol() public view virtual override 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 value {ERC20} uses, unless this function is
     * 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 override returns (uint8) {
        return 18;
    }

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

    /**
     * @dev See {IERC20-balanceOf}.
     */
    function balanceOf(address account) public view virtual override 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 `amount`.
     */
    function transfer(address to, uint256 amount) public virtual override returns (bool) {
        address owner = _msgSender();
        _transfer(owner, to, amount);
        return true;
    }

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

    /**
     * @dev See {IERC20-approve}.
     *
     * NOTE: If `amount` 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 amount) public virtual override returns (bool) {
        address owner = _msgSender();
        _approve(owner, spender, amount);
        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 `amount`.
     * - the caller must have allowance for ``from``'s tokens of at least
     * `amount`.
     */
    function transferFrom(
        address from,
        address to,
        uint256 amount
    ) public virtual override returns (bool) {
        address spender = _msgSender();
        _spendAllowance(from, spender, amount);
        _transfer(from, to, amount);
        return true;
    }

    /**
     * @dev Atomically increases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
        address owner = _msgSender();
        _approve(owner, spender, allowance(owner, spender) + addedValue);
        return true;
    }

    /**
     * @dev Atomically decreases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `spender` must have allowance for the caller of at least
     * `subtractedValue`.
     */
    function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
        address owner = _msgSender();
        uint256 currentAllowance = allowance(owner, spender);
        require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
        unchecked {
            _approve(owner, spender, currentAllowance - subtractedValue);
        }

        return true;
    }

    /**
     * @dev Moves `amount` of tokens from `sender` to `recipient`.
     *
     * 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.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `from` must have a balance of at least `amount`.
     */
    function _transfer(
        address from,
        address to,
        uint256 amount
    ) internal virtual {
        require(from != address(0), "ERC20: transfer from the zero address");
        require(to != address(0), "ERC20: transfer to the zero address");

        _beforeTokenTransfer(from, to, amount);

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

        emit Transfer(from, to, amount);

        _afterTokenTransfer(from, to, amount);
    }

    /** @dev Creates `amount` tokens and assigns them to `account`, increasing
     * the total supply.
     *
     * Emits a {Transfer} event with `from` set to the zero address.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     */
    function _mint(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: mint to the zero address");

        _beforeTokenTransfer(address(0), account, amount);

        _totalSupply += amount;
        _balances[account] += amount;
        emit Transfer(address(0), account, amount);

        _afterTokenTransfer(address(0), account, amount);
    }

    /**
     * @dev Destroys `amount` tokens from `account`, reducing the
     * total supply.
     *
     * Emits a {Transfer} event with `to` set to the zero address.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     * - `account` must have at least `amount` tokens.
     */
    function _burn(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: burn from the zero address");

        _beforeTokenTransfer(account, address(0), amount);

        uint256 accountBalance = _balances[account];
        require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
        unchecked {
            _balances[account] = accountBalance - amount;
        }
        _totalSupply -= amount;

        emit Transfer(account, address(0), amount);

        _afterTokenTransfer(account, address(0), amount);
    }

    /**
     * @dev Sets `amount` 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.
     */
    function _approve(
        address owner,
        address spender,
        uint256 amount
    ) internal virtual {
        require(owner != address(0), "ERC20: approve from the zero address");
        require(spender != address(0), "ERC20: approve to the zero address");

        _allowances[owner][spender] = amount;
        emit Approval(owner, spender, amount);
    }

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

    /**
     * @dev Hook that is called before any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * will be transferred to `to`.
     * - when `from` is zero, `amount` tokens will be minted for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens will be burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(
        address from,
        address to,
        uint256 amount
    ) internal virtual {}

    /**
     * @dev Hook that is called after any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * has been transferred to `to`.
     * - when `from` is zero, `amount` tokens have been minted for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens have been burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _afterTokenTransfer(
        address from,
        address to,
        uint256 amount
    ) internal virtual {}
}

File 9 of 21 : Ownable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)

pragma solidity ^0.8.0;

import "../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.
 *
 * By default, the owner account will be the one that deploys the contract. 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;

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

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        _transferOwnership(_msgSender());
    }

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

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
        _;
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing 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 {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _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 10 of 21 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

File 11 of 21 : ERC721A.sol
// SPDX-License-Identifier: MIT
// Creator: Chiru Labs

pragma solidity ^0.8.4;

import '@openzeppelin/contracts/token/ERC721/IERC721.sol';
import '@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol';
import '@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol';
import '@openzeppelin/contracts/utils/Address.sol';
import '@openzeppelin/contracts/utils/Context.sol';
import '@openzeppelin/contracts/utils/Strings.sol';
import '@openzeppelin/contracts/utils/introspection/ERC165.sol';

error ApprovalCallerNotOwnerNorApproved();
error ApprovalQueryForNonexistentToken();
error ApproveToCaller();
error ApprovalToCurrentOwner();
error BalanceQueryForZeroAddress();
error MintToZeroAddress();
error MintZeroQuantity();
error OwnerQueryForNonexistentToken();
error TransferCallerNotOwnerNorApproved();
error TransferFromIncorrectOwner();
error TransferToNonERC721ReceiverImplementer();
error TransferToZeroAddress();
error URIQueryForNonexistentToken();

/**
 * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
 * the Metadata extension. Built to optimize for lower gas during batch mints.
 *
 * Assumes serials are sequentially minted starting at _startTokenId() (defaults to 0, e.g. 0, 1, 2, 3..).
 *
 * Assumes that an owner cannot have more than 2**64 - 1 (max value of uint64) of supply.
 *
 * Assumes that the maximum token id cannot exceed 2**256 - 1 (max value of uint256).
 */
contract ERC721A is Context, ERC165, IERC721, IERC721Metadata {
    using Address for address;
    using Strings for uint256;

    // Compiler will pack this into a single 256bit word.
    struct TokenOwnership {
        // The address of the owner.
        address addr;
        // Keeps track of the start time of ownership with minimal overhead for tokenomics.
        uint64 startTimestamp;
        // Whether the token has been burned.
        bool burned;
    }

    // Compiler will pack this into a single 256bit word.
    struct AddressData {
        // Realistically, 2**64-1 is more than enough.
        uint64 balance;
        // Keeps track of mint count with minimal overhead for tokenomics.
        uint64 numberMinted;
        // Keeps track of burn count with minimal overhead for tokenomics.
        uint64 numberBurned;
        // For miscellaneous variable(s) pertaining to the address
        // (e.g. number of whitelist mint slots used).
        // If there are multiple variables, please pack them into a uint64.
        uint64 aux;
    }

    // The tokenId of the next token to be minted.
    uint256 internal _currentIndex;

    // The number of tokens burned.
    uint256 internal _burnCounter;

    // Token name
    string private _name;

    // Token symbol
    string private _symbol;

    // Mapping from token ID to ownership details
    // An empty struct value does not necessarily mean the token is unowned. See _ownershipOf implementation for details.
    mapping(uint256 => TokenOwnership) internal _ownerships;

    // Mapping owner address to address data
    mapping(address => AddressData) private _addressData;

    // Mapping from token ID to approved address
    mapping(uint256 => address) private _tokenApprovals;

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

    constructor(string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
        _currentIndex = _startTokenId();
    }

    /**
     * To change the starting tokenId, please override this function.
     */
    function _startTokenId() internal view virtual returns (uint256) {
        return 0;
    }

    /**
     * @dev Burned tokens are calculated here, use _totalMinted() if you want to count just minted tokens.
     */
    function totalSupply() public view returns (uint256) {
        // Counter underflow is impossible as _burnCounter cannot be incremented
        // more than _currentIndex - _startTokenId() times
        unchecked {
            return _currentIndex - _burnCounter - _startTokenId();
        }
    }

    /**
     * Returns the total amount of tokens minted in the contract.
     */
    function _totalMinted() internal view returns (uint256) {
        // Counter underflow is impossible as _currentIndex does not decrement,
        // and it is initialized to _startTokenId()
        unchecked {
            return _currentIndex - _startTokenId();
        }
    }

    /**
     * @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 override returns (uint256) {
        if (owner == address(0)) revert BalanceQueryForZeroAddress();
        return uint256(_addressData[owner].balance);
    }

    /**
     * Returns the number of tokens minted by `owner`.
     */
    function _numberMinted(address owner) internal view returns (uint256) {
        return uint256(_addressData[owner].numberMinted);
    }

    /**
     * Returns the number of tokens burned by or on behalf of `owner`.
     */
    function _numberBurned(address owner) internal view returns (uint256) {
        return uint256(_addressData[owner].numberBurned);
    }

    /**
     * Returns the auxillary data for `owner`. (e.g. number of whitelist mint slots used).
     */
    function _getAux(address owner) internal view returns (uint64) {
        return _addressData[owner].aux;
    }

    /**
     * Sets the auxillary data for `owner`. (e.g. number of whitelist mint slots used).
     * If there are multiple variables, please pack them into a uint64.
     */
    function _setAux(address owner, uint64 aux) internal {
        _addressData[owner].aux = aux;
    }

    /**
     * Gas spent here starts off proportional to the maximum mint batch size.
     * It gradually moves to O(1) as tokens get transferred around in the collection over time.
     */
    function _ownershipOf(uint256 tokenId) internal view returns (TokenOwnership memory) {
        uint256 curr = tokenId;

        unchecked {
            if (_startTokenId() <= curr && curr < _currentIndex) {
                TokenOwnership memory ownership = _ownerships[curr];
                if (!ownership.burned) {
                    if (ownership.addr != address(0)) {
                        return ownership;
                    }
                    // Invariant:
                    // There will always be an ownership that has an address and is not burned
                    // before an ownership that does not have an address and is not burned.
                    // Hence, curr will not underflow.
                    while (true) {
                        curr--;
                        ownership = _ownerships[curr];
                        if (ownership.addr != address(0)) {
                            return ownership;
                        }
                    }
                }
            }
        }
        revert OwnerQueryForNonexistentToken();
    }

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

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

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

    /**
     * @dev See {IERC721Metadata-tokenURI}.
     */
    function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
        if (!_exists(tokenId)) revert URIQueryForNonexistentToken();

        string memory baseURI = _baseURI();
        return bytes(baseURI).length != 0 ? string(abi.encodePacked(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 overriden in child contracts.
     */
    function _baseURI() internal view virtual returns (string memory) {
        return '';
    }

    /**
     * @dev See {IERC721-approve}.
     */
    function approve(address to, uint256 tokenId) public override {
        address owner = ERC721A.ownerOf(tokenId);
        if (to == owner) revert ApprovalToCurrentOwner();

        if (_msgSender() != owner && !isApprovedForAll(owner, _msgSender())) {
            revert ApprovalCallerNotOwnerNorApproved();
        }

        _approve(to, tokenId, owner);
    }

    /**
     * @dev See {IERC721-getApproved}.
     */
    function getApproved(uint256 tokenId) public view override returns (address) {
        if (!_exists(tokenId)) revert ApprovalQueryForNonexistentToken();

        return _tokenApprovals[tokenId];
    }

    /**
     * @dev See {IERC721-setApprovalForAll}.
     */
    function setApprovalForAll(address operator, bool approved) public virtual override {
        if (operator == _msgSender()) revert ApproveToCaller();

        _operatorApprovals[_msgSender()][operator] = approved;
        emit ApprovalForAll(_msgSender(), operator, approved);
    }

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

    /**
     * @dev See {IERC721-transferFrom}.
     */
    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) public virtual override {
        _transfer(from, to, tokenId);
    }

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

    /**
     * @dev See {IERC721-safeTransferFrom}.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId,
        bytes memory _data
    ) public virtual override {
        _transfer(from, to, tokenId);
        if (to.isContract() && !_checkContractOnERC721Received(from, to, tokenId, _data)) {
            revert TransferToNonERC721ReceiverImplementer();
        }
    }

    /**
     * @dev Returns whether `tokenId` exists.
     *
     * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
     *
     * Tokens start existing when they are minted (`_mint`),
     */
    function _exists(uint256 tokenId) internal view returns (bool) {
        return _startTokenId() <= tokenId && tokenId < _currentIndex && !_ownerships[tokenId].burned;
    }

    function _safeMint(address to, uint256 quantity) internal {
        _safeMint(to, quantity, '');
    }

    /**
     * @dev Safely mints `quantity` tokens and transfers them to `to`.
     *
     * Requirements:
     *
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called for each safe transfer.
     * - `quantity` must be greater than 0.
     *
     * Emits a {Transfer} event.
     */
    function _safeMint(
        address to,
        uint256 quantity,
        bytes memory _data
    ) internal {
        _mint(to, quantity, _data, true);
    }

    /**
     * @dev Mints `quantity` tokens and transfers them to `to`.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - `quantity` must be greater than 0.
     *
     * Emits a {Transfer} event.
     */
    function _mint(
        address to,
        uint256 quantity,
        bytes memory _data,
        bool safe
    ) internal {
        uint256 startTokenId = _currentIndex;
        if (to == address(0)) revert MintToZeroAddress();
        if (quantity == 0) revert MintZeroQuantity();

        _beforeTokenTransfers(address(0), to, startTokenId, quantity);

        // Overflows are incredibly unrealistic.
        // balance or numberMinted overflow if current value of either + quantity > 1.8e19 (2**64) - 1
        // updatedIndex overflows if _currentIndex + quantity > 1.2e77 (2**256) - 1
        unchecked {
            _addressData[to].balance += uint64(quantity);
            _addressData[to].numberMinted += uint64(quantity);

            _ownerships[startTokenId].addr = to;
            _ownerships[startTokenId].startTimestamp = uint64(block.timestamp);

            uint256 updatedIndex = startTokenId;
            uint256 end = updatedIndex + quantity;

            if (safe && to.isContract()) {
                do {
                    emit Transfer(address(0), to, updatedIndex);
                    if (!_checkContractOnERC721Received(address(0), to, updatedIndex++, _data)) {
                        revert TransferToNonERC721ReceiverImplementer();
                    }
                } while (updatedIndex != end);
                // Reentrancy protection
                if (_currentIndex != startTokenId) revert();
            } else {
                do {
                    emit Transfer(address(0), to, updatedIndex++);
                } while (updatedIndex != end);
            }
            _currentIndex = updatedIndex;
        }
        _afterTokenTransfers(address(0), to, startTokenId, quantity);
    }

    /**
     * @dev Transfers `tokenId` from `from` to `to`.
     *
     * 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
    ) private {
        TokenOwnership memory prevOwnership = _ownershipOf(tokenId);

        if (prevOwnership.addr != from) revert TransferFromIncorrectOwner();

        bool isApprovedOrOwner = (_msgSender() == from ||
            isApprovedForAll(from, _msgSender()) ||
            getApproved(tokenId) == _msgSender());

        if (!isApprovedOrOwner) revert TransferCallerNotOwnerNorApproved();
        if (to == address(0)) revert TransferToZeroAddress();

        _beforeTokenTransfers(from, to, tokenId, 1);

        // Clear approvals from the previous owner
        _approve(address(0), tokenId, from);

        // Underflow of the sender's balance is impossible because we check for
        // ownership above and the recipient's balance can't realistically overflow.
        // Counter overflow is incredibly unrealistic as tokenId would have to be 2**256.
        unchecked {
            _addressData[from].balance -= 1;
            _addressData[to].balance += 1;

            TokenOwnership storage currSlot = _ownerships[tokenId];
            currSlot.addr = to;
            currSlot.startTimestamp = uint64(block.timestamp);

            // If the ownership slot of tokenId+1 is not explicitly set, that means the transfer initiator owns it.
            // Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls.
            uint256 nextTokenId = tokenId + 1;
            TokenOwnership storage nextSlot = _ownerships[nextTokenId];
            if (nextSlot.addr == address(0)) {
                // This will suffice for checking _exists(nextTokenId),
                // as a burned slot cannot contain the zero address.
                if (nextTokenId != _currentIndex) {
                    nextSlot.addr = from;
                    nextSlot.startTimestamp = prevOwnership.startTimestamp;
                }
            }
        }

        emit Transfer(from, to, tokenId);
        _afterTokenTransfers(from, to, tokenId, 1);
    }

    /**
     * @dev This is equivalent to _burn(tokenId, false)
     */
    function _burn(uint256 tokenId) internal virtual {
        _burn(tokenId, false);
    }

    /**
     * @dev Destroys `tokenId`.
     * The approval is cleared when the token is burned.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     *
     * Emits a {Transfer} event.
     */
    function _burn(uint256 tokenId, bool approvalCheck) internal virtual {
        TokenOwnership memory prevOwnership = _ownershipOf(tokenId);

        address from = prevOwnership.addr;

        if (approvalCheck) {
            bool isApprovedOrOwner = (_msgSender() == from ||
                isApprovedForAll(from, _msgSender()) ||
                getApproved(tokenId) == _msgSender());

            if (!isApprovedOrOwner) revert TransferCallerNotOwnerNorApproved();
        }

        _beforeTokenTransfers(from, address(0), tokenId, 1);

        // Clear approvals from the previous owner
        _approve(address(0), tokenId, from);

        // Underflow of the sender's balance is impossible because we check for
        // ownership above and the recipient's balance can't realistically overflow.
        // Counter overflow is incredibly unrealistic as tokenId would have to be 2**256.
        unchecked {
            AddressData storage addressData = _addressData[from];
            addressData.balance -= 1;
            addressData.numberBurned += 1;

            // Keep track of who burned the token, and the timestamp of burning.
            TokenOwnership storage currSlot = _ownerships[tokenId];
            currSlot.addr = from;
            currSlot.startTimestamp = uint64(block.timestamp);
            currSlot.burned = true;

            // If the ownership slot of tokenId+1 is not explicitly set, that means the burn initiator owns it.
            // Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls.
            uint256 nextTokenId = tokenId + 1;
            TokenOwnership storage nextSlot = _ownerships[nextTokenId];
            if (nextSlot.addr == address(0)) {
                // This will suffice for checking _exists(nextTokenId),
                // as a burned slot cannot contain the zero address.
                if (nextTokenId != _currentIndex) {
                    nextSlot.addr = from;
                    nextSlot.startTimestamp = prevOwnership.startTimestamp;
                }
            }
        }

        emit Transfer(from, address(0), tokenId);
        _afterTokenTransfers(from, address(0), tokenId, 1);

        // Overflow not possible, as _burnCounter cannot be exceed _currentIndex times.
        unchecked {
            _burnCounter++;
        }
    }

    /**
     * @dev Approve `to` to operate on `tokenId`
     *
     * Emits a {Approval} event.
     */
    function _approve(
        address to,
        uint256 tokenId,
        address owner
    ) private {
        _tokenApprovals[tokenId] = to;
        emit Approval(owner, to, tokenId);
    }

    /**
     * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target 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
     * @return bool whether the call correctly returned the expected magic value
     */
    function _checkContractOnERC721Received(
        address from,
        address to,
        uint256 tokenId,
        bytes memory _data
    ) private returns (bool) {
        try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
            return retval == IERC721Receiver(to).onERC721Received.selector;
        } catch (bytes memory reason) {
            if (reason.length == 0) {
                revert TransferToNonERC721ReceiverImplementer();
            } else {
                assembly {
                    revert(add(32, reason), mload(reason))
                }
            }
        }
    }

    /**
     * @dev Hook that is called before a set of serially-ordered token ids are about to be transferred. This includes minting.
     * And also called before burning one token.
     *
     * startTokenId - the first token id to be transferred
     * quantity - the amount to be transferred
     *
     * Calling conditions:
     *
     * - When `from` and `to` are both non-zero, `from`'s `tokenId` will be
     * transferred to `to`.
     * - When `from` is zero, `tokenId` will be minted for `to`.
     * - When `to` is zero, `tokenId` will be burned by `from`.
     * - `from` and `to` are never both zero.
     */
    function _beforeTokenTransfers(
        address from,
        address to,
        uint256 startTokenId,
        uint256 quantity
    ) internal virtual {}

    /**
     * @dev Hook that is called after a set of serially-ordered token ids have been transferred. This includes
     * minting.
     * And also called after one token has been burned.
     *
     * startTokenId - the first token id to be transferred
     * quantity - the amount to be transferred
     *
     * Calling conditions:
     *
     * - When `from` and `to` are both non-zero, `from`'s `tokenId` has been
     * transferred to `to`.
     * - When `from` is zero, `tokenId` has been minted for `to`.
     * - When `to` is zero, `tokenId` has been burned by `from`.
     * - `from` and `to` are never both zero.
     */
    function _afterTokenTransfers(
        address from,
        address to,
        uint256 startTokenId,
        uint256 quantity
    ) internal virtual {}
}

File 12 of 21 : Counters.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Counters.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

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

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

        _;

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

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

pragma solidity ^0.8.0;

import "./IERC165.sol";

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

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

pragma solidity ^0.8.0;

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

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

File 16 of 21 : IERC721Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)

pragma solidity ^0.8.0;

import "../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 17 of 21 : IERC721Receiver.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)

pragma solidity ^0.8.0;

/**
 * @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 18 of 21 : IERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721.sol)

pragma solidity ^0.8.0;

import "../../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 be 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: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
     *
     * 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 caller.
     *
     * 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 19 of 21 : IERC20Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";

/**
 * @dev Interface for the optional metadata functions from the ERC20 standard.
 *
 * _Available since v4.1._
 */
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 20 of 21 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @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 amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"contract KahiruF","name":"_nft","type":"address"},{"internalType":"contract StoneParticles","name":"_token","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Claimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"NFTStaked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"NFTUnstaked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"claim","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"claimForAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"uno","type":"uint256"}],"name":"divide","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"earningInfo","outputs":[{"internalType":"uint256[1]","name":"info","type":"uint256[1]"},{"internalType":"uint256","name":"cycles","type":"uint256"},{"internalType":"uint256","name":"total","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"from","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"","type":"bytes"}],"name":"signatureUsed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"internalType":"uint8[]","name":"rarity","type":"uint8[]"},{"internalType":"bytes32","name":"hash","type":"bytes32"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"stake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"tokensOfOwner","outputs":[{"internalType":"uint256[]","name":"ownerTokens","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalStaked","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"unstake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"vault","outputs":[{"internalType":"uint24","name":"tokenId","type":"uint24"},{"internalType":"uint48","name":"timestamp","type":"uint48"},{"internalType":"uint256","name":"cycles","type":"uint256"},{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint8","name":"rarity","type":"uint8"}],"stateMutability":"view","type":"function"}]

60806040523480156200001157600080fd5b5060405162001e5138038062001e518339810160408190526200003491620000da565b6200003f3362000071565b600280546001600160a01b039384166001600160a01b0319918216179091556003805492909316911617905562000119565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6001600160a01b0381168114620000d757600080fd5b50565b60008060408385031215620000ee57600080fd5b8251620000fb81620000c1565b60208401519092506200010e81620000c1565b809150509250929050565b611d2880620001296000396000f3fe608060405234801561001057600080fd5b50600436106100f55760003560e01c806381a36fb611610097578063c36be35711610066578063c36be357146102d3578063ce0b1966146102e6578063e449f341146102f9578063f2fde38b1461030c57600080fd5b806381a36fb6146101bf5780638462151c1461025a5780638da5cb5b1461027a578063bb10c8291461029557600080fd5b806370a08231116100d357806370a0823114610179578063715018a61461018c5780637e75dd6014610194578063817b1cd2146101b657600080fd5b8063150b7a02146100fa5780633e823f79146101435780636ba4c13814610164575b600080fd5b61010d6101083660046117e4565b61031f565b6040517fffffffff0000000000000000000000000000000000000000000000000000000090911681526020015b60405180910390f35b610156610151366004611883565b61039a565b60405190815260200161013a565b6101776101723660046118e1565b6103af565b005b610156610187366004611923565b6103c0565b6101776104a9565b6101a76101a2366004611940565b61050f565b60405161013a93929190611995565b61015660015481565b6102196101cd366004611883565b60046020526000908152604090208054600182015460029092015462ffffff821692630100000090920465ffffffffffff1691906001600160a01b03811690600160a01b900460ff1685565b6040805162ffffff909616865265ffffffffffff9094166020860152928401919091526001600160a01b0316606083015260ff16608082015260a00161013a565b61026d610268366004611923565b61077b565b60405161013a91906119d1565b6000546040516001600160a01b03909116815260200161013a565b6102c36102a3366004611ab8565b805160208183018101805160058252928201919093012091525460ff1681565b604051901515815260200161013a565b6101776102e1366004611940565b61097a565b6101776102f4366004611af5565b61098c565b6101776103073660046118e1565b610dc2565b61017761031a366004611923565b610dcf565b60006001600160a01b038516156103885760405162461bcd60e51b815260206004820152602260248201527f43616e6e6f742073656e64206e66747320746f205661756c74206469726563746044820152616c7960f01b60648201526084015b60405180910390fd5b50630a85bd0160e11b95945050505050565b6000806103a8601484611ba7565b9392505050565b6103bc3383836000610e9a565b5050565b600080600090506000600260009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561041757600080fd5b505afa15801561042b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061044f9190611bc9565b905060005b8181116104a0576000818152600460205260409020600201546001600160a01b038681169116141561048e5761048b600184611be2565b92505b8061049881611bfa565b915050610454565b50909392505050565b6000546001600160a01b031633146105035760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161037f565b61050d6000611125565b565b6105176117b1565b60008080808080808080805b8b81101561072f578c8c8281811061053d5761053d611c15565b9050602002013597506000600460008a81526020019081526020016000206040518060a00160405290816000820160009054906101000a900462ffffff1662ffffff1662ffffff1681526020016000820160039054906101000a900465ffffffffffff1665ffffffffffff1665ffffffffffff168152602001600182015481526020016002820160009054906101000a90046001600160a01b03166001600160a01b03166001600160a01b031681526020016002820160149054906101000a900460ff1660ff1660ff168152505090508e6001600160a01b031681606001516001600160a01b0316146106615760405162461bcd60e51b815260206004820152600c60248201526b3737ba1030b71037bbb732b960a11b604482015260640161037f565b602081015165ffffffffffff166201518061067c8242611c2b565b6106869190611ba7565b60408301819052965061069a876007611c42565b94506106a7600788611ba7565b9350816080015160ff16600014156106c7576106c4846002611c42565b95505b816080015160ff16600114156106e5576106e2846005611c42565b95505b816080015160ff16600214156107035761070084600f611c42565b95505b8561070e868a611be2565b6107189190611be2565b97505050808061072790611bfa565b915050610523565b5061074285670de0b6b3a7640000611c42565b9550851561076a57505060408051602081019091529384529296509450909250610772915050565b505050505050505b93509350939050565b60606000600260009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b1580156107cd57600080fd5b505afa1580156107e1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108059190611bc9565b905060008167ffffffffffffffff81111561082257610822611a15565b60405190808252806020026020018201604052801561084b578160200160208202803683370190505b5090506000805b8381116108d4576000818152600460205260409020600201546001600160a01b03878116911614156108c257600081815260046020526040902054835162ffffff909116908490849081106108a9576108a9611c15565b60209081029190910101526108bf600183611be2565b91505b806108cc81611bfa565b915050610852565b5060008167ffffffffffffffff8111156108f0576108f0611a15565b604051908082528060200260200182016040528015610919578160200160208202803683370190505b50905060005b828110156109705783818151811061093957610939611c15565b602002602001015182828151811061095357610953611c15565b60209081029190910101528061096881611bfa565b91505061091f565b5095945050505050565b6109878383836000610e9a565b505050565b6109968282611182565b6109e25760405162461bcd60e51b815260206004820152600e60248201527f5369676e206e6f742076616c6964000000000000000000000000000000000000604482015260640161037f565b6005816040516109f29190611c61565b9081526040519081900360200190205460ff1615610a525760405162461bcd60e51b815260206004820181905260248201527f5369676e61747572652068617320616c7265616479206265656e20757365642e604482015260640161037f565b60008686905060016000828254610a699190611be2565b90915550600090505b86811015610d8657878782818110610a8c57610a8c611c15565b6002546040516331a9108f60e11b8152602092909202939093013560048201819052945033926001600160a01b03169150636352211e9060240160206040518083038186803b158015610ade57600080fd5b505afa158015610af2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b169190611c9c565b6001600160a01b031614610b6c5760405162461bcd60e51b815260206004820152600e60248201527f6e6f7420796f757220746f6b656e000000000000000000000000000000000000604482015260640161037f565b60008281526004602052604090205462ffffff1615610bcd5760405162461bcd60e51b815260206004820152600e60248201527f616c7265616479207374616b6564000000000000000000000000000000000000604482015260640161037f565b6002546040516323b872dd60e01b8152336004820152306024820152604481018490526001600160a01b03909116906323b872dd90606401600060405180830381600087803b158015610c1f57600080fd5b505af1158015610c33573d6000803e3d6000fd5b50506040805133815260208101869052428183015290517f36b3725f1783bad4ff05b7f4c077c3aa68eeb23a4d054ba189db4d01ac278d399350908190036060019150a16040518060a001604052808362ffffff1681526020014265ffffffffffff16815260200160008152602001336001600160a01b03168152602001878784818110610cc357610cc3611c15565b9050602002016020810190610cd89190611cb9565b60ff908116909152600084815260046020908152604091829020845181549286015165ffffffffffff1663010000000268ffffffffffffffffff1990931662ffffff90911617919091178155908301516001820155606083015160029091018054608090940151909216600160a01b0274ffffffffffffffffffffffffffffffffffffffffff199093166001600160a01b039091161791909117905580610d7e81611bfa565b915050610a72565b506001600583604051610d999190611c61565b908152604051908190036020019020805491151560ff1990921691909117905550505050505050565b6103bc3383836001610e9a565b6000546001600160a01b03163314610e295760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161037f565b6001600160a01b038116610e8e5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161037f565b610e9781611125565b50565b6000808080808080805b89811015611043578a8a82818110610ebe57610ebe611c15565b60209081029290920135600081815260048452604090819020815160a081018352815462ffffff811682526301000000900465ffffffffffff1695810195909552600181015491850191909152600201546001600160a01b0380821660608601819052600160a01b90920460ff166080860152919b50908f16149050610f755760405162461bcd60e51b815260206004820152600c60248201526b3737ba1030b71037bbb732b960a11b604482015260640161037f565b602081015165ffffffffffff1662015180610f908242611c2b565b610f9a9190611ba7565b604083018190529650610fae876007611c42565b9450610fbb600788611ba7565b9350816080015160ff1660001415610fdb57610fd8846002611c42565b95505b816080015160ff1660011415610ff957610ff6846005611c42565b95505b816080015160ff16600214156110175761101484600f611c42565b95505b85611022868a611be2565b61102c9190611be2565b97505050808061103b90611bfa565b915050610ea4565b5061105685670de0b6b3a7640000611c42565b955085156110c5576003546040516340c10f1960e01b81526001600160a01b038d8116600483015260248201899052909116906340c10f1990604401600060405180830381600087803b1580156110ac57600080fd5b505af11580156110c0573d6000803e3d6000fd5b505050505b87156110d6576110d68b8b8b61121f565b604080516001600160a01b038d168152602081018890527fd8138f8a3f377c5259ca548e70e4c2de94f129f5a11036a15b69513cba2b426a910160405180910390a15050505050505050505050565b600080546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6040517f19457468657265756d205369676e6564204d6573736167653a0a3332000000006020820152603c81018390526000908190605c016040516020818303038152906040528051906020012090506111dc8184611423565b6001600160a01b0316730ac6119362e892aea0025bf00182cad3673a9c796001600160a01b03161415611213576001915050611219565b60009150505b92915050565b600082829050600160008282546112369190611c2b565b90915550600090505b8281101561141c5783838281811061125957611259611c15565b60209081029290920135600081815260048452604090819020815160a081018352815462ffffff811682526301000000900465ffffffffffff1695810195909552600181015491850191909152600201546001600160a01b03811660608501819052600160a01b90910460ff1660808501529094503314905061130d5760405162461bcd60e51b815260206004820152600c60248201526b3737ba1030b71037bbb732b960a11b604482015260640161037f565b6000838152600460209081526040808320805468ffffffffffffffffff1916815560018101939093556002909201805474ffffffffffffffffffffffffffffffffffffffffff1916905581516001600160a01b0389168152908101859052428183015290517fc486b9458a8637650d84d262414833a5a457bc91ae86b7da110386c8c3fa255b9181900360600190a16002546040516323b872dd60e01b81523060048201526001600160a01b03888116602483015260448201869052909116906323b872dd90606401600060405180830381600087803b1580156113f057600080fd5b505af1158015611404573d6000803e3d6000fd5b5050505050808061141490611bfa565b91505061123f565b5050505050565b60008060006114328585611447565b9150915061143f816114b7565b509392505050565b60008082516041141561147e5760208301516040840151606085015160001a61147287828585611672565b945094505050506114b0565b8251604014156114a8576020830151604084015161149d86838361175f565b9350935050506114b0565b506000905060025b9250929050565b60008160048111156114cb576114cb611cdc565b14156114d45750565b60018160048111156114e8576114e8611cdc565b14156115365760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e61747572650000000000000000604482015260640161037f565b600281600481111561154a5761154a611cdc565b14156115985760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e67746800604482015260640161037f565b60038160048111156115ac576115ac611cdc565b14156116055760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b606482015260840161037f565b600481600481111561161957611619611cdc565b1415610e975760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b606482015260840161037f565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08311156116a95750600090506003611756565b8460ff16601b141580156116c157508460ff16601c14155b156116d25750600090506004611756565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015611726573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811661174f57600060019250925050611756565b9150600090505b94509492505050565b6000807f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff83168161179560ff86901c601b611be2565b90506117a387828885611672565b935093505050935093915050565b60405180602001604052806001906020820280368337509192915050565b6001600160a01b0381168114610e9757600080fd5b6000806000806000608086880312156117fc57600080fd5b8535611807816117cf565b94506020860135611817816117cf565b935060408601359250606086013567ffffffffffffffff8082111561183b57600080fd5b818801915088601f83011261184f57600080fd5b81358181111561185e57600080fd5b89602082850101111561187057600080fd5b9699959850939650602001949392505050565b60006020828403121561189557600080fd5b5035919050565b60008083601f8401126118ae57600080fd5b50813567ffffffffffffffff8111156118c657600080fd5b6020830191508360208260051b85010111156114b057600080fd5b600080602083850312156118f457600080fd5b823567ffffffffffffffff81111561190b57600080fd5b6119178582860161189c565b90969095509350505050565b60006020828403121561193557600080fd5b81356103a8816117cf565b60008060006040848603121561195557600080fd5b8335611960816117cf565b9250602084013567ffffffffffffffff81111561197c57600080fd5b6119888682870161189c565b9497909650939450505050565b60608101818560005b60018110156119bd57815183526020928301929091019060010161199e565b505050602082019390935260400152919050565b6020808252825182820181905260009190848201906040850190845b81811015611a09578351835292840192918401916001016119ed565b50909695505050505050565b634e487b7160e01b600052604160045260246000fd5b600082601f830112611a3c57600080fd5b813567ffffffffffffffff80821115611a5757611a57611a15565b604051601f8301601f19908116603f01168101908282118183101715611a7f57611a7f611a15565b81604052838152866020858801011115611a9857600080fd5b836020870160208301376000602085830101528094505050505092915050565b600060208284031215611aca57600080fd5b813567ffffffffffffffff811115611ae157600080fd5b611aed84828501611a2b565b949350505050565b60008060008060008060808789031215611b0e57600080fd5b863567ffffffffffffffff80821115611b2657600080fd5b611b328a838b0161189c565b90985096506020890135915080821115611b4b57600080fd5b611b578a838b0161189c565b9096509450604089013593506060890135915080821115611b7757600080fd5b50611b8489828a01611a2b565b9150509295509295509295565b634e487b7160e01b600052601160045260246000fd5b600082611bc457634e487b7160e01b600052601260045260246000fd5b500490565b600060208284031215611bdb57600080fd5b5051919050565b60008219821115611bf557611bf5611b91565b500190565b6000600019821415611c0e57611c0e611b91565b5060010190565b634e487b7160e01b600052603260045260246000fd5b600082821015611c3d57611c3d611b91565b500390565b6000816000190483118215151615611c5c57611c5c611b91565b500290565b6000825160005b81811015611c825760208186018101518583015201611c68565b81811115611c91576000828501525b509190910192915050565b600060208284031215611cae57600080fd5b81516103a8816117cf565b600060208284031215611ccb57600080fd5b813560ff811681146103a857600080fd5b634e487b7160e01b600052602160045260246000fdfea264697066735822122017fb20ee53b55e3be0251a677109cd15e0261aff80c0cb8d4f79844d19590cf164736f6c634300080900330000000000000000000000000326b0688d9869a19388312df6805d1d72aab7bc000000000000000000000000957a229f2fdb792ed075004d63eec99c7f2d8df1

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106100f55760003560e01c806381a36fb611610097578063c36be35711610066578063c36be357146102d3578063ce0b1966146102e6578063e449f341146102f9578063f2fde38b1461030c57600080fd5b806381a36fb6146101bf5780638462151c1461025a5780638da5cb5b1461027a578063bb10c8291461029557600080fd5b806370a08231116100d357806370a0823114610179578063715018a61461018c5780637e75dd6014610194578063817b1cd2146101b657600080fd5b8063150b7a02146100fa5780633e823f79146101435780636ba4c13814610164575b600080fd5b61010d6101083660046117e4565b61031f565b6040517fffffffff0000000000000000000000000000000000000000000000000000000090911681526020015b60405180910390f35b610156610151366004611883565b61039a565b60405190815260200161013a565b6101776101723660046118e1565b6103af565b005b610156610187366004611923565b6103c0565b6101776104a9565b6101a76101a2366004611940565b61050f565b60405161013a93929190611995565b61015660015481565b6102196101cd366004611883565b60046020526000908152604090208054600182015460029092015462ffffff821692630100000090920465ffffffffffff1691906001600160a01b03811690600160a01b900460ff1685565b6040805162ffffff909616865265ffffffffffff9094166020860152928401919091526001600160a01b0316606083015260ff16608082015260a00161013a565b61026d610268366004611923565b61077b565b60405161013a91906119d1565b6000546040516001600160a01b03909116815260200161013a565b6102c36102a3366004611ab8565b805160208183018101805160058252928201919093012091525460ff1681565b604051901515815260200161013a565b6101776102e1366004611940565b61097a565b6101776102f4366004611af5565b61098c565b6101776103073660046118e1565b610dc2565b61017761031a366004611923565b610dcf565b60006001600160a01b038516156103885760405162461bcd60e51b815260206004820152602260248201527f43616e6e6f742073656e64206e66747320746f205661756c74206469726563746044820152616c7960f01b60648201526084015b60405180910390fd5b50630a85bd0160e11b95945050505050565b6000806103a8601484611ba7565b9392505050565b6103bc3383836000610e9a565b5050565b600080600090506000600260009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561041757600080fd5b505afa15801561042b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061044f9190611bc9565b905060005b8181116104a0576000818152600460205260409020600201546001600160a01b038681169116141561048e5761048b600184611be2565b92505b8061049881611bfa565b915050610454565b50909392505050565b6000546001600160a01b031633146105035760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161037f565b61050d6000611125565b565b6105176117b1565b60008080808080808080805b8b81101561072f578c8c8281811061053d5761053d611c15565b9050602002013597506000600460008a81526020019081526020016000206040518060a00160405290816000820160009054906101000a900462ffffff1662ffffff1662ffffff1681526020016000820160039054906101000a900465ffffffffffff1665ffffffffffff1665ffffffffffff168152602001600182015481526020016002820160009054906101000a90046001600160a01b03166001600160a01b03166001600160a01b031681526020016002820160149054906101000a900460ff1660ff1660ff168152505090508e6001600160a01b031681606001516001600160a01b0316146106615760405162461bcd60e51b815260206004820152600c60248201526b3737ba1030b71037bbb732b960a11b604482015260640161037f565b602081015165ffffffffffff166201518061067c8242611c2b565b6106869190611ba7565b60408301819052965061069a876007611c42565b94506106a7600788611ba7565b9350816080015160ff16600014156106c7576106c4846002611c42565b95505b816080015160ff16600114156106e5576106e2846005611c42565b95505b816080015160ff16600214156107035761070084600f611c42565b95505b8561070e868a611be2565b6107189190611be2565b97505050808061072790611bfa565b915050610523565b5061074285670de0b6b3a7640000611c42565b9550851561076a57505060408051602081019091529384529296509450909250610772915050565b505050505050505b93509350939050565b60606000600260009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b1580156107cd57600080fd5b505afa1580156107e1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108059190611bc9565b905060008167ffffffffffffffff81111561082257610822611a15565b60405190808252806020026020018201604052801561084b578160200160208202803683370190505b5090506000805b8381116108d4576000818152600460205260409020600201546001600160a01b03878116911614156108c257600081815260046020526040902054835162ffffff909116908490849081106108a9576108a9611c15565b60209081029190910101526108bf600183611be2565b91505b806108cc81611bfa565b915050610852565b5060008167ffffffffffffffff8111156108f0576108f0611a15565b604051908082528060200260200182016040528015610919578160200160208202803683370190505b50905060005b828110156109705783818151811061093957610939611c15565b602002602001015182828151811061095357610953611c15565b60209081029190910101528061096881611bfa565b91505061091f565b5095945050505050565b6109878383836000610e9a565b505050565b6109968282611182565b6109e25760405162461bcd60e51b815260206004820152600e60248201527f5369676e206e6f742076616c6964000000000000000000000000000000000000604482015260640161037f565b6005816040516109f29190611c61565b9081526040519081900360200190205460ff1615610a525760405162461bcd60e51b815260206004820181905260248201527f5369676e61747572652068617320616c7265616479206265656e20757365642e604482015260640161037f565b60008686905060016000828254610a699190611be2565b90915550600090505b86811015610d8657878782818110610a8c57610a8c611c15565b6002546040516331a9108f60e11b8152602092909202939093013560048201819052945033926001600160a01b03169150636352211e9060240160206040518083038186803b158015610ade57600080fd5b505afa158015610af2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b169190611c9c565b6001600160a01b031614610b6c5760405162461bcd60e51b815260206004820152600e60248201527f6e6f7420796f757220746f6b656e000000000000000000000000000000000000604482015260640161037f565b60008281526004602052604090205462ffffff1615610bcd5760405162461bcd60e51b815260206004820152600e60248201527f616c7265616479207374616b6564000000000000000000000000000000000000604482015260640161037f565b6002546040516323b872dd60e01b8152336004820152306024820152604481018490526001600160a01b03909116906323b872dd90606401600060405180830381600087803b158015610c1f57600080fd5b505af1158015610c33573d6000803e3d6000fd5b50506040805133815260208101869052428183015290517f36b3725f1783bad4ff05b7f4c077c3aa68eeb23a4d054ba189db4d01ac278d399350908190036060019150a16040518060a001604052808362ffffff1681526020014265ffffffffffff16815260200160008152602001336001600160a01b03168152602001878784818110610cc357610cc3611c15565b9050602002016020810190610cd89190611cb9565b60ff908116909152600084815260046020908152604091829020845181549286015165ffffffffffff1663010000000268ffffffffffffffffff1990931662ffffff90911617919091178155908301516001820155606083015160029091018054608090940151909216600160a01b0274ffffffffffffffffffffffffffffffffffffffffff199093166001600160a01b039091161791909117905580610d7e81611bfa565b915050610a72565b506001600583604051610d999190611c61565b908152604051908190036020019020805491151560ff1990921691909117905550505050505050565b6103bc3383836001610e9a565b6000546001600160a01b03163314610e295760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161037f565b6001600160a01b038116610e8e5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161037f565b610e9781611125565b50565b6000808080808080805b89811015611043578a8a82818110610ebe57610ebe611c15565b60209081029290920135600081815260048452604090819020815160a081018352815462ffffff811682526301000000900465ffffffffffff1695810195909552600181015491850191909152600201546001600160a01b0380821660608601819052600160a01b90920460ff166080860152919b50908f16149050610f755760405162461bcd60e51b815260206004820152600c60248201526b3737ba1030b71037bbb732b960a11b604482015260640161037f565b602081015165ffffffffffff1662015180610f908242611c2b565b610f9a9190611ba7565b604083018190529650610fae876007611c42565b9450610fbb600788611ba7565b9350816080015160ff1660001415610fdb57610fd8846002611c42565b95505b816080015160ff1660011415610ff957610ff6846005611c42565b95505b816080015160ff16600214156110175761101484600f611c42565b95505b85611022868a611be2565b61102c9190611be2565b97505050808061103b90611bfa565b915050610ea4565b5061105685670de0b6b3a7640000611c42565b955085156110c5576003546040516340c10f1960e01b81526001600160a01b038d8116600483015260248201899052909116906340c10f1990604401600060405180830381600087803b1580156110ac57600080fd5b505af11580156110c0573d6000803e3d6000fd5b505050505b87156110d6576110d68b8b8b61121f565b604080516001600160a01b038d168152602081018890527fd8138f8a3f377c5259ca548e70e4c2de94f129f5a11036a15b69513cba2b426a910160405180910390a15050505050505050505050565b600080546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6040517f19457468657265756d205369676e6564204d6573736167653a0a3332000000006020820152603c81018390526000908190605c016040516020818303038152906040528051906020012090506111dc8184611423565b6001600160a01b0316730ac6119362e892aea0025bf00182cad3673a9c796001600160a01b03161415611213576001915050611219565b60009150505b92915050565b600082829050600160008282546112369190611c2b565b90915550600090505b8281101561141c5783838281811061125957611259611c15565b60209081029290920135600081815260048452604090819020815160a081018352815462ffffff811682526301000000900465ffffffffffff1695810195909552600181015491850191909152600201546001600160a01b03811660608501819052600160a01b90910460ff1660808501529094503314905061130d5760405162461bcd60e51b815260206004820152600c60248201526b3737ba1030b71037bbb732b960a11b604482015260640161037f565b6000838152600460209081526040808320805468ffffffffffffffffff1916815560018101939093556002909201805474ffffffffffffffffffffffffffffffffffffffffff1916905581516001600160a01b0389168152908101859052428183015290517fc486b9458a8637650d84d262414833a5a457bc91ae86b7da110386c8c3fa255b9181900360600190a16002546040516323b872dd60e01b81523060048201526001600160a01b03888116602483015260448201869052909116906323b872dd90606401600060405180830381600087803b1580156113f057600080fd5b505af1158015611404573d6000803e3d6000fd5b5050505050808061141490611bfa565b91505061123f565b5050505050565b60008060006114328585611447565b9150915061143f816114b7565b509392505050565b60008082516041141561147e5760208301516040840151606085015160001a61147287828585611672565b945094505050506114b0565b8251604014156114a8576020830151604084015161149d86838361175f565b9350935050506114b0565b506000905060025b9250929050565b60008160048111156114cb576114cb611cdc565b14156114d45750565b60018160048111156114e8576114e8611cdc565b14156115365760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e61747572650000000000000000604482015260640161037f565b600281600481111561154a5761154a611cdc565b14156115985760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e67746800604482015260640161037f565b60038160048111156115ac576115ac611cdc565b14156116055760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b606482015260840161037f565b600481600481111561161957611619611cdc565b1415610e975760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b606482015260840161037f565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08311156116a95750600090506003611756565b8460ff16601b141580156116c157508460ff16601c14155b156116d25750600090506004611756565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015611726573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811661174f57600060019250925050611756565b9150600090505b94509492505050565b6000807f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff83168161179560ff86901c601b611be2565b90506117a387828885611672565b935093505050935093915050565b60405180602001604052806001906020820280368337509192915050565b6001600160a01b0381168114610e9757600080fd5b6000806000806000608086880312156117fc57600080fd5b8535611807816117cf565b94506020860135611817816117cf565b935060408601359250606086013567ffffffffffffffff8082111561183b57600080fd5b818801915088601f83011261184f57600080fd5b81358181111561185e57600080fd5b89602082850101111561187057600080fd5b9699959850939650602001949392505050565b60006020828403121561189557600080fd5b5035919050565b60008083601f8401126118ae57600080fd5b50813567ffffffffffffffff8111156118c657600080fd5b6020830191508360208260051b85010111156114b057600080fd5b600080602083850312156118f457600080fd5b823567ffffffffffffffff81111561190b57600080fd5b6119178582860161189c565b90969095509350505050565b60006020828403121561193557600080fd5b81356103a8816117cf565b60008060006040848603121561195557600080fd5b8335611960816117cf565b9250602084013567ffffffffffffffff81111561197c57600080fd5b6119888682870161189c565b9497909650939450505050565b60608101818560005b60018110156119bd57815183526020928301929091019060010161199e565b505050602082019390935260400152919050565b6020808252825182820181905260009190848201906040850190845b81811015611a09578351835292840192918401916001016119ed565b50909695505050505050565b634e487b7160e01b600052604160045260246000fd5b600082601f830112611a3c57600080fd5b813567ffffffffffffffff80821115611a5757611a57611a15565b604051601f8301601f19908116603f01168101908282118183101715611a7f57611a7f611a15565b81604052838152866020858801011115611a9857600080fd5b836020870160208301376000602085830101528094505050505092915050565b600060208284031215611aca57600080fd5b813567ffffffffffffffff811115611ae157600080fd5b611aed84828501611a2b565b949350505050565b60008060008060008060808789031215611b0e57600080fd5b863567ffffffffffffffff80821115611b2657600080fd5b611b328a838b0161189c565b90985096506020890135915080821115611b4b57600080fd5b611b578a838b0161189c565b9096509450604089013593506060890135915080821115611b7757600080fd5b50611b8489828a01611a2b565b9150509295509295509295565b634e487b7160e01b600052601160045260246000fd5b600082611bc457634e487b7160e01b600052601260045260246000fd5b500490565b600060208284031215611bdb57600080fd5b5051919050565b60008219821115611bf557611bf5611b91565b500190565b6000600019821415611c0e57611c0e611b91565b5060010190565b634e487b7160e01b600052603260045260246000fd5b600082821015611c3d57611c3d611b91565b500390565b6000816000190483118215151615611c5c57611c5c611b91565b500290565b6000825160005b81811015611c825760208186018101518583015201611c68565b81811115611c91576000828501525b509190910192915050565b600060208284031215611cae57600080fd5b81516103a8816117cf565b600060208284031215611ccb57600080fd5b813560ff811681146103a857600080fd5b634e487b7160e01b600052602160045260246000fdfea264697066735822122017fb20ee53b55e3be0251a677109cd15e0261aff80c0cb8d4f79844d19590cf164736f6c63430008090033

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

0000000000000000000000000326b0688d9869a19388312df6805d1d72aab7bc000000000000000000000000957a229f2fdb792ed075004d63eec99c7f2d8df1

-----Decoded View---------------
Arg [0] : _nft (address): 0x0326b0688d9869a19388312Df6805d1D72AaB7bC
Arg [1] : _token (address): 0x957A229F2fDb792Ed075004D63eEc99C7f2D8dF1

-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 0000000000000000000000000326b0688d9869a19388312df6805d1d72aab7bc
Arg [1] : 000000000000000000000000957a229f2fdb792ed075004d63eec99c7f2d8df1


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  ]

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.