Transaction Hash:
Block:
14676135 at Apr-29-2022 12:50:35 AM +UTC
Transaction Fee:
0.007645302104427072 ETH
$19.23
Gas Used:
138,896 Gas / 55.043356932 Gwei
Emitted Events:
172 |
NFT.Transfer( from=0x00000000...000000000, to=[Sender] 0xc90931ad448e2939af1fa6f3ab75227cb993a707, tokenId=1634 )
|
Account State Difference:
Address | Before | After | State Difference | ||
---|---|---|---|---|---|
0xb9A4A79c...68461e7Cd | |||||
0xC90931Ad...Cb993A707 |
0.01 Eth
Nonce: 0
|
0.002354697895572928 Eth
Nonce: 1
| 0.007645302104427072 | ||
0xE283DDDc...CD154372E | |||||
0xEA674fdD...16B898ec8
Miner
| (Ethermine) | 1,180.744318136616666321 Eth | 1,180.744526480616666321 Eth | 0.000208344 |
Execution Trace
MintingRouter.publicMint( recipient=0xC90931Ad448e2939af1fA6F3ab75227Cb993A707, quantity=1 )
-
NFT.mint( recipient=0xC90931Ad448e2939af1fA6F3ab75227Cb993A707, quantity=1 )
File 1 of 2: MintingRouter
File 2 of 2: NFT
{"Context.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n"},"ECDSA.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/cryptography/ECDSA.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./Strings.sol\";\n\n/**\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\n *\n * These functions can be used to verify that a message was signed by the holder\n * of the private keys of a given address.\n */\nlibrary ECDSA {\n enum RecoverError {\n NoError,\n InvalidSignature,\n InvalidSignatureLength,\n InvalidSignatureS,\n InvalidSignatureV\n }\n\n function _throwError(RecoverError error) private pure {\n if (error == RecoverError.NoError) {\n return; // no error: do nothing\n } else if (error == RecoverError.InvalidSignature) {\n revert(\"ECDSA: invalid signature\");\n } else if (error == RecoverError.InvalidSignatureLength) {\n revert(\"ECDSA: invalid signature length\");\n } else if (error == RecoverError.InvalidSignatureS) {\n revert(\"ECDSA: invalid signature \u0027s\u0027 value\");\n } else if (error == RecoverError.InvalidSignatureV) {\n revert(\"ECDSA: invalid signature \u0027v\u0027 value\");\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature` or error string. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n *\n * Documentation for signature generation:\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\n *\n * _Available since v4.3._\n */\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {\n // Check the signature length\n // - case 65: r,s,v signature (standard)\n // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._\n if (signature.length == 65) {\n bytes32 r;\n bytes32 s;\n uint8 v;\n // ecrecover takes the signature parameters, and the only way to get them\n // currently is to use assembly.\n assembly {\n r := mload(add(signature, 0x20))\n s := mload(add(signature, 0x40))\n v := byte(0, mload(add(signature, 0x60)))\n }\n return tryRecover(hash, v, r, s);\n } else if (signature.length == 64) {\n bytes32 r;\n bytes32 vs;\n // ecrecover takes the signature parameters, and the only way to get them\n // currently is to use assembly.\n assembly {\n r := mload(add(signature, 0x20))\n vs := mload(add(signature, 0x40))\n }\n return tryRecover(hash, r, vs);\n } else {\n return (address(0), RecoverError.InvalidSignatureLength);\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature`. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n */\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, signature);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\n *\n * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address, RecoverError) {\n bytes32 s = vs \u0026 bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\n uint8 v = uint8((uint256(vs) \u003e\u003e 255) + 27);\n return tryRecover(hash, v, r, s);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\n *\n * _Available since v4.2._\n */\n function recover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, r, vs);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\n * `r` and `s` signature fields separately.\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address, RecoverError) {\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n // the valid range for s in (301): 0 \u003c s \u003c secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most\n // signatures from current libraries generate a unique signature with an s-value in the lower half order.\n //\n // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\n // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\n // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\n // these malleable signatures as well.\n if (uint256(s) \u003e 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n return (address(0), RecoverError.InvalidSignatureS);\n }\n if (v != 27 \u0026\u0026 v != 28) {\n return (address(0), RecoverError.InvalidSignatureV);\n }\n\n // If the signature is valid (and not malleable), return the signer address\n address signer = ecrecover(hash, v, r, s);\n if (signer == address(0)) {\n return (address(0), RecoverError.InvalidSignature);\n }\n\n return (signer, RecoverError.NoError);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `v`,\n * `r` and `s` signature fields separately.\n */\n function recover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from a `hash`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {\n // 32 is the length in bytes of hash,\n // enforced by the type signature above\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n32\", hash));\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from `s`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n\", Strings.toString(s.length), s));\n }\n\n /**\n * @dev Returns an Ethereum Signed Typed Data, created from a\n * `domainSeparator` and a `structHash`. This produces hash corresponding\n * to the one signed with the\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]\n * JSON-RPC method as part of EIP-712.\n *\n * See {recover}.\n */\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19\\x01\", domainSeparator, structHash));\n }\n}\n"},"EIP712Whitelisting.sol":{"content":"//SPDX-License-Identifier: Unlicense\npragma solidity ^0.8.0;\n\nimport \"./ECDSA.sol\";\n\ncontract EIP712Whitelisting {\n using ECDSA for bytes32;\n\n // The key used to sign whitelist signatures.\n // We will check to ensure that the key that signed the signature\n // is this one that we expect.\n address whitelistSigningKey = address(0);\n\n // Domain Separator is the EIP-712 defined structure that defines what contract\n // and chain these signatures can be used for. This ensures people can\u0027t take\n // a signature used to mint on one contract and use it for another, or a signature\n // from testnet to replay on mainnet.\n // It has to be created in the constructor so we can dynamically grab the chainId.\n // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-712.md#definition-of-domainseparator\n bytes32 public DOMAIN_SEPARATOR;\n\n // The typehash for the data type specified in the structured data\n // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-712.md#rationale-for-typehash\n // This should match whats in the client side whitelist signing code\n // https://github.com/msfeldstein/EIP712-whitelisting/blob/main/test/signWhitelist.ts#L22\n bytes32 public constant MINTER_TYPEHASH = keccak256(\"Minter(address wallet)\");\n\n constructor(string memory tokenName, string memory version) {\n // This should match whats in the client side whitelist signing code\n // https://github.com/msfeldstein/EIP712-whitelisting/blob/main/test/signWhitelist.ts#L12\n DOMAIN_SEPARATOR = keccak256(\n abi.encode(\n keccak256(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\"),\n // This should match the domain you set in your client side signing.\n keccak256(bytes(tokenName)),\n keccak256(bytes(version)),\n block.chainid,\n address(this)\n )\n );\n }\n\n function _setWhitelistSigningAddress(address newSigningKey) internal {\n whitelistSigningKey = newSigningKey;\n }\n\n modifier requiresWhitelist(bytes calldata signature) {\n require(whitelistSigningKey != address(0), \"Whitelist not enabled; please set the private key.\");\n // Verify EIP-712 signature by recreating the data structure\n // that we signed on the client side, and then using that to recover\n // the address that signed the signature for this data.\n bytes32 digest = keccak256(abi.encodePacked(\"\\x19\\x01\", DOMAIN_SEPARATOR, keccak256(abi.encode(MINTER_TYPEHASH, msg.sender))));\n // Use the recover method to see what address was used to create\n // the signature on this data.\n // Note that if the digest doesn\u0027t exactly match what was signed we\u0027ll\n // get a random recovered address.\n address recoveredAddress = digest.recover(signature);\n require(recoveredAddress == whitelistSigningKey, \"Invalid signature\");\n _;\n }\n}\n"},"MintingRouter.sol":{"content":"//SPDX-License-Identifier: UNLICENSED\n\n// ███████╗███╗ ██╗███████╗ █████╗ ██╗ ██╗██╗ ██╗ ██████╗ ██████╗ ██████╗ ██╗ ██╗███╗ ██╗███████╗\n// ██╔════╝████╗ ██║██╔════╝██╔══██╗██║ ██╔╝╚██╗ ██╔╝ ██╔════╝ ██╔═══██╗██╔══██╗██║ ██║████╗ ██║██╔════╝\n// ███████╗██╔██╗ ██║█████╗ ███████║█████╔╝ ╚████╔╝ ██║ ███╗██║ ██║██████╔╝██║ ██║██╔██╗ ██║███████╗\n// ╚════██║██║╚██╗██║██╔══╝ ██╔══██║██╔═██╗ ╚██╔╝ ██║ ██║██║ ██║██╔══██╗██║ ██║██║╚██╗██║╚════██║\n// ███████║██║ ╚████║███████╗██║ ██║██║ ██╗ ██║ ╚██████╔╝╚██████╔╝██████╔╝███████╗██║██║ ╚████║███████║\n// ╚══════╝╚═╝ ╚═══╝╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚══════╝╚═╝╚═╝ ╚═══╝╚══════╝\n\npragma solidity 0.8.13;\n\n// Imports\nimport \"./ReentrancyGuard.sol\";\nimport \"./Ownable.sol\";\nimport \"./EIP712Whitelisting.sol\";\n\n/// NFT Interface\ninterface INFT {\n function mint(address recipient, uint256 quantity) external;\n function preminted() external view returns (bool);\n function MAX_SUPPLY() external view returns(uint256);\n function totalSupply() external view returns(uint256);\n}\n\n/**\n * @title The Minting Router contract.\n */\ncontract MintingRouter is EIP712Whitelisting, ReentrancyGuard, Ownable {\n // The available sale types.\n enum SaleRoundType {\n WHITELIST,\n PUBLIC\n }\n\n // The sale round details.\n struct SaleRound {\n // The type of the sale.\n SaleRoundType saleType;\n // The price of a token during the sale round.\n uint256 price;\n // The total number of tokens available for minting during the sale round.\n uint256 totalAmount;\n // The total number of tokens available for minting by a single wallet during the sale round.\n uint256 limitAmountPerWallet;\n // The maximum number of tokens available for minting per single transaction.\n uint256 maxAmountPerMint;\n // The flag that indicates if the sale round is enabled.\n bool enabled;\n }\n\n /// @notice Indicates that tokens are unlimited.\n uint256 private constant UNLIMITED_AMOUNT = 0;\n /// @notice The current sale round details.\n SaleRound public saleRound;\n /// @notice The current sale round index.\n uint256 public currentSaleIndex;\n /// @notice The number of NFTs minted during an ongoing sale round.\n uint256 public totalMintedAmountCurrentRound;\n /// @notice The number of NFTs minted during a sale round.\n mapping(uint256 =\u003e uint256) public mintedAmountPerRound;\n /// @notice The NFT contract.\n INFT private _nftContract;\n /// @notice The number of NFTs minted during a sale round per wallet.\n mapping(uint256 =\u003e mapping(address =\u003e uint256)) private _mintedAmountPerAddress;\n\n /**\n * @notice The smart contract constructor that initializes the minting router.\n * @param nftContract_ The NFT contract.\n * @param tokenName The name of the NFT token.\n * @param version The version of the project.\n */\n constructor(INFT nftContract_, string memory tokenName, string memory version) EIP712Whitelisting(tokenName, version) {\n // Initialize the variables.\n _nftContract = nftContract_;\n // Set the initial dummy value for the current sale index.\n currentSaleIndex = type(uint256).max;\n }\n\n /**\n * @notice Changes the current sale details.\n * @param price The price of an NFT for the current sale round.\n * @param totalAmount The total amount of NFTs available for the current sale round.\n * @param limitAmountPerWallet The total number of NFTs that can be minted by a single wallet during the sale round.\n * @param maxAmountPerMint The maximum number of tokens available for minting per single transaction.\n */\n function changeSaleRoundParams(\n uint256 price,\n uint256 totalAmount,\n uint8 limitAmountPerWallet,\n uint256 maxAmountPerMint\n ) external onlyOwner {\n saleRound.price = price;\n saleRound.totalAmount = totalAmount;\n saleRound.limitAmountPerWallet = limitAmountPerWallet;\n saleRound.maxAmountPerMint = maxAmountPerMint;\n }\n\n /**\n * @notice Creates a new sale round.\n * @dev Requires sales to be disabled and reserves to be minted.\n * @param saleType The type of the sale round (WHITELIST - 0, PUBLIC SALE - 1).\n * @param price The price of an NFT for the current sale round.\n * @param totalAmount The total amount of NFTs available for the current sale round.\n * @param limitAmountPerWallet The total number of NFTs that can be minted by a single wallet during the sale round.\n * @param maxAmountPerMint The maximum number of tokens available for minting per single transaction.\n */\n function createSaleRound(\n SaleRoundType saleType,\n uint256 price,\n uint256 totalAmount,\n uint256 limitAmountPerWallet,\n uint256 maxAmountPerMint\n ) external onlyOwner {\n // Check if the reserves are minted.\n bool preminted = _nftContract.preminted();\n require(preminted == true, \"Must mint reserved tokens\");\n // Check if the sales are closed.\n require(saleRound.enabled == false, \"Must disable the current round\");\n // Increment the sale round index.\n if (currentSaleIndex == type(uint256).max) {\n currentSaleIndex = 0;\n } else {\n currentSaleIndex += 1;\n }\n // Set new sale parameters.\n saleRound.price = price;\n saleRound.totalAmount = totalAmount;\n saleRound.limitAmountPerWallet = limitAmountPerWallet;\n saleRound.maxAmountPerMint = maxAmountPerMint;\n saleRound.saleType = saleType;\n\n // Reset the number of tokens minted during the round.\n totalMintedAmountCurrentRound = 0;\n }\n\n /**\n * @notice Starts the sale round.\n */\n function enableSaleRound() external onlyOwner {\n require(saleRound.enabled == false, \"Sale round was already enabled\");\n saleRound.enabled = true;\n }\n\n /**\n * @notice Closes the sale round.\n */\n function disableSaleRound() external onlyOwner {\n require(saleRound.enabled == true, \"Sale round was already disabled\");\n saleRound.enabled = false;\n }\n\n /**\n * @notice Mints NFTs during whitelist sale rounds.\n * @dev Requires the current sale round to be a WHITELIST round.\n * @param recipient The address that will receive the minted NFT.\n * @param quantity The number of NFTs to mint.\n * @param signature The signature of a whitelisted minter.\n */\n function whitelistMint(address recipient, uint256 quantity, bytes calldata signature) external payable requiresWhitelist(signature) nonReentrant {\n require(saleRound.saleType == SaleRoundType.WHITELIST, \"Not a whitelist round\");\n _mint(msg.value, recipient, quantity);\n }\n\n /**\n * @notice Mints NFTs during public sale rounds.\n * @dev Requires the current sale round to be a PUBLIC round.\n * @param recipient The address that will receive the minted NFT.\n * @param quantity The number of NFTs to mint.\n */\n function publicMint(address recipient, uint256 quantity) external payable nonReentrant {\n require(saleRound.saleType == SaleRoundType.PUBLIC, \"Not a public round\");\n _mint(msg.value, recipient, quantity);\n }\n\n /**\n * @notice Sets the address that is used during whitelist generation.\n * @param signer The address used during whitelist generation.\n */\n function setWhitelistSigningAddress(address signer) public onlyOwner {\n _setWhitelistSigningAddress(signer);\n }\n\n /**\n * @notice Withdraws funds to the owner wallet.\n */\n function withdraw() public onlyOwner returns(bool) {\n uint256 balance = address(this).balance;\n payable(msg.sender).transfer(balance);\n return true;\n }\n\n /**\n * @notice Calculates the number of tokens a minter is allowed to mint.\n * @param minter The minter address.\n * @return The number of tokens that a minter can mint.\n */\n function allowedTokenCount(address minter) public view returns (uint256) {\n if (saleRound.enabled == false) {\n return 0;\n }\n // Calculate the allowed number of tokens to mint by a wallet.\n uint256 allowedWalletCount = saleRound.limitAmountPerWallet != UNLIMITED_AMOUNT\n ? (saleRound.limitAmountPerWallet \u003e _mintedAmountPerAddress[currentSaleIndex][minter]\n ? saleRound.limitAmountPerWallet - _mintedAmountPerAddress[currentSaleIndex][minter] : 0)\n : _nftContract.MAX_SUPPLY() - _nftContract.totalSupply();\n // Calculate the total number of tokens left.\n uint256 availableTokenCount = saleRound.totalAmount != UNLIMITED_AMOUNT\n ? (saleRound.totalAmount \u003e mintedAmountPerRound[currentSaleIndex]\n ? saleRound.totalAmount - mintedAmountPerRound[currentSaleIndex] : 0)\n : _nftContract.MAX_SUPPLY() - _nftContract.totalSupply();\n // Calculate the limit of the number of tokens per single mint.\n uint256 allowedAmountPerMint = saleRound.maxAmountPerMint != UNLIMITED_AMOUNT\n ? saleRound.maxAmountPerMint : _nftContract.MAX_SUPPLY() - _nftContract.totalSupply();\n // Get the minimum of all values.\n uint256 allowedTokens = allowedWalletCount \u003c availableTokenCount ? allowedWalletCount : availableTokenCount;\n allowedTokens = allowedAmountPerMint \u003c allowedTokens ? allowedAmountPerMint : allowedTokens;\n return allowedTokens;\n }\n\n /**\n * @notice Returns the number of tokens left for the running sale round.\n */\n function tokensLeft() public view returns (uint256) {\n if (saleRound.enabled == false) {\n return 0;\n }\n\n return saleRound.totalAmount != UNLIMITED_AMOUNT\n ? (saleRound.totalAmount \u003e mintedAmountPerRound[currentSaleIndex]\n ? saleRound.totalAmount - mintedAmountPerRound[currentSaleIndex] : 0)\n : _nftContract.MAX_SUPPLY() - _nftContract.totalSupply();\n }\n\n /**\n * @notice Mints NFTs.\n * @param value The purchase fee.\n * @param recipient The address that will receive the minted NFT.\n * @param quantity The number of NFTs to mint.\n */\n function _mint(uint256 value, address recipient, uint256 quantity) private {\n require(saleRound.enabled == true, \"Sale round is disabled\");\n require(quantity \u003e 0, \"Quantity must be \u003e 0\");\n\n if (saleRound.maxAmountPerMint != UNLIMITED_AMOUNT) {\n require(quantity \u003c= saleRound.maxAmountPerMint, \"Max mint amount exceeded\");\n }\n\n if (saleRound.totalAmount != UNLIMITED_AMOUNT) {\n require(totalMintedAmountCurrentRound + quantity \u003c= saleRound.totalAmount, \"Max sale amount reached\");\n }\n\n if (saleRound.limitAmountPerWallet != UNLIMITED_AMOUNT) {\n uint256 mintedAmountSoFar = _mintedAmountPerAddress[currentSaleIndex][recipient];\n require(mintedAmountSoFar + quantity \u003c= saleRound.limitAmountPerWallet, \"Max minted per address reached\");\n }\n\n require(value \u003e= saleRound.price * quantity, \"Insufficient funds\");\n _nftContract.mint(recipient, quantity);\n totalMintedAmountCurrentRound += quantity;\n // update total minted amount of this address\n _mintedAmountPerAddress[currentSaleIndex][recipient] += quantity;\n mintedAmountPerRound[currentSaleIndex] += quantity;\n }\n}\n"},"Ownable.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n constructor() {\n _transferOwnership(_msgSender());\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n _;\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions anymore. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby removing any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n"},"ReentrancyGuard.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Contract module that helps prevent reentrant calls to a function.\n *\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\n * available, which can be applied to functions to make sure there are no nested\n * (reentrant) calls to them.\n *\n * Note that because there is a single `nonReentrant` guard, functions marked as\n * `nonReentrant` may not call one another. This can be worked around by making\n * those functions `private`, and then adding `external` `nonReentrant` entry\n * points to them.\n *\n * TIP: If you would like to learn more about reentrancy and alternative ways\n * to protect against it, check out our blog post\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\n */\nabstract contract ReentrancyGuard {\n // Booleans are more expensive than uint256 or any type that takes up a full\n // word because each write operation emits an extra SLOAD to first read the\n // slot\u0027s contents, replace the bits taken up by the boolean, and then write\n // back. This is the compiler\u0027s defense against contract upgrades and\n // pointer aliasing, and it cannot be disabled.\n\n // The values being non-zero value makes deployment a bit more expensive,\n // but in exchange the refund on every call to nonReentrant will be lower in\n // amount. Since refunds are capped to a percentage of the total\n // transaction\u0027s gas, it is best to keep them low in cases like this one, to\n // increase the likelihood of the full refund coming into effect.\n uint256 private constant _NOT_ENTERED = 1;\n uint256 private constant _ENTERED = 2;\n\n uint256 private _status;\n\n constructor() {\n _status = _NOT_ENTERED;\n }\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n * Calling a `nonReentrant` function from another `nonReentrant`\n * function is not supported. It is possible to prevent this from happening\n * by making the `nonReentrant` function external, and making it call a\n * `private` function that does the actual work.\n */\n modifier nonReentrant() {\n // On the first call to nonReentrant, _notEntered will be true\n require(_status != _ENTERED, \"ReentrancyGuard: reentrant call\");\n\n // Any calls to nonReentrant after this point will fail\n _status = _ENTERED;\n\n _;\n\n // By storing the original value once again, a refund is triggered (see\n // https://eips.ethereum.org/EIPS/eip-2200)\n _status = _NOT_ENTERED;\n }\n}\n"},"Strings.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n bytes16 private constant _HEX_SYMBOLS = \"0123456789abcdef\";\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n // Inspired by OraclizeAPI\u0027s implementation - MIT licence\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n if (value == 0) {\n return \"0\";\n }\n uint256 temp = value;\n uint256 digits;\n while (temp != 0) {\n digits++;\n temp /= 10;\n }\n bytes memory buffer = new bytes(digits);\n while (value != 0) {\n digits -= 1;\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n value /= 10;\n }\n return string(buffer);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n if (value == 0) {\n return \"0x00\";\n }\n uint256 temp = value;\n uint256 length = 0;\n while (temp != 0) {\n length++;\n temp \u003e\u003e= 8;\n }\n return toHexString(value, length);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i \u003e 1; --i) {\n buffer[i] = _HEX_SYMBOLS[value \u0026 0xf];\n value \u003e\u003e= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\n return string(buffer);\n }\n}\n"}}
File 2 of 2: NFT
{"AccessControl.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (access/AccessControl.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IAccessControl.sol\";\nimport \"./Context.sol\";\nimport \"./Strings.sol\";\nimport \"./ERC165.sol\";\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn\u0027t allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role\u0027s admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address =\u003e bool) members;\n bytes32 adminRole;\n }\n\n mapping(bytes32 =\u003e RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with a standardized message including the required role.\n *\n * The format of the revert reason is given by the following regular expression:\n *\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\n *\n * _Available since v4.1._\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role, _msgSender());\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual override returns (bool) {\n return _roles[role].members[account];\n }\n\n /**\n * @dev Revert with a standard message if `account` is missing `role`.\n *\n * The format of the revert reason is given by the following regular expression:\n *\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert(\n string(\n abi.encodePacked(\n \"AccessControl: account \",\n Strings.toHexString(uint160(account), 20),\n \" is missing role \",\n Strings.toHexString(uint256(role), 32)\n )\n )\n );\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role\u0027s admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``\u0027s admin role.\n */\n function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``\u0027s admin role.\n */\n function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function\u0027s\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `account`.\n */\n function renounceRole(bytes32 role, address account) public virtual override {\n require(account == _msgSender(), \"AccessControl: can only renounce roles for self\");\n\n _revokeRole(role, account);\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event. Note that unlike {grantRole}, this function doesn\u0027t perform any\n * checks on the calling account.\n *\n * [WARNING]\n * ====\n * This function should only be called from the constructor when setting\n * up the initial roles for the system.\n *\n * Using this function in any other way is effectively circumventing the admin\n * system imposed by {AccessControl}.\n * ====\n *\n * NOTE: This function is deprecated in favor of {_grantRole}.\n */\n function _setupRole(bytes32 role, address account) internal virtual {\n _grantRole(role, account);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``\u0027s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * Internal function without access restriction.\n */\n function _grantRole(bytes32 role, address account) internal virtual {\n if (!hasRole(role, account)) {\n _roles[role].members[account] = true;\n emit RoleGranted(role, account, _msgSender());\n }\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * Internal function without access restriction.\n */\n function _revokeRole(bytes32 role, address account) internal virtual {\n if (hasRole(role, account)) {\n _roles[role].members[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n }\n }\n}\n"},"Address.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn\u0027t rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length \u003e 0;\n }\n\n /**\n * @dev Replacement for Solidity\u0027s `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance \u003e= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCall(target, data, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance \u003e= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(isContract(target), \"Address: delegate call to non-contract\");\n\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn\u0027t, either by bubbling the\n * revert reason using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n // Look for revert reason and bubble it up if present\n if (returndata.length \u003e 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n"},"Context.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n"},"ERC165.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n"},"ERC721A.sol":{"content":"// SPDX-License-Identifier: MIT\n// Creator: Chiru Labs\n\npragma solidity ^0.8.4;\n\nimport \u0027./IERC721.sol\u0027;\nimport \u0027./IERC721Receiver.sol\u0027;\nimport \u0027./IERC721Metadata.sol\u0027;\nimport \u0027./IERC721Enumerable.sol\u0027;\nimport \u0027./Address.sol\u0027;\nimport \u0027./Context.sol\u0027;\nimport \u0027./Strings.sol\u0027;\nimport \u0027./ERC165.sol\u0027;\n\n error ApprovalCallerNotOwnerNorApproved();\n error ApprovalQueryForNonexistentToken();\n error ApproveToCaller();\n error ApprovalToCurrentOwner();\n error BalanceQueryForZeroAddress();\n error MintedQueryForZeroAddress();\n error BurnedQueryForZeroAddress();\n error AuxQueryForZeroAddress();\n error MintToZeroAddress();\n error MintZeroQuantity();\n error OwnerIndexOutOfBounds();\n error OwnerQueryForNonexistentToken();\n error TokenIndexOutOfBounds();\n error TransferCallerNotOwnerNorApproved();\n error TransferFromIncorrectOwner();\n error TransferToNonERC721ReceiverImplementer();\n error TransferToZeroAddress();\n error URIQueryForNonexistentToken();\n\n/**\n * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including\n * the Metadata extension. Built to optimize for lower gas during batch mints.\n *\n * Assumes serials are sequentially minted starting at 0 (e.g. 0, 1, 2, 3..).\n *\n * Assumes that an owner cannot have more than 2**64 - 1 (max value of uint64) of supply.\n *\n * Assumes that the maximum token id cannot exceed 2**256 - 1 (max value of uint256).\n */\ncontract ERC721A is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable {\n using Address for address;\n using Strings for uint256;\n\n // Compiler will pack this into a single 256bit word.\n struct TokenOwnership {\n // The address of the owner.\n address addr;\n // Keeps track of the start time of ownership with minimal overhead for tokenomics.\n uint64 startTimestamp;\n // Whether the token has been burned.\n bool burned;\n }\n\n // Compiler will pack this into a single 256bit word.\n struct AddressData {\n // Realistically, 2**64-1 is more than enough.\n uint64 balance;\n // Keeps track of mint count with minimal overhead for tokenomics.\n uint64 numberMinted;\n // Keeps track of burn count with minimal overhead for tokenomics.\n uint64 numberBurned;\n // For miscellaneous variable(s) pertaining to the address\n // (e.g. number of whitelist mint slots used).\n // If there are multiple variables, please pack them into a uint64.\n uint64 aux;\n }\n\n // The tokenId of the next token to be minted.\n uint256 internal _currentIndex;\n\n // The number of tokens burned.\n uint256 internal _burnCounter;\n\n // Token name\n string private _name;\n\n // Token symbol\n string private _symbol;\n\n // Mapping from token ID to ownership details\n // An empty struct value does not necessarily mean the token is unowned. See ownershipOf implementation for details.\n mapping(uint256 =\u003e TokenOwnership) internal _ownerships;\n\n // Mapping owner address to address data\n mapping(address =\u003e AddressData) private _addressData;\n\n // Mapping from token ID to approved address\n mapping(uint256 =\u003e address) private _tokenApprovals;\n\n // Mapping from owner to operator approvals\n mapping(address =\u003e mapping(address =\u003e bool)) private _operatorApprovals;\n\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev See {IERC721Enumerable-totalSupply}.\n */\n function totalSupply() public view override returns (uint256) {\n // Counter underflow is impossible as _burnCounter cannot be incremented\n // more than _currentIndex times\n unchecked {\n return _currentIndex - _burnCounter;\n }\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {\n return\n interfaceId == type(IERC721).interfaceId ||\n interfaceId == type(IERC721Metadata).interfaceId ||\n interfaceId == type(IERC721Enumerable).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev See {IERC721-balanceOf}.\n */\n function balanceOf(address owner) public view override returns (uint256) {\n if (owner == address(0)) revert BalanceQueryForZeroAddress();\n return uint256(_addressData[owner].balance);\n }\n\n /**\n * Returns the number of tokens minted by `owner`.\n */\n function _numberMinted(address owner) internal view returns (uint256) {\n if (owner == address(0)) revert MintedQueryForZeroAddress();\n return uint256(_addressData[owner].numberMinted);\n }\n\n /**\n * Returns the number of tokens burned by or on behalf of `owner`.\n */\n function _numberBurned(address owner) internal view returns (uint256) {\n if (owner == address(0)) revert BurnedQueryForZeroAddress();\n return uint256(_addressData[owner].numberBurned);\n }\n\n /**\n * Returns the auxillary data for `owner`. (e.g. number of whitelist mint slots used).\n */\n function _getAux(address owner) internal view returns (uint64) {\n if (owner == address(0)) revert AuxQueryForZeroAddress();\n return _addressData[owner].aux;\n }\n\n /**\n * Sets the auxillary data for `owner`. (e.g. number of whitelist mint slots used).\n * If there are multiple variables, please pack them into a uint64.\n */\n function _setAux(address owner, uint64 aux) internal {\n if (owner == address(0)) revert AuxQueryForZeroAddress();\n _addressData[owner].aux = aux;\n }\n\n /**\n * Gas spent here starts off proportional to the maximum mint batch size.\n * It gradually moves to O(1) as tokens get transferred around in the collection over time.\n */\n function ownershipOf(uint256 tokenId) internal view returns (TokenOwnership memory) {\n uint256 curr = tokenId;\n\n unchecked {\n if (curr \u003c _currentIndex) {\n TokenOwnership memory ownership = _ownerships[curr];\n if (!ownership.burned) {\n if (ownership.addr != address(0)) {\n return ownership;\n }\n // Invariant:\n // There will always be an ownership that has an address and is not burned\n // before an ownership that does not have an address and is not burned.\n // Hence, curr will not underflow.\n while (true) {\n curr--;\n ownership = _ownerships[curr];\n if (ownership.addr != address(0)) {\n return ownership;\n }\n }\n }\n }\n }\n revert OwnerQueryForNonexistentToken();\n }\n\n /**\n * @dev See {IERC721-ownerOf}.\n */\n function ownerOf(uint256 tokenId) public view override returns (address) {\n return ownershipOf(tokenId).addr;\n }\n\n /**\n * @dev See {IERC721Metadata-name}.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev See {IERC721Metadata-symbol}.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev See {IERC721Metadata-tokenURI}.\n */\n function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {\n if (!_exists(tokenId)) revert URIQueryForNonexistentToken();\n\n string memory baseURI = _baseURI();\n return bytes(baseURI).length != 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : \u0027\u0027;\n }\n\n /**\n * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each\n * token will be the concatenation of the `baseURI` and the `tokenId`. Empty\n * by default, can be overriden in child contracts.\n */\n function _baseURI() internal view virtual returns (string memory) {\n return \u0027\u0027;\n }\n\n /**\n * @dev See {IERC721-approve}.\n */\n function approve(address to, uint256 tokenId) public override {\n address owner = ERC721A.ownerOf(tokenId);\n if (to == owner) revert ApprovalToCurrentOwner();\n\n if (_msgSender() != owner \u0026\u0026 !isApprovedForAll(owner, _msgSender())) {\n revert ApprovalCallerNotOwnerNorApproved();\n }\n\n _approve(to, tokenId, owner);\n }\n\n /**\n * @dev See {IERC721-getApproved}.\n */\n function getApproved(uint256 tokenId) public view override returns (address) {\n if (!_exists(tokenId)) revert ApprovalQueryForNonexistentToken();\n\n return _tokenApprovals[tokenId];\n }\n\n /**\n * @dev See {IERC721-setApprovalForAll}.\n */\n function setApprovalForAll(address operator, bool approved) public override {\n if (operator == _msgSender()) revert ApproveToCaller();\n\n _operatorApprovals[_msgSender()][operator] = approved;\n emit ApprovalForAll(_msgSender(), operator, approved);\n }\n\n /**\n * @dev See {IERC721-isApprovedForAll}.\n */\n function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {\n return _operatorApprovals[owner][operator];\n }\n\n /**\n * @dev See {IERC721-transferFrom}.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n _transfer(from, to, tokenId);\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n safeTransferFrom(from, to, tokenId, \u0027\u0027);\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes memory _data\n ) public virtual override {\n _transfer(from, to, tokenId);\n if (!_checkOnERC721Received(from, to, tokenId, _data)) {\n revert TransferToNonERC721ReceiverImplementer();\n }\n }\n\n /**\n * @dev Returns whether `tokenId` exists.\n *\n * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.\n *\n * Tokens start existing when they are minted (`_mint`),\n */\n function _exists(uint256 tokenId) internal view returns (bool) {\n return tokenId \u003c _currentIndex \u0026\u0026 !_ownerships[tokenId].burned;\n }\n\n function _safeMint(address to, uint256 quantity) internal {\n _safeMint(to, quantity, \u0027\u0027);\n }\n\n /**\n * @dev Safely mints `quantity` tokens and transfers them to `to`.\n *\n * Requirements:\n *\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called for each safe transfer.\n * - `quantity` must be greater than 0.\n *\n * Emits a {Transfer} event.\n */\n function _safeMint(\n address to,\n uint256 quantity,\n bytes memory _data\n ) internal {\n _mint(to, quantity, _data, true);\n }\n\n /**\n * @dev Mints `quantity` tokens and transfers them to `to`.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - `quantity` must be greater than 0.\n *\n * Emits a {Transfer} event.\n */\n function _mint(\n address to,\n uint256 quantity,\n bytes memory _data,\n bool safe\n ) internal {\n uint256 startTokenId = _currentIndex;\n if (to == address(0)) revert MintToZeroAddress();\n if (quantity == 0) revert MintZeroQuantity();\n\n _beforeTokenTransfers(address(0), to, startTokenId, quantity);\n\n // Overflows are incredibly unrealistic.\n // balance or numberMinted overflow if current value of either + quantity \u003e 1.8e19 (2**64) - 1\n // updatedIndex overflows if _currentIndex + quantity \u003e 1.2e77 (2**256) - 1\n unchecked {\n _addressData[to].balance += uint64(quantity);\n _addressData[to].numberMinted += uint64(quantity);\n\n _ownerships[startTokenId].addr = to;\n _ownerships[startTokenId].startTimestamp = uint64(block.timestamp);\n\n uint256 updatedIndex = startTokenId;\n\n for (uint256 i; i \u003c quantity; i++) {\n emit Transfer(address(0), to, updatedIndex);\n if (safe \u0026\u0026 !_checkOnERC721Received(address(0), to, updatedIndex, _data)) {\n revert TransferToNonERC721ReceiverImplementer();\n }\n updatedIndex++;\n }\n\n _currentIndex = updatedIndex;\n }\n _afterTokenTransfers(address(0), to, startTokenId, quantity);\n }\n\n /**\n * @dev Transfers `tokenId` from `from` to `to`.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n *\n * Emits a {Transfer} event.\n */\n function _transfer(\n address from,\n address to,\n uint256 tokenId\n ) private {\n TokenOwnership memory prevOwnership = ownershipOf(tokenId);\n\n bool isApprovedOrOwner = (_msgSender() == prevOwnership.addr ||\n isApprovedForAll(prevOwnership.addr, _msgSender()) ||\n getApproved(tokenId) == _msgSender());\n\n if (!isApprovedOrOwner) revert TransferCallerNotOwnerNorApproved();\n if (prevOwnership.addr != from) revert TransferFromIncorrectOwner();\n if (to == address(0)) revert TransferToZeroAddress();\n\n _beforeTokenTransfers(from, to, tokenId, 1);\n\n // Clear approvals from the previous owner\n _approve(address(0), tokenId, prevOwnership.addr);\n\n // Underflow of the sender\u0027s balance is impossible because we check for\n // ownership above and the recipient\u0027s balance can\u0027t realistically overflow.\n // Counter overflow is incredibly unrealistic as tokenId would have to be 2**256.\n unchecked {\n _addressData[from].balance -= 1;\n _addressData[to].balance += 1;\n\n _ownerships[tokenId].addr = to;\n _ownerships[tokenId].startTimestamp = uint64(block.timestamp);\n\n // If the ownership slot of tokenId+1 is not explicitly set, that means the transfer initiator owns it.\n // Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls.\n uint256 nextTokenId = tokenId + 1;\n if (_ownerships[nextTokenId].addr == address(0)) {\n // This will suffice for checking _exists(nextTokenId),\n // as a burned slot cannot contain the zero address.\n if (nextTokenId \u003c _currentIndex) {\n _ownerships[nextTokenId].addr = prevOwnership.addr;\n _ownerships[nextTokenId].startTimestamp = prevOwnership.startTimestamp;\n }\n }\n }\n\n emit Transfer(from, to, tokenId);\n _afterTokenTransfers(from, to, tokenId, 1);\n }\n\n /**\n * @dev Destroys `tokenId`.\n * The approval is cleared when the token is burned.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n *\n * Emits a {Transfer} event.\n */\n function _burn(uint256 tokenId) internal virtual {\n TokenOwnership memory prevOwnership = ownershipOf(tokenId);\n\n _beforeTokenTransfers(prevOwnership.addr, address(0), tokenId, 1);\n\n // Clear approvals from the previous owner\n _approve(address(0), tokenId, prevOwnership.addr);\n\n // Underflow of the sender\u0027s balance is impossible because we check for\n // ownership above and the recipient\u0027s balance can\u0027t realistically overflow.\n // Counter overflow is incredibly unrealistic as tokenId would have to be 2**256.\n unchecked {\n _addressData[prevOwnership.addr].balance -= 1;\n _addressData[prevOwnership.addr].numberBurned += 1;\n\n // Keep track of who burned the token, and the timestamp of burning.\n _ownerships[tokenId].addr = prevOwnership.addr;\n _ownerships[tokenId].startTimestamp = uint64(block.timestamp);\n _ownerships[tokenId].burned = true;\n\n // If the ownership slot of tokenId+1 is not explicitly set, that means the burn initiator owns it.\n // Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls.\n uint256 nextTokenId = tokenId + 1;\n if (_ownerships[nextTokenId].addr == address(0)) {\n // This will suffice for checking _exists(nextTokenId),\n // as a burned slot cannot contain the zero address.\n if (nextTokenId \u003c _currentIndex) {\n _ownerships[nextTokenId].addr = prevOwnership.addr;\n _ownerships[nextTokenId].startTimestamp = prevOwnership.startTimestamp;\n }\n }\n }\n\n emit Transfer(prevOwnership.addr, address(0), tokenId);\n _afterTokenTransfers(prevOwnership.addr, address(0), tokenId, 1);\n\n // Overflow not possible, as _burnCounter cannot be exceed _currentIndex times.\n unchecked {\n _burnCounter++;\n }\n }\n\n /**\n * @dev Approve `to` to operate on `tokenId`\n *\n * Emits a {Approval} event.\n */\n function _approve(\n address to,\n uint256 tokenId,\n address owner\n ) private {\n _tokenApprovals[tokenId] = to;\n emit Approval(owner, to, tokenId);\n }\n\n /**\n * @dev See {IERC721Enumerable-tokenByIndex}.\n * This read function is O(totalSupply). If calling from a separate contract, be sure to test gas first.\n * It may also degrade with extremely large collection sizes (e.g \u003e\u003e 10000), test for your use case.\n */\n function tokenByIndex(uint256 index) public view override returns (uint256) {\n uint256 numMintedSoFar = _currentIndex;\n uint256 tokenIdsIdx;\n\n // Counter overflow is impossible as the loop breaks when\n // uint256 i is equal to another uint256 numMintedSoFar.\n unchecked {\n for (uint256 i; i \u003c numMintedSoFar; i++) {\n TokenOwnership memory ownership = _ownerships[i];\n if (!ownership.burned) {\n if (tokenIdsIdx == index) {\n return i;\n }\n tokenIdsIdx++;\n }\n }\n }\n revert TokenIndexOutOfBounds();\n }\n\n /**\n * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.\n * This read function is O(totalSupply). If calling from a separate contract, be sure to test gas first.\n * It may also degrade with extremely large collection sizes (e.g \u003e\u003e 10000), test for your use case.\n */\n function tokenOfOwnerByIndex(address owner, uint256 index) public view override returns (uint256) {\n if (index \u003e= balanceOf(owner)) revert OwnerIndexOutOfBounds();\n uint256 numMintedSoFar = _currentIndex;\n uint256 tokenIdsIdx;\n address currOwnershipAddr;\n\n // Counter overflow is impossible as the loop breaks when\n // uint256 i is equal to another uint256 numMintedSoFar.\n unchecked {\n for (uint256 i; i \u003c numMintedSoFar; i++) {\n TokenOwnership memory ownership = _ownerships[i];\n if (ownership.burned) {\n continue;\n }\n if (ownership.addr != address(0)) {\n currOwnershipAddr = ownership.addr;\n }\n if (currOwnershipAddr == owner) {\n if (tokenIdsIdx == index) {\n return i;\n }\n tokenIdsIdx++;\n }\n }\n }\n\n // Execution should never reach this point.\n revert();\n }\n\n /**\n * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.\n * The call is not executed if the target address is not a contract.\n *\n * @param from address representing the previous owner of the given token ID\n * @param to target address that will receive the tokens\n * @param tokenId uint256 ID of the token to be transferred\n * @param _data bytes optional data to send along with the call\n * @return bool whether the call correctly returned the expected magic value\n */\n function _checkOnERC721Received(\n address from,\n address to,\n uint256 tokenId,\n bytes memory _data\n ) private returns (bool) {\n if (to.isContract()) {\n try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {\n return retval == IERC721Receiver(to).onERC721Received.selector;\n } catch (bytes memory reason) {\n if (reason.length == 0) {\n revert TransferToNonERC721ReceiverImplementer();\n } else {\n assembly {\n revert(add(32, reason), mload(reason))\n }\n }\n }\n } else {\n return true;\n }\n }\n\n /**\n * @dev Hook that is called before a set of serially-ordered token ids are about to be transferred. This includes minting.\n * And also called before burning one token.\n *\n * startTokenId - the first token id to be transferred\n * quantity - the amount to be transferred\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, `from`\u0027s `tokenId` will be\n * transferred to `to`.\n * - When `from` is zero, `tokenId` will be minted for `to`.\n * - When `to` is zero, `tokenId` will be burned by `from`.\n * - `from` and `to` are never both zero.\n */\n function _beforeTokenTransfers(\n address from,\n address to,\n uint256 startTokenId,\n uint256 quantity\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after a set of serially-ordered token ids have been transferred. This includes\n * minting.\n * And also called after one token has been burned.\n *\n * startTokenId - the first token id to be transferred\n * quantity - the amount to be transferred\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, `from`\u0027s `tokenId` has been\n * transferred to `to`.\n * - When `from` is zero, `tokenId` has been minted for `to`.\n * - When `to` is zero, `tokenId` has been burned by `from`.\n * - `from` and `to` are never both zero.\n */\n function _afterTokenTransfers(\n address from,\n address to,\n uint256 startTokenId,\n uint256 quantity\n ) internal virtual {}\n}\n"},"IAccessControl.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``\u0027s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n *\n * _Available since v3.1._\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role\u0027s admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``\u0027s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``\u0027s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function\u0027s\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `account`.\n */\n function renounceRole(bytes32 role, address account) external;\n}\n"},"IERC165.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n"},"IERC721.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n /**\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returns the number of tokens in ``owner``\u0027s account.\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Transfers `tokenId` token from `from` to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool _approved) external;\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes calldata data\n ) external;\n}\n"},"IERC721Enumerable.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC721.sol\";\n\n/**\n * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n */\ninterface IERC721Enumerable is IERC721 {\n /**\n * @dev Returns the total amount of tokens stored by the contract.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns a token ID owned by `owner` at a given `index` of its token list.\n * Use along with {balanceOf} to enumerate all of ``owner``\u0027s tokens.\n */\n function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256);\n\n /**\n * @dev Returns a token ID at a given `index` of all the tokens stored by the contract.\n * Use along with {totalSupply} to enumerate all tokens.\n */\n function tokenByIndex(uint256 index) external view returns (uint256);\n}\n"},"IERC721Metadata.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC721.sol\";\n\n/**\n * @title ERC-721 Non-Fungible Token Standard, optional metadata extension\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n */\ninterface IERC721Metadata is IERC721 {\n /**\n * @dev Returns the token collection name.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the token collection symbol.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\n */\n function tokenURI(uint256 tokenId) external view returns (string memory);\n}\n"},"IERC721Receiver.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC721 token receiver interface\n * @dev Interface for any contract that wants to support safeTransfers\n * from ERC721 asset contracts.\n */\ninterface IERC721Receiver {\n /**\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\n * by `operator` from `from`, this function is called.\n *\n * It must return its Solidity selector to confirm the token transfer.\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\n *\n * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.\n */\n function onERC721Received(\n address operator,\n address from,\n uint256 tokenId,\n bytes calldata data\n ) external returns (bytes4);\n}\n"},"NFT.sol":{"content":"// SPDX-License-Identifier: UNLICENSED\npragma solidity 0.8.13;\n\nimport \"./ERC721A.sol\";\nimport \"./Reveal.sol\";\nimport \"./AccessControl.sol\";\nimport \"./Ownable.sol\";\n\n/**\n * @title The NFT smart contract.\n */\ncontract NFT is ERC721A, AccessControl, Ownable, Reveal {\n /// @notice Minter Access Role - allows users and smart contracts with this role to mint standard tokens (not reserves).\n bytes32 public constant MINTER_ROLE = keccak256(\"MINTER_ROLE\");\n /// @notice The amount of available NFT tokens (including the reserved tokens).\n uint256 public MAX_SUPPLY;\n /// @notice The amount of reserved NFT tokens.\n uint256 public MAX_RESERVED_SUPPLY;\n /// @notice Indicates if the reserves have been minted.\n bool public preminted = false;\n\n /**\n * @notice The smart contract constructor that initializes the contract.\n * @param tokenName The name of the token.\n * @param tokenSymbol The symbol of the token.\n * @param unrevealedUri The URL of a media that is shown for unrevealed NFTs.\n * @param maxSupply The total amount of available NFT tokens (including the reserved tokens).\n * @param maxReservedSupply The amount of reserved NFT tokens.\n */\n constructor(\n string memory tokenName,\n string memory tokenSymbol,\n string memory unrevealedUri,\n uint256 maxSupply,\n uint256 maxReservedSupply\n )\n ERC721A(tokenName, tokenSymbol)\n Reveal(unrevealedUri) {\n // Set the roles.\n _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);\n _grantRole(MINTER_ROLE, msg.sender);\n // Set the variables.\n MAX_SUPPLY = maxSupply;\n MAX_RESERVED_SUPPLY = maxReservedSupply;\n }\n\n /**\n * @notice Sets the total amounts of tokens.\n * @param quantity The number of tokens to set.\n */\n function setMaxSupply(uint256 quantity) external onlyRole(DEFAULT_ADMIN_ROLE) {\n require(quantity \u003e 0, \"Quantity must be greater than 0\");\n MAX_SUPPLY = quantity;\n }\n\n /**\n * @notice Mints the reserved NFT tokens.\n * @param recipient The NFT tokens recipient.\n * @param quantity The number of NFT tokens to mint.\n */\n function premint(address recipient, uint256 quantity) external onlyRole(DEFAULT_ADMIN_ROLE) {\n // Check if there are any reserved tokens available to mint.\n require(preminted == false, \"Reserved tokens minted already\");\n // Check if the desired quantity of the reserved tokens to mint doesn\u0027t exceed the reserve.\n require(totalSupply() + quantity \u003c= MAX_RESERVED_SUPPLY, \"MAX_RESERVED_SUPPLY exceeded\");\n // Mint the tokens.\n _safeMint(recipient, quantity);\n // Set the flag only if we have minted the whole reserve.\n preminted = totalSupply() == MAX_RESERVED_SUPPLY;\n }\n\n /**\n * @notice Grants the specified address the minter role.\n * @param mintingRouter The address to grant the minter role.\n */\n function setMinter(address mintingRouter) external onlyRole(DEFAULT_ADMIN_ROLE) {\n _setupRole(MINTER_ROLE, mintingRouter);\n }\n\n /**\n * @notice Mints the NFT tokens.\n * @param recipient The NFT tokens recipient.\n * @param quantity The number of NFT tokens to mint.\n */\n function mint(address recipient, uint256 quantity) external onlyRole(MINTER_ROLE) {\n // Reserves should be minted before minting standard tokens.\n require(preminted == true, \"TEAM_RESERVE_NOT_PREMINTED_YET\");\n // Check that the number of tokens to mint does not exceed the total amount.\n require(totalSupply() + quantity \u003c= MAX_SUPPLY, \"Exceeds max supply\");\n // Mint the tokens.\n _safeMint(recipient, quantity);\n }\n\n /**\n * @notice Burns the NFT tokens.\n * @param tokenIds The IDs of the NFTs to burn.\n */\n function burnTokens(uint256[] calldata tokenIds) external {\n for (uint i = 0; i \u003c tokenIds.length; i++) {\n TokenOwnership memory ownership = ownershipOf(tokenIds[i]);\n if (ownership.addr != _msgSender() || ownership.burned) {\n revert(\"Not owner or already burned\");\n }\n\n _burn(tokenIds[i]);\n }\n }\n\n /**\n * @notice Returns a URI of an NFT.\n * @param tokenId The ID of the NFT.\n * @return The URI of the token.\n */\n function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {\n if (!_exists(tokenId)) revert URIQueryForNonexistentToken();\n\n return getTokenUri(tokenId);\n }\n\n /**\n * @notice Returns true if this contract implements the interface defined by interfaceId.\n * @dev The following functions are overrides required by Solidity.\n * @param interfaceId The interface ID.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721A, AccessControl) returns (bool) {\n return super.supportsInterface(interfaceId);\n }\n\n /**\n * @notice Returns the base URL.\n */\n function _baseURI() internal view override returns (string memory) {\n return getBaseUri();\n }\n}\n"},"Ownable.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n constructor() {\n _transferOwnership(_msgSender());\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n _;\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions anymore. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby removing any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n"},"Reveal.sol":{"content":"// SPDX-License-Identifier: UNLICENSED\npragma solidity 0.8.13;\n\nimport \"./Strings.sol\";\nimport \"./AccessControl.sol\";\n\n/// @title The NFT reveal contract.\ncontract Reveal is AccessControl {\n using Strings for uint256;\n // The base URI.\n string private baseUri = \"ipfs://none\";\n // The URI that used until NFTs are revealed.\n string private unrevealedUri;\n // The flag that indicates if NFTs have been revealed.\n bool public revealed = false;\n\n constructor(string memory _unrevealedUri) {\n unrevealedUri = _unrevealedUri;\n }\n\n /// Reveals the NFTs.\n function reveal() external onlyRole(DEFAULT_ADMIN_ROLE) {\n revealed = true;\n }\n\n /// Unreveals the NFTs.\n function unreveal() external onlyRole(DEFAULT_ADMIN_ROLE) {\n revealed = false;\n }\n\n /// Sets base URI that is used when NFTs are revealed.\n function setBaseUri(string memory uri) external onlyRole(DEFAULT_ADMIN_ROLE) {\n baseUri = uri;\n revealed = true;\n }\n\n /// Sets URI to be used while NFTs are unrevealed.\n function setUnrevealedUri(string memory uri) external onlyRole(DEFAULT_ADMIN_ROLE) {\n unrevealedUri = uri;\n }\n\n /// Gets the base URI.\n function getBaseUri() public view returns (string memory) {\n return baseUri;\n }\n\n /// Gets a token URI.\n function getTokenUri(uint256 tokenId) internal view returns (string memory) {\n if (!revealed) {\n return unrevealedUri;\n }\n\n return bytes(baseUri).length != 0 ? string(abi.encodePacked(baseUri, tokenId.toString())) : \"\";\n }\n}"},"Strings.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n bytes16 private constant _HEX_SYMBOLS = \"0123456789abcdef\";\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n // Inspired by OraclizeAPI\u0027s implementation - MIT licence\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n if (value == 0) {\n return \"0\";\n }\n uint256 temp = value;\n uint256 digits;\n while (temp != 0) {\n digits++;\n temp /= 10;\n }\n bytes memory buffer = new bytes(digits);\n while (value != 0) {\n digits -= 1;\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n value /= 10;\n }\n return string(buffer);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n if (value == 0) {\n return \"0x00\";\n }\n uint256 temp = value;\n uint256 length = 0;\n while (temp != 0) {\n length++;\n temp \u003e\u003e= 8;\n }\n return toHexString(value, length);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i \u003e 1; --i) {\n buffer[i] = _HEX_SYMBOLS[value \u0026 0xf];\n value \u003e\u003e= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\n return string(buffer);\n }\n}\n"}}