Transaction Hash:
Block:
16141365 at Dec-08-2022 05:04:47 PM +UTC
Transaction Fee:
0.001136659867681085 ETH
$2.36
Gas Used:
46,591 Gas / 24.396554435 Gwei
Emitted Events:
| 240 |
TheSanctum_Neophytes.ApprovalForAll( owner=[Sender] 0x3d854cc95c0cbfb4d6bfae2ae2e4c26f3a63d1da, operator=0x1E004978...d54003c71, approved=True )
|
Account State Difference:
| Address | Before | After | State Difference | ||
|---|---|---|---|---|---|
|
0x388C818C...7ccB19297
Miner
| (Lido: Execution Layer Rewards Vault) | 39.156480437613600504 Eth | 39.156550324113600504 Eth | 0.0000698865 | |
| 0x3D854cc9...f3A63d1dA |
1.429880496028143872 Eth
Nonce: 1054
|
1.428743836160462787 Eth
Nonce: 1055
| 0.001136659867681085 | ||
| 0xB5128894...7A245B7aE |
Execution Trace
TheSanctum_Neophytes.setApprovalForAll( operator=0x1E0049783F008A0085193E00003D00cd54003c71, approved=True )
{"Context.sol":{"content":"// SPDX-License-Identifier: MIT\r\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\r\n\r\npragma solidity ^0.8.0;\r\n\r\n/**\r\n * @dev Provides information about the current execution context, including the\r\n * sender of the transaction and its data. While these are generally available\r\n * via msg.sender and msg.data, they should not be accessed in such a direct\r\n * manner, since when dealing with meta-transactions the account sending and\r\n * paying for execution may not be the actual sender (as far as an application\r\n * is concerned).\r\n *\r\n * This contract is only required for intermediate, library-like contracts.\r\n */\r\nabstract contract Context {\r\n function _msgSender() internal view virtual returns (address) {\r\n return msg.sender;\r\n }\r\n\r\n function _msgData() internal view virtual returns (bytes calldata) {\r\n return msg.data;\r\n }\r\n}"},"DefaultOperatorFilterer.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\nimport {OperatorFilterer} from \"./OperatorFilterer.sol\";\n\nabstract contract DefaultOperatorFilterer is OperatorFilterer {\n address constant DEFAULT_SUBSCRIPTION = address(0x3cc6CddA760b79bAfa08dF41ECFA224f810dCeB6);\n\n constructor() OperatorFilterer(DEFAULT_SUBSCRIPTION, true) {}\n}\n"},"EnumerableSet.sol":{"content":"// SPDX-License-Identifier: MIT\r\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/structs/EnumerableSet.sol)\r\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\r\n\r\n// OpenZeppelin Contracts (last updated v4.8.0) (access/Ownable2Step.sol)\r\n\r\npragma solidity ^0.8.0;\r\n\r\nimport \"./Ownable.sol\";\r\n\r\n/**\r\n * @dev Contract module which provides access control mechanism, where\r\n * there is an account (an owner) that can be granted exclusive access to\r\n * specific functions.\r\n *\r\n * By default, the owner account will be the one that deploys the contract. This\r\n * can later be changed with {transferOwnership} and {acceptOwnership}.\r\n *\r\n * This module is used through inheritance. It will make available all functions\r\n * from parent (Ownable).\r\n */\r\nabstract contract Ownable2Step is Ownable {\r\n address private _pendingOwner;\r\n\r\n event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);\r\n\r\n /**\r\n * @dev Returns the address of the pending owner.\r\n */\r\n function pendingOwner() public view virtual returns (address) {\r\n return _pendingOwner;\r\n }\r\n\r\n /**\r\n * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.\r\n * Can only be called by the current owner.\r\n */\r\n function transferOwnership(address newOwner) public virtual override onlyOwner {\r\n _pendingOwner = newOwner;\r\n emit OwnershipTransferStarted(owner(), newOwner);\r\n }\r\n\r\n /**\r\n * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.\r\n * Internal function without access restriction.\r\n */\r\n function _transferOwnership(address newOwner) internal virtual override {\r\n delete _pendingOwner;\r\n super._transferOwnership(newOwner);\r\n }\r\n\r\n /**\r\n * @dev The new owner accepts the ownership transfer.\r\n */\r\n function acceptOwnership() external {\r\n address sender = _msgSender();\r\n require(pendingOwner() == sender, \"Ownable2Step: caller is not the new owner\");\r\n _transferOwnership(sender);\r\n }\r\n}\r\npragma solidity ^0.8.0;\r\n\r\n/**\r\n * @dev Library for managing\r\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\r\n * types.\r\n *\r\n * Sets have the following properties:\r\n *\r\n * - Elements are added, removed, and checked for existence in constant time\r\n * (O(1)).\r\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\r\n *\r\n * ```\r\n * contract Example {\r\n * // Add the library methods\r\n * using EnumerableSet for EnumerableSet.AddressSet;\r\n *\r\n * // Declare a set state variable\r\n * EnumerableSet.AddressSet private mySet;\r\n * }\r\n * ```\r\n *\r\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\r\n * and `uint256` (`UintSet`) are supported.\r\n *\r\n * [WARNING]\r\n * ====\r\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\r\n * unusable.\r\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\r\n *\r\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\r\n * array of EnumerableSet.\r\n * ====\r\n */\r\nlibrary EnumerableSet {\r\n // To implement this library for multiple types with as little code\r\n // repetition as possible, we write it in terms of a generic Set type with\r\n // bytes32 values.\r\n // The Set implementation uses private functions, and user-facing\r\n // implementations (such as AddressSet) are just wrappers around the\r\n // underlying Set.\r\n // This means that we can only create new EnumerableSets for types that fit\r\n // in bytes32.\r\n\r\n struct Set {\r\n // Storage of set values\r\n bytes32[] _values;\r\n // Position of the value in the `values` array, plus 1 because index 0\r\n // means a value is not in the set.\r\n mapping(bytes32 =\u003e uint256) _indexes;\r\n }\r\n\r\n /**\r\n * @dev Add a value to a set. O(1).\r\n *\r\n * Returns true if the value was added to the set, that is if it was not\r\n * already present.\r\n */\r\n function _add(Set storage set, bytes32 value) private returns (bool) {\r\n if (!_contains(set, value)) {\r\n set._values.push(value);\r\n // The value is stored at length-1, but we add 1 to all indexes\r\n // and use 0 as a sentinel value\r\n set._indexes[value] = set._values.length;\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n }\r\n\r\n /**\r\n * @dev Removes a value from a set. O(1).\r\n *\r\n * Returns true if the value was removed from the set, that is if it was\r\n * present.\r\n */\r\n function _remove(Set storage set, bytes32 value) private returns (bool) {\r\n // We read and store the value\u0027s index to prevent multiple reads from the same storage slot\r\n uint256 valueIndex = set._indexes[value];\r\n\r\n if (valueIndex != 0) {\r\n // Equivalent to contains(set, value)\r\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\r\n // the array, and then remove the last element (sometimes called as \u0027swap and pop\u0027).\r\n // This modifies the order of the array, as noted in {at}.\r\n\r\n uint256 toDeleteIndex = valueIndex - 1;\r\n uint256 lastIndex = set._values.length - 1;\r\n\r\n if (lastIndex != toDeleteIndex) {\r\n bytes32 lastValue = set._values[lastIndex];\r\n\r\n // Move the last value to the index where the value to delete is\r\n set._values[toDeleteIndex] = lastValue;\r\n // Update the index for the moved value\r\n set._indexes[lastValue] = valueIndex; // Replace lastValue\u0027s index to valueIndex\r\n }\r\n\r\n // Delete the slot where the moved value was stored\r\n set._values.pop();\r\n\r\n // Delete the index for the deleted slot\r\n delete set._indexes[value];\r\n\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n }\r\n\r\n /**\r\n * @dev Returns true if the value is in the set. O(1).\r\n */\r\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\r\n return set._indexes[value] != 0;\r\n }\r\n\r\n /**\r\n * @dev Returns the number of values on the set. O(1).\r\n */\r\n function _length(Set storage set) private view returns (uint256) {\r\n return set._values.length;\r\n }\r\n\r\n /**\r\n * @dev Returns the value stored at position `index` in the set. O(1).\r\n *\r\n * Note that there are no guarantees on the ordering of values inside the\r\n * array, and it may change when more values are added or removed.\r\n *\r\n * Requirements:\r\n *\r\n * - `index` must be strictly less than {length}.\r\n */\r\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\r\n return set._values[index];\r\n }\r\n\r\n /**\r\n * @dev Return the entire set in an array\r\n *\r\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\r\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\r\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\r\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\r\n */\r\n function _values(Set storage set) private view returns (bytes32[] memory) {\r\n return set._values;\r\n }\r\n\r\n // Bytes32Set\r\n\r\n struct Bytes32Set {\r\n Set _inner;\r\n }\r\n\r\n /**\r\n * @dev Add a value to a set. O(1).\r\n *\r\n * Returns true if the value was added to the set, that is if it was not\r\n * already present.\r\n */\r\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\r\n return _add(set._inner, value);\r\n }\r\n\r\n /**\r\n * @dev Removes a value from a set. O(1).\r\n *\r\n * Returns true if the value was removed from the set, that is if it was\r\n * present.\r\n */\r\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\r\n return _remove(set._inner, value);\r\n }\r\n\r\n /**\r\n * @dev Returns true if the value is in the set. O(1).\r\n */\r\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\r\n return _contains(set._inner, value);\r\n }\r\n\r\n /**\r\n * @dev Returns the number of values in the set. O(1).\r\n */\r\n function length(Bytes32Set storage set) internal view returns (uint256) {\r\n return _length(set._inner);\r\n }\r\n\r\n /**\r\n * @dev Returns the value stored at position `index` in the set. O(1).\r\n *\r\n * Note that there are no guarantees on the ordering of values inside the\r\n * array, and it may change when more values are added or removed.\r\n *\r\n * Requirements:\r\n *\r\n * - `index` must be strictly less than {length}.\r\n */\r\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\r\n return _at(set._inner, index);\r\n }\r\n\r\n /**\r\n * @dev Return the entire set in an array\r\n *\r\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\r\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\r\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\r\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\r\n */\r\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\r\n bytes32[] memory store = _values(set._inner);\r\n bytes32[] memory result;\r\n\r\n /// @solidity memory-safe-assembly\r\n assembly {\r\n result := store\r\n }\r\n\r\n return result;\r\n }\r\n\r\n // AddressSet\r\n\r\n struct AddressSet {\r\n Set _inner;\r\n }\r\n\r\n /**\r\n * @dev Add a value to a set. O(1).\r\n *\r\n * Returns true if the value was added to the set, that is if it was not\r\n * already present.\r\n */\r\n function add(AddressSet storage set, address value) internal returns (bool) {\r\n return _add(set._inner, bytes32(uint256(uint160(value))));\r\n }\r\n\r\n /**\r\n * @dev Removes a value from a set. O(1).\r\n *\r\n * Returns true if the value was removed from the set, that is if it was\r\n * present.\r\n */\r\n function remove(AddressSet storage set, address value) internal returns (bool) {\r\n return _remove(set._inner, bytes32(uint256(uint160(value))));\r\n }\r\n\r\n /**\r\n * @dev Returns true if the value is in the set. O(1).\r\n */\r\n function contains(AddressSet storage set, address value) internal view returns (bool) {\r\n return _contains(set._inner, bytes32(uint256(uint160(value))));\r\n }\r\n\r\n /**\r\n * @dev Returns the number of values in the set. O(1).\r\n */\r\n function length(AddressSet storage set) internal view returns (uint256) {\r\n return _length(set._inner);\r\n }\r\n\r\n /**\r\n * @dev Returns the value stored at position `index` in the set. O(1).\r\n *\r\n * Note that there are no guarantees on the ordering of values inside the\r\n * array, and it may change when more values are added or removed.\r\n *\r\n * Requirements:\r\n *\r\n * - `index` must be strictly less than {length}.\r\n */\r\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\r\n return address(uint160(uint256(_at(set._inner, index))));\r\n }\r\n\r\n /**\r\n * @dev Return the entire set in an array\r\n *\r\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\r\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\r\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\r\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\r\n */\r\n function values(AddressSet storage set) internal view returns (address[] memory) {\r\n bytes32[] memory store = _values(set._inner);\r\n address[] memory result;\r\n\r\n /// @solidity memory-safe-assembly\r\n assembly {\r\n result := store\r\n }\r\n\r\n return result;\r\n }\r\n\r\n // UintSet\r\n\r\n struct UintSet {\r\n Set _inner;\r\n }\r\n\r\n /**\r\n * @dev Add a value to a set. O(1).\r\n *\r\n * Returns true if the value was added to the set, that is if it was not\r\n * already present.\r\n */\r\n function add(UintSet storage set, uint256 value) internal returns (bool) {\r\n return _add(set._inner, bytes32(value));\r\n }\r\n\r\n /**\r\n * @dev Removes a value from a set. O(1).\r\n *\r\n * Returns true if the value was removed from the set, that is if it was\r\n * present.\r\n */\r\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\r\n return _remove(set._inner, bytes32(value));\r\n }\r\n\r\n /**\r\n * @dev Returns true if the value is in the set. O(1).\r\n */\r\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\r\n return _contains(set._inner, bytes32(value));\r\n }\r\n\r\n /**\r\n * @dev Returns the number of values in the set. O(1).\r\n */\r\n function length(UintSet storage set) internal view returns (uint256) {\r\n return _length(set._inner);\r\n }\r\n\r\n /**\r\n * @dev Returns the value stored at position `index` in the set. O(1).\r\n *\r\n * Note that there are no guarantees on the ordering of values inside the\r\n * array, and it may change when more values are added or removed.\r\n *\r\n * Requirements:\r\n *\r\n * - `index` must be strictly less than {length}.\r\n */\r\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\r\n return uint256(_at(set._inner, index));\r\n }\r\n\r\n /**\r\n * @dev Return the entire set in an array\r\n *\r\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\r\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\r\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\r\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\r\n */\r\n function values(UintSet storage set) internal view returns (uint256[] memory) {\r\n bytes32[] memory store = _values(set._inner);\r\n uint256[] memory result;\r\n\r\n /// @solidity memory-safe-assembly\r\n assembly {\r\n result := store\r\n }\r\n\r\n return result;\r\n }\r\n}"},"ERC721A.sol":{"content":"// SPDX-License-Identifier: MIT\r\n// ERC721A Contracts v4.2.3\r\n// Creator: Chiru Labs\r\n\r\npragma solidity ^0.8.4;\r\n\r\nimport \u0027./IERC721A.sol\u0027;\r\nimport \u0027./DefaultOperatorFilterer.sol\u0027;\r\n/**\r\n * @dev Interface of ERC721 token receiver.\r\n */\r\ninterface ERC721A__IERC721Receiver {\r\n function onERC721Received(\r\n address operator,\r\n address from,\r\n uint256 tokenId,\r\n bytes calldata data\r\n ) external returns (bytes4);\r\n}\r\n\r\n/**\r\n * @title ERC721A\r\n *\r\n * @dev Implementation of the [ERC721](https://eips.ethereum.org/EIPS/eip-721)\r\n * Non-Fungible Token Standard, including the Metadata extension.\r\n * Optimized for lower gas during batch mints.\r\n *\r\n * Token IDs are minted in sequential order (e.g. 0, 1, 2, 3, ...)\r\n * starting from `_startTokenId()`.\r\n *\r\n * Assumptions:\r\n *\r\n * - An owner cannot have more than 2**64 - 1 (max value of uint64) of supply.\r\n * - The maximum token ID cannot exceed 2**256 - 1 (max value of uint256).\r\n */\r\ncontract ERC721A is IERC721A, DefaultOperatorFilterer {\r\n // Bypass for a `--via-ir` bug (https://github.com/chiru-labs/ERC721A/pull/364).\r\n struct TokenApprovalRef {\r\n address value;\r\n }\r\n\r\n // =============================================================\r\n // CONSTANTS\r\n // =============================================================\r\n\r\n // Mask of an entry in packed address data.\r\n uint256 private constant _BITMASK_ADDRESS_DATA_ENTRY = (1 \u003c\u003c 64) - 1;\r\n\r\n // The bit position of `numberMinted` in packed address data.\r\n uint256 private constant _BITPOS_NUMBER_MINTED = 64;\r\n\r\n // The bit position of `numberBurned` in packed address data.\r\n uint256 private constant _BITPOS_NUMBER_BURNED = 128;\r\n\r\n // The bit position of `aux` in packed address data.\r\n uint256 private constant _BITPOS_AUX = 192;\r\n\r\n // Mask of all 256 bits in packed address data except the 64 bits for `aux`.\r\n uint256 private constant _BITMASK_AUX_COMPLEMENT = (1 \u003c\u003c 192) - 1;\r\n\r\n // The bit position of `startTimestamp` in packed ownership.\r\n uint256 private constant _BITPOS_START_TIMESTAMP = 160;\r\n\r\n // The bit mask of the `burned` bit in packed ownership.\r\n uint256 private constant _BITMASK_BURNED = 1 \u003c\u003c 224;\r\n\r\n // The bit position of the `nextInitialized` bit in packed ownership.\r\n uint256 private constant _BITPOS_NEXT_INITIALIZED = 225;\r\n\r\n // The bit mask of the `nextInitialized` bit in packed ownership.\r\n uint256 private constant _BITMASK_NEXT_INITIALIZED = 1 \u003c\u003c 225;\r\n\r\n // The bit position of `extraData` in packed ownership.\r\n uint256 private constant _BITPOS_EXTRA_DATA = 232;\r\n\r\n // Mask of all 256 bits in a packed ownership except the 24 bits for `extraData`.\r\n uint256 private constant _BITMASK_EXTRA_DATA_COMPLEMENT = (1 \u003c\u003c 232) - 1;\r\n\r\n // The mask of the lower 160 bits for addresses.\r\n uint256 private constant _BITMASK_ADDRESS = (1 \u003c\u003c 160) - 1;\r\n\r\n // The maximum `quantity` that can be minted with {_mintERC2309}.\r\n // This limit is to prevent overflows on the address data entries.\r\n // For a limit of 5000, a total of 3.689e15 calls to {_mintERC2309}\r\n // is required to cause an overflow, which is unrealistic.\r\n uint256 private constant _MAX_MINT_ERC2309_QUANTITY_LIMIT = 5000;\r\n\r\n // The `Transfer` event signature is given by:\r\n // `keccak256(bytes(\"Transfer(address,address,uint256)\"))`.\r\n bytes32 private constant _TRANSFER_EVENT_SIGNATURE =\r\n 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef;\r\n\r\n // =============================================================\r\n // STORAGE\r\n // =============================================================\r\n\r\n // The next token ID to be minted.\r\n uint256 private _currentIndex;\r\n\r\n // The number of tokens burned.\r\n uint256 private _burnCounter;\r\n\r\n // Token name\r\n string private _name;\r\n\r\n // Token symbol\r\n string private _symbol;\r\n\r\n // Mapping from token ID to ownership details\r\n // An empty struct value does not necessarily mean the token is unowned.\r\n // See {_packedOwnershipOf} implementation for details.\r\n //\r\n // Bits Layout:\r\n // - [0..159] `addr`\r\n // - [160..223] `startTimestamp`\r\n // - [224] `burned`\r\n // - [225] `nextInitialized`\r\n // - [232..255] `extraData`\r\n mapping(uint256 =\u003e uint256) private _packedOwnerships;\r\n\r\n // Mapping owner address to address data.\r\n //\r\n // Bits Layout:\r\n // - [0..63] `balance`\r\n // - [64..127] `numberMinted`\r\n // - [128..191] `numberBurned`\r\n // - [192..255] `aux`\r\n mapping(address =\u003e uint256) private _packedAddressData;\r\n\r\n // Mapping from token ID to approved address.\r\n mapping(uint256 =\u003e TokenApprovalRef) private _tokenApprovals;\r\n\r\n // Mapping from owner to operator approvals\r\n mapping(address =\u003e mapping(address =\u003e bool)) private _operatorApprovals;\r\n\r\n // =============================================================\r\n // CONSTRUCTOR\r\n // =============================================================\r\n\r\n constructor(string memory name_, string memory symbol_) {\r\n _name = name_;\r\n _symbol = symbol_;\r\n _currentIndex = _startTokenId();\r\n }\r\n\r\n // =============================================================\r\n // TOKEN COUNTING OPERATIONS\r\n // =============================================================\r\n\r\n /**\r\n * @dev Returns the starting token ID.\r\n * To change the starting token ID, please override this function.\r\n */\r\n function _startTokenId() internal view virtual returns (uint256) {\r\n return 1;\r\n }\r\n\r\n /**\r\n * @dev Returns the next token ID to be minted.\r\n */\r\n function _nextTokenId() internal view virtual returns (uint256) {\r\n return _currentIndex;\r\n }\r\n\r\n /**\r\n * @dev Returns the total number of tokens in existence.\r\n * Burned tokens will reduce the count.\r\n * To get the total number of tokens minted, please see {_totalMinted}.\r\n */\r\n function totalSupply() public view virtual override returns (uint256) {\r\n // Counter underflow is impossible as _burnCounter cannot be incremented\r\n // more than `_currentIndex - _startTokenId()` times.\r\n unchecked {\r\n return _currentIndex - _burnCounter - _startTokenId();\r\n }\r\n }\r\n\r\n /**\r\n * @dev Returns the total amount of tokens minted in the contract.\r\n */\r\n function _totalMinted() internal view virtual returns (uint256) {\r\n // Counter underflow is impossible as `_currentIndex` does not decrement,\r\n // and it is initialized to `_startTokenId()`.\r\n unchecked {\r\n return _currentIndex - _startTokenId();\r\n }\r\n }\r\n\r\n /**\r\n * @dev Returns the total number of tokens burned.\r\n */\r\n function _totalBurned() internal view virtual returns (uint256) {\r\n return _burnCounter;\r\n }\r\n\r\n // =============================================================\r\n // ADDRESS DATA OPERATIONS\r\n // =============================================================\r\n\r\n /**\r\n * @dev Returns the number of tokens in `owner`\u0027s account.\r\n */\r\n function balanceOf(address owner) public view virtual override returns (uint256) {\r\n if (owner == address(0)) revert BalanceQueryForZeroAddress();\r\n return _packedAddressData[owner] \u0026 _BITMASK_ADDRESS_DATA_ENTRY;\r\n }\r\n\r\n /**\r\n * Returns the number of tokens minted by `owner`.\r\n */\r\n function _numberMinted(address owner) internal view returns (uint256) {\r\n return (_packedAddressData[owner] \u003e\u003e _BITPOS_NUMBER_MINTED) \u0026 _BITMASK_ADDRESS_DATA_ENTRY;\r\n }\r\n\r\n /**\r\n * Returns the number of tokens burned by or on behalf of `owner`.\r\n */\r\n function _numberBurned(address owner) internal view returns (uint256) {\r\n return (_packedAddressData[owner] \u003e\u003e _BITPOS_NUMBER_BURNED) \u0026 _BITMASK_ADDRESS_DATA_ENTRY;\r\n }\r\n\r\n /**\r\n * Returns the auxiliary data for `owner`. (e.g. number of whitelist mint slots used).\r\n */\r\n function _getAux(address owner) internal view returns (uint64) {\r\n return uint64(_packedAddressData[owner] \u003e\u003e _BITPOS_AUX);\r\n }\r\n\r\n /**\r\n * Sets the auxiliary data for `owner`. (e.g. number of whitelist mint slots used).\r\n * If there are multiple variables, please pack them into a uint64.\r\n */\r\n function _setAux(address owner, uint64 aux) internal virtual {\r\n uint256 packed = _packedAddressData[owner];\r\n uint256 auxCasted;\r\n // Cast `aux` with assembly to avoid redundant masking.\r\n assembly {\r\n auxCasted := aux\r\n }\r\n packed = (packed \u0026 _BITMASK_AUX_COMPLEMENT) | (auxCasted \u003c\u003c _BITPOS_AUX);\r\n _packedAddressData[owner] = packed;\r\n }\r\n\r\n // =============================================================\r\n // IERC165\r\n // =============================================================\r\n\r\n /**\r\n * @dev Returns true if this contract implements the interface defined by\r\n * `interfaceId`. See the corresponding\r\n * [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified)\r\n * to learn more about how these ids are created.\r\n *\r\n * This function call must use less than 30000 gas.\r\n */\r\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\r\n // The interface IDs are constants representing the first 4 bytes\r\n // of the XOR of all function selectors in the interface.\r\n // See: [ERC165](https://eips.ethereum.org/EIPS/eip-165)\r\n // (e.g. `bytes4(i.functionA.selector ^ i.functionB.selector ^ ...)`)\r\n return\r\n interfaceId == 0x01ffc9a7 || // ERC165 interface ID for ERC165.\r\n interfaceId == 0x80ac58cd || // ERC165 interface ID for ERC721.\r\n interfaceId == 0x5b5e139f; // ERC165 interface ID for ERC721Metadata.\r\n }\r\n\r\n // =============================================================\r\n // IERC721Metadata\r\n // =============================================================\r\n\r\n /**\r\n * @dev Returns the token collection name.\r\n */\r\n function name() public view virtual override returns (string memory) {\r\n return _name;\r\n }\r\n\r\n /**\r\n * @dev Returns the token collection symbol.\r\n */\r\n function symbol() public view virtual override returns (string memory) {\r\n return _symbol;\r\n }\r\n\r\n /**\r\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\r\n */\r\n function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {\r\n if (!_exists(tokenId)) revert URIQueryForNonexistentToken();\r\n\r\n string memory baseURI = _baseURI();\r\n return bytes(baseURI).length != 0 ? string(abi.encodePacked(baseURI, _toString(tokenId))) : \u0027\u0027;\r\n }\r\n\r\n /**\r\n * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each\r\n * token will be the concatenation of the `baseURI` and the `tokenId`. Empty\r\n * by default, it can be overridden in child contracts.\r\n */\r\n function _baseURI() internal view virtual returns (string memory) {\r\n return \u0027\u0027;\r\n }\r\n\r\n // =============================================================\r\n // OWNERSHIPS OPERATIONS\r\n // =============================================================\r\n\r\n /**\r\n * @dev Returns the owner of the `tokenId` token.\r\n *\r\n * Requirements:\r\n *\r\n * - `tokenId` must exist.\r\n */\r\n function ownerOf(uint256 tokenId) public view virtual override returns (address) {\r\n return address(uint160(_packedOwnershipOf(tokenId)));\r\n }\r\n\r\n /**\r\n * @dev Gas spent here starts off proportional to the maximum mint batch size.\r\n * It gradually moves to O(1) as tokens get transferred around over time.\r\n */\r\n function _ownershipOf(uint256 tokenId) internal view virtual returns (TokenOwnership memory) {\r\n return _unpackedOwnership(_packedOwnershipOf(tokenId));\r\n }\r\n\r\n /**\r\n * @dev Returns the unpacked `TokenOwnership` struct at `index`.\r\n */\r\n function _ownershipAt(uint256 index) internal view virtual returns (TokenOwnership memory) {\r\n return _unpackedOwnership(_packedOwnerships[index]);\r\n }\r\n\r\n /**\r\n * @dev Initializes the ownership slot minted at `index` for efficiency purposes.\r\n */\r\n function _initializeOwnershipAt(uint256 index) internal virtual {\r\n if (_packedOwnerships[index] == 0) {\r\n _packedOwnerships[index] = _packedOwnershipOf(index);\r\n }\r\n }\r\n\r\n /**\r\n * Returns the packed ownership data of `tokenId`.\r\n */\r\n function _packedOwnershipOf(uint256 tokenId) private view returns (uint256) {\r\n uint256 curr = tokenId;\r\n\r\n unchecked {\r\n if (_startTokenId() \u003c= curr)\r\n if (curr \u003c _currentIndex) {\r\n uint256 packed = _packedOwnerships[curr];\r\n // If not burned.\r\n if (packed \u0026 _BITMASK_BURNED == 0) {\r\n // Invariant:\r\n // There will always be an initialized ownership slot\r\n // (i.e. `ownership.addr != address(0) \u0026\u0026 ownership.burned == false`)\r\n // before an unintialized ownership slot\r\n // (i.e. `ownership.addr == address(0) \u0026\u0026 ownership.burned == false`)\r\n // Hence, `curr` will not underflow.\r\n //\r\n // We can directly compare the packed value.\r\n // If the address is zero, packed will be zero.\r\n while (packed == 0) {\r\n packed = _packedOwnerships[--curr];\r\n }\r\n return packed;\r\n }\r\n }\r\n }\r\n revert OwnerQueryForNonexistentToken();\r\n }\r\n\r\n /**\r\n * @dev Returns the unpacked `TokenOwnership` struct from `packed`.\r\n */\r\n function _unpackedOwnership(uint256 packed) private pure returns (TokenOwnership memory ownership) {\r\n ownership.addr = address(uint160(packed));\r\n ownership.startTimestamp = uint64(packed \u003e\u003e _BITPOS_START_TIMESTAMP);\r\n ownership.burned = packed \u0026 _BITMASK_BURNED != 0;\r\n ownership.extraData = uint24(packed \u003e\u003e _BITPOS_EXTRA_DATA);\r\n }\r\n\r\n /**\r\n * @dev Packs ownership data into a single uint256.\r\n */\r\n function _packOwnershipData(address owner, uint256 flags) private view returns (uint256 result) {\r\n assembly {\r\n // Mask `owner` to the lower 160 bits, in case the upper bits somehow aren\u0027t clean.\r\n owner := and(owner, _BITMASK_ADDRESS)\r\n // `owner | (block.timestamp \u003c\u003c _BITPOS_START_TIMESTAMP) | flags`.\r\n result := or(owner, or(shl(_BITPOS_START_TIMESTAMP, timestamp()), flags))\r\n }\r\n }\r\n\r\n /**\r\n * @dev Returns the `nextInitialized` flag set if `quantity` equals 1.\r\n */\r\n function _nextInitializedFlag(uint256 quantity) private pure returns (uint256 result) {\r\n // For branchless setting of the `nextInitialized` flag.\r\n assembly {\r\n // `(quantity == 1) \u003c\u003c _BITPOS_NEXT_INITIALIZED`.\r\n result := shl(_BITPOS_NEXT_INITIALIZED, eq(quantity, 1))\r\n }\r\n }\r\n\r\n // =============================================================\r\n // APPROVAL OPERATIONS\r\n // =============================================================\r\n\r\n /**\r\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\r\n * The approval is cleared when the token is transferred.\r\n *\r\n * Only a single account can be approved at a time, so approving the\r\n * zero address clears previous approvals.\r\n *\r\n * Requirements:\r\n *\r\n * - The caller must own the token or be an approved operator.\r\n * - `tokenId` must exist.\r\n *\r\n * Emits an {Approval} event.\r\n */\r\n function approve(address to, uint256 tokenId) public payable virtual override {\r\n address owner = ownerOf(tokenId);\r\n\r\n if (_msgSenderERC721A() != owner)\r\n if (!isApprovedForAll(owner, _msgSenderERC721A())) {\r\n revert ApprovalCallerNotOwnerNorApproved();\r\n }\r\n\r\n _tokenApprovals[tokenId].value = to;\r\n emit Approval(owner, to, tokenId);\r\n }\r\n\r\n /**\r\n * @dev Returns the account approved for `tokenId` token.\r\n *\r\n * Requirements:\r\n *\r\n * - `tokenId` must exist.\r\n */\r\n function getApproved(uint256 tokenId) public view virtual override returns (address) {\r\n if (!_exists(tokenId)) revert ApprovalQueryForNonexistentToken();\r\n\r\n return _tokenApprovals[tokenId].value;\r\n }\r\n\r\n /**\r\n * @dev Approve or remove `operator` as an operator for the caller.\r\n * Operators can call {transferFrom} or {safeTransferFrom}\r\n * for any token owned by the caller.\r\n *\r\n * Requirements:\r\n *\r\n * - The `operator` cannot be the caller.\r\n *\r\n * Emits an {ApprovalForAll} event.\r\n */\r\n function setApprovalForAll(address operator, bool approved) public virtual override {\r\n _operatorApprovals[_msgSenderERC721A()][operator] = approved;\r\n emit ApprovalForAll(_msgSenderERC721A(), operator, approved);\r\n }\r\n\r\n /**\r\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\r\n *\r\n * See {setApprovalForAll}.\r\n */\r\n function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {\r\n return _operatorApprovals[owner][operator];\r\n }\r\n\r\n /**\r\n * @dev Returns whether `tokenId` exists.\r\n *\r\n * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.\r\n *\r\n * Tokens start existing when they are minted. See {_mint}.\r\n */\r\n function _exists(uint256 tokenId) internal view virtual returns (bool) {\r\n return\r\n _startTokenId() \u003c= tokenId \u0026\u0026\r\n tokenId \u003c _currentIndex \u0026\u0026 // If within bounds,\r\n _packedOwnerships[tokenId] \u0026 _BITMASK_BURNED == 0; // and not burned.\r\n }\r\n\r\n /**\r\n * @dev Returns whether `msgSender` is equal to `approvedAddress` or `owner`.\r\n */\r\n function _isSenderApprovedOrOwner(\r\n address approvedAddress,\r\n address owner,\r\n address msgSender\r\n ) private pure returns (bool result) {\r\n assembly {\r\n // Mask `owner` to the lower 160 bits, in case the upper bits somehow aren\u0027t clean.\r\n owner := and(owner, _BITMASK_ADDRESS)\r\n // Mask `msgSender` to the lower 160 bits, in case the upper bits somehow aren\u0027t clean.\r\n msgSender := and(msgSender, _BITMASK_ADDRESS)\r\n // `msgSender == owner || msgSender == approvedAddress`.\r\n result := or(eq(msgSender, owner), eq(msgSender, approvedAddress))\r\n }\r\n }\r\n\r\n /**\r\n * @dev Returns the storage slot and value for the approved address of `tokenId`.\r\n */\r\n function _getApprovedSlotAndAddress(uint256 tokenId)\r\n private\r\n view\r\n returns (uint256 approvedAddressSlot, address approvedAddress)\r\n {\r\n TokenApprovalRef storage tokenApproval = _tokenApprovals[tokenId];\r\n // The following is equivalent to `approvedAddress = _tokenApprovals[tokenId].value`.\r\n assembly {\r\n approvedAddressSlot := tokenApproval.slot\r\n approvedAddress := sload(approvedAddressSlot)\r\n }\r\n }\r\n\r\n // =============================================================\r\n // TRANSFER OPERATIONS\r\n // =============================================================\r\n\r\n /**\r\n * @dev Transfers `tokenId` from `from` to `to`.\r\n *\r\n * Requirements:\r\n *\r\n * - `from` cannot be the zero address.\r\n * - `to` cannot be the zero address.\r\n * - `tokenId` token must be owned by `from`.\r\n * - If the caller is not `from`, it must be approved to move this token\r\n * by either {approve} or {setApprovalForAll}.\r\n *\r\n * Emits a {Transfer} event.\r\n */\r\n function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {\r\n require(_exists(tokenId), \"ERC721: operator query for nonexistent token\");\r\n address owner = ERC721A.ownerOf(tokenId);\r\n return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender));\r\n }\r\n function transferFrom(\r\n address from,\r\n address to,\r\n uint256 tokenId\r\n ) public payable virtual override onlyAllowedOperator(from){\r\n uint256 prevOwnershipPacked = _packedOwnershipOf(tokenId);\r\n\r\n if (address(uint160(prevOwnershipPacked)) != from) revert TransferFromIncorrectOwner();\r\n\r\n (uint256 approvedAddressSlot, address approvedAddress) = _getApprovedSlotAndAddress(tokenId);\r\n\r\n // The nested ifs save around 20+ gas over a compound boolean condition.\r\n if (!_isSenderApprovedOrOwner(approvedAddress, from, _msgSenderERC721A()))\r\n if (!isApprovedForAll(from, _msgSenderERC721A())) revert TransferCallerNotOwnerNorApproved();\r\n\r\n if (to == address(0)) revert TransferToZeroAddress();\r\n\r\n _beforeTokenTransfers(from, to, tokenId, 1);\r\n\r\n // Clear approvals from the previous owner.\r\n assembly {\r\n if approvedAddress {\r\n // This is equivalent to `delete _tokenApprovals[tokenId]`.\r\n sstore(approvedAddressSlot, 0)\r\n }\r\n }\r\n\r\n // Underflow of the sender\u0027s balance is impossible because we check for\r\n // ownership above and the recipient\u0027s balance can\u0027t realistically overflow.\r\n // Counter overflow is incredibly unrealistic as `tokenId` would have to be 2**256.\r\n unchecked {\r\n // We can directly increment and decrement the balances.\r\n --_packedAddressData[from]; // Updates: `balance -= 1`.\r\n ++_packedAddressData[to]; // Updates: `balance += 1`.\r\n\r\n // Updates:\r\n // - `address` to the next owner.\r\n // - `startTimestamp` to the timestamp of transfering.\r\n // - `burned` to `false`.\r\n // - `nextInitialized` to `true`.\r\n _packedOwnerships[tokenId] = _packOwnershipData(\r\n to,\r\n _BITMASK_NEXT_INITIALIZED | _nextExtraData(from, to, prevOwnershipPacked)\r\n );\r\n\r\n // If the next slot may not have been initialized (i.e. `nextInitialized == false`) .\r\n if (prevOwnershipPacked \u0026 _BITMASK_NEXT_INITIALIZED == 0) {\r\n uint256 nextTokenId = tokenId + 1;\r\n // If the next slot\u0027s address is zero and not burned (i.e. packed value is zero).\r\n if (_packedOwnerships[nextTokenId] == 0) {\r\n // If the next slot is within bounds.\r\n if (nextTokenId != _currentIndex) {\r\n // Initialize the next slot to maintain correctness for `ownerOf(tokenId + 1)`.\r\n _packedOwnerships[nextTokenId] = prevOwnershipPacked;\r\n }\r\n }\r\n }\r\n }\r\n\r\n emit Transfer(from, to, tokenId);\r\n _afterTokenTransfers(from, to, tokenId, 1);\r\n }\r\n\r\n /**\r\n * @dev Equivalent to `safeTransferFrom(from, to, tokenId, \u0027\u0027)`.\r\n */\r\n function safeTransferFrom(\r\n address from,\r\n address to,\r\n uint256 tokenId\r\n ) public payable virtual override onlyAllowedOperator(from){\r\n safeTransferFrom(from, to, tokenId, \u0027\u0027);\r\n }\r\n\r\n /**\r\n * @dev Safely transfers `tokenId` token from `from` to `to`.\r\n *\r\n * Requirements:\r\n *\r\n * - `from` cannot be the zero address.\r\n * - `to` cannot be the zero address.\r\n * - `tokenId` token must exist and be owned by `from`.\r\n * - If the caller is not `from`, it must be approved to move this token\r\n * by either {approve} or {setApprovalForAll}.\r\n * - If `to` refers to a smart contract, it must implement\r\n * {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\r\n *\r\n * Emits a {Transfer} event.\r\n */\r\n function safeTransferFrom(\r\n address from,\r\n address to,\r\n uint256 tokenId,\r\n bytes memory _data\r\n ) public payable virtual override onlyAllowedOperator(from){\r\n transferFrom(from, to, tokenId);\r\n if (to.code.length != 0)\r\n if (!_checkContractOnERC721Received(from, to, tokenId, _data)) {\r\n revert TransferToNonERC721ReceiverImplementer();\r\n }\r\n }\r\n\r\n /**\r\n * @dev Hook that is called before a set of serially-ordered token IDs\r\n * are about to be transferred. This includes minting.\r\n * And also called before burning one token.\r\n *\r\n * `startTokenId` - the first token ID to be transferred.\r\n * `quantity` - the amount to be transferred.\r\n *\r\n * Calling conditions:\r\n *\r\n * - When `from` and `to` are both non-zero, `from`\u0027s `tokenId` will be\r\n * transferred to `to`.\r\n * - When `from` is zero, `tokenId` will be minted for `to`.\r\n * - When `to` is zero, `tokenId` will be burned by `from`.\r\n * - `from` and `to` are never both zero.\r\n */\r\n function _beforeTokenTransfers(\r\n address from,\r\n address to,\r\n uint256 startTokenId,\r\n uint256 quantity\r\n ) internal virtual {}\r\n\r\n /**\r\n * @dev Hook that is called after a set of serially-ordered token IDs\r\n * have been transferred. This includes minting.\r\n * And also called after one token has been burned.\r\n *\r\n * `startTokenId` - the first token ID to be transferred.\r\n * `quantity` - the amount to be transferred.\r\n *\r\n * Calling conditions:\r\n *\r\n * - When `from` and `to` are both non-zero, `from`\u0027s `tokenId` has been\r\n * transferred to `to`.\r\n * - When `from` is zero, `tokenId` has been minted for `to`.\r\n * - When `to` is zero, `tokenId` has been burned by `from`.\r\n * - `from` and `to` are never both zero.\r\n */\r\n function _afterTokenTransfers(\r\n address from,\r\n address to,\r\n uint256 startTokenId,\r\n uint256 quantity\r\n ) internal virtual {}\r\n\r\n /**\r\n * @dev Private function to invoke {IERC721Receiver-onERC721Received} on a target contract.\r\n *\r\n * `from` - Previous owner of the given token ID.\r\n * `to` - Target address that will receive the token.\r\n * `tokenId` - Token ID to be transferred.\r\n * `_data` - Optional data to send along with the call.\r\n *\r\n * Returns whether the call correctly returned the expected magic value.\r\n */\r\n function _checkContractOnERC721Received(\r\n address from,\r\n address to,\r\n uint256 tokenId,\r\n bytes memory _data\r\n ) private returns (bool) {\r\n try ERC721A__IERC721Receiver(to).onERC721Received(_msgSenderERC721A(), from, tokenId, _data) returns (\r\n bytes4 retval\r\n ) {\r\n return retval == ERC721A__IERC721Receiver(to).onERC721Received.selector;\r\n } catch (bytes memory reason) {\r\n if (reason.length == 0) {\r\n revert TransferToNonERC721ReceiverImplementer();\r\n } else {\r\n assembly {\r\n revert(add(32, reason), mload(reason))\r\n }\r\n }\r\n }\r\n }\r\n\r\n // =============================================================\r\n // MINT OPERATIONS\r\n // =============================================================\r\n\r\n /**\r\n * @dev Mints `quantity` tokens and transfers them to `to`.\r\n *\r\n * Requirements:\r\n *\r\n * - `to` cannot be the zero address.\r\n * - `quantity` must be greater than 0.\r\n *\r\n * Emits a {Transfer} event for each mint.\r\n */\r\n function _mint(address to, uint256 quantity) internal virtual {\r\n uint256 startTokenId = _currentIndex;\r\n if (quantity == 0) revert MintZeroQuantity();\r\n\r\n _beforeTokenTransfers(address(0), to, startTokenId, quantity);\r\n\r\n // Overflows are incredibly unrealistic.\r\n // `balance` and `numberMinted` have a maximum limit of 2**64.\r\n // `tokenId` has a maximum limit of 2**256.\r\n unchecked {\r\n // Updates:\r\n // - `balance += quantity`.\r\n // - `numberMinted += quantity`.\r\n //\r\n // We can directly add to the `balance` and `numberMinted`.\r\n _packedAddressData[to] += quantity * ((1 \u003c\u003c _BITPOS_NUMBER_MINTED) | 1);\r\n\r\n // Updates:\r\n // - `address` to the owner.\r\n // - `startTimestamp` to the timestamp of minting.\r\n // - `burned` to `false`.\r\n // - `nextInitialized` to `quantity == 1`.\r\n _packedOwnerships[startTokenId] = _packOwnershipData(\r\n to,\r\n _nextInitializedFlag(quantity) | _nextExtraData(address(0), to, 0)\r\n );\r\n\r\n uint256 toMasked;\r\n uint256 end = startTokenId + quantity;\r\n\r\n // Use assembly to loop and emit the `Transfer` event for gas savings.\r\n // The duplicated `log4` removes an extra check and reduces stack juggling.\r\n // The assembly, together with the surrounding Solidity code, have been\r\n // delicately arranged to nudge the compiler into producing optimized opcodes.\r\n assembly {\r\n // Mask `to` to the lower 160 bits, in case the upper bits somehow aren\u0027t clean.\r\n toMasked := and(to, _BITMASK_ADDRESS)\r\n // Emit the `Transfer` event.\r\n log4(\r\n 0, // Start of data (0, since no data).\r\n 0, // End of data (0, since no data).\r\n _TRANSFER_EVENT_SIGNATURE, // Signature.\r\n 0, // `address(0)`.\r\n toMasked, // `to`.\r\n startTokenId // `tokenId`.\r\n )\r\n\r\n // The `iszero(eq(,))` check ensures that large values of `quantity`\r\n // that overflows uint256 will make the loop run out of gas.\r\n // The compiler will optimize the `iszero` away for performance.\r\n for {\r\n let tokenId := add(startTokenId, 1)\r\n } iszero(eq(tokenId, end)) {\r\n tokenId := add(tokenId, 1)\r\n } {\r\n // Emit the `Transfer` event. Similar to above.\r\n log4(0, 0, _TRANSFER_EVENT_SIGNATURE, 0, toMasked, tokenId)\r\n }\r\n }\r\n if (toMasked == 0) revert MintToZeroAddress();\r\n\r\n _currentIndex = end;\r\n }\r\n _afterTokenTransfers(address(0), to, startTokenId, quantity);\r\n }\r\n\r\n /**\r\n * @dev Mints `quantity` tokens and transfers them to `to`.\r\n *\r\n * This function is intended for efficient minting only during contract creation.\r\n *\r\n * It emits only one {ConsecutiveTransfer} as defined in\r\n * [ERC2309](https://eips.ethereum.org/EIPS/eip-2309),\r\n * instead of a sequence of {Transfer} event(s).\r\n *\r\n * Calling this function outside of contract creation WILL make your contract\r\n * non-compliant with the ERC721 standard.\r\n * For full ERC721 compliance, substituting ERC721 {Transfer} event(s) with the ERC2309\r\n * {ConsecutiveTransfer} event is only permissible during contract creation.\r\n *\r\n * Requirements:\r\n *\r\n * - `to` cannot be the zero address.\r\n * - `quantity` must be greater than 0.\r\n *\r\n * Emits a {ConsecutiveTransfer} event.\r\n */\r\n function _mintERC2309(address to, uint256 quantity) internal virtual {\r\n uint256 startTokenId = _currentIndex;\r\n if (to == address(0)) revert MintToZeroAddress();\r\n if (quantity == 0) revert MintZeroQuantity();\r\n if (quantity \u003e _MAX_MINT_ERC2309_QUANTITY_LIMIT) revert MintERC2309QuantityExceedsLimit();\r\n\r\n _beforeTokenTransfers(address(0), to, startTokenId, quantity);\r\n\r\n // Overflows are unrealistic due to the above check for `quantity` to be below the limit.\r\n unchecked {\r\n // Updates:\r\n // - `balance += quantity`.\r\n // - `numberMinted += quantity`.\r\n //\r\n // We can directly add to the `balance` and `numberMinted`.\r\n _packedAddressData[to] += quantity * ((1 \u003c\u003c _BITPOS_NUMBER_MINTED) | 1);\r\n\r\n // Updates:\r\n // - `address` to the owner.\r\n // - `startTimestamp` to the timestamp of minting.\r\n // - `burned` to `false`.\r\n // - `nextInitialized` to `quantity == 1`.\r\n _packedOwnerships[startTokenId] = _packOwnershipData(\r\n to,\r\n _nextInitializedFlag(quantity) | _nextExtraData(address(0), to, 0)\r\n );\r\n\r\n emit ConsecutiveTransfer(startTokenId, startTokenId + quantity - 1, address(0), to);\r\n\r\n _currentIndex = startTokenId + quantity;\r\n }\r\n _afterTokenTransfers(address(0), to, startTokenId, quantity);\r\n }\r\n\r\n /**\r\n * @dev Safely mints `quantity` tokens and transfers them to `to`.\r\n *\r\n * Requirements:\r\n *\r\n * - If `to` refers to a smart contract, it must implement\r\n * {IERC721Receiver-onERC721Received}, which is called for each safe transfer.\r\n * - `quantity` must be greater than 0.\r\n *\r\n * See {_mint}.\r\n *\r\n * Emits a {Transfer} event for each mint.\r\n */\r\n function _safeMint(\r\n address to,\r\n uint256 quantity,\r\n bytes memory _data\r\n ) internal virtual {\r\n _mint(to, quantity);\r\n\r\n unchecked {\r\n if (to.code.length != 0) {\r\n uint256 end = _currentIndex;\r\n uint256 index = end - quantity;\r\n do {\r\n if (!_checkContractOnERC721Received(address(0), to, index++, _data)) {\r\n revert TransferToNonERC721ReceiverImplementer();\r\n }\r\n } while (index \u003c end);\r\n // Reentrancy protection.\r\n if (_currentIndex != end) revert();\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * @dev Equivalent to `_safeMint(to, quantity, \u0027\u0027)`.\r\n */\r\n function _safeMint(address to, uint256 quantity) internal virtual {\r\n _safeMint(to, quantity, \u0027\u0027);\r\n }\r\n\r\n // =============================================================\r\n // BURN OPERATIONS\r\n // =============================================================\r\n\r\n /**\r\n * @dev Equivalent to `_burn(tokenId, false)`.\r\n */\r\n function _burn(uint256 tokenId) internal virtual {\r\n _burn(tokenId, false);\r\n }\r\n\r\n /**\r\n * @dev Destroys `tokenId`.\r\n * The approval is cleared when the token is burned.\r\n *\r\n * Requirements:\r\n *\r\n * - `tokenId` must exist.\r\n *\r\n * Emits a {Transfer} event.\r\n */\r\n function _burn(uint256 tokenId, bool approvalCheck) internal virtual {\r\n uint256 prevOwnershipPacked = _packedOwnershipOf(tokenId);\r\n\r\n address from = address(uint160(prevOwnershipPacked));\r\n\r\n (uint256 approvedAddressSlot, address approvedAddress) = _getApprovedSlotAndAddress(tokenId);\r\n\r\n if (approvalCheck) {\r\n // The nested ifs save around 20+ gas over a compound boolean condition.\r\n if (!_isSenderApprovedOrOwner(approvedAddress, from, _msgSenderERC721A()))\r\n if (!isApprovedForAll(from, _msgSenderERC721A())) revert TransferCallerNotOwnerNorApproved();\r\n }\r\n\r\n _beforeTokenTransfers(from, address(0), tokenId, 1);\r\n\r\n // Clear approvals from the previous owner.\r\n assembly {\r\n if approvedAddress {\r\n // This is equivalent to `delete _tokenApprovals[tokenId]`.\r\n sstore(approvedAddressSlot, 0)\r\n }\r\n }\r\n\r\n // Underflow of the sender\u0027s balance is impossible because we check for\r\n // ownership above and the recipient\u0027s balance can\u0027t realistically overflow.\r\n // Counter overflow is incredibly unrealistic as `tokenId` would have to be 2**256.\r\n unchecked {\r\n // Updates:\r\n // - `balance -= 1`.\r\n // - `numberBurned += 1`.\r\n //\r\n // We can directly decrement the balance, and increment the number burned.\r\n // This is equivalent to `packed -= 1; packed += 1 \u003c\u003c _BITPOS_NUMBER_BURNED;`.\r\n _packedAddressData[from] += (1 \u003c\u003c _BITPOS_NUMBER_BURNED) - 1;\r\n\r\n // Updates:\r\n // - `address` to the last owner.\r\n // - `startTimestamp` to the timestamp of burning.\r\n // - `burned` to `true`.\r\n // - `nextInitialized` to `true`.\r\n _packedOwnerships[tokenId] = _packOwnershipData(\r\n from,\r\n (_BITMASK_BURNED | _BITMASK_NEXT_INITIALIZED) | _nextExtraData(from, address(0), prevOwnershipPacked)\r\n );\r\n\r\n // If the next slot may not have been initialized (i.e. `nextInitialized == false`) .\r\n if (prevOwnershipPacked \u0026 _BITMASK_NEXT_INITIALIZED == 0) {\r\n uint256 nextTokenId = tokenId + 1;\r\n // If the next slot\u0027s address is zero and not burned (i.e. packed value is zero).\r\n if (_packedOwnerships[nextTokenId] == 0) {\r\n // If the next slot is within bounds.\r\n if (nextTokenId != _currentIndex) {\r\n // Initialize the next slot to maintain correctness for `ownerOf(tokenId + 1)`.\r\n _packedOwnerships[nextTokenId] = prevOwnershipPacked;\r\n }\r\n }\r\n }\r\n }\r\n\r\n emit Transfer(from, address(0), tokenId);\r\n _afterTokenTransfers(from, address(0), tokenId, 1);\r\n\r\n // Overflow not possible, as _burnCounter cannot be exceed _currentIndex times.\r\n unchecked {\r\n _burnCounter++;\r\n }\r\n }\r\n\r\n // =============================================================\r\n // EXTRA DATA OPERATIONS\r\n // =============================================================\r\n\r\n /**\r\n * @dev Directly sets the extra data for the ownership data `index`.\r\n */\r\n function _setExtraDataAt(uint256 index, uint24 extraData) internal virtual {\r\n uint256 packed = _packedOwnerships[index];\r\n if (packed == 0) revert OwnershipNotInitializedForExtraData();\r\n uint256 extraDataCasted;\r\n // Cast `extraData` with assembly to avoid redundant masking.\r\n assembly {\r\n extraDataCasted := extraData\r\n }\r\n packed = (packed \u0026 _BITMASK_EXTRA_DATA_COMPLEMENT) | (extraDataCasted \u003c\u003c _BITPOS_EXTRA_DATA);\r\n _packedOwnerships[index] = packed;\r\n }\r\n\r\n /**\r\n * @dev Called during each token transfer to set the 24bit `extraData` field.\r\n * Intended to be overridden by the cosumer contract.\r\n *\r\n * `previousExtraData` - the value of `extraData` before transfer.\r\n *\r\n * Calling conditions:\r\n *\r\n * - When `from` and `to` are both non-zero, `from`\u0027s `tokenId` will be\r\n * transferred to `to`.\r\n * - When `from` is zero, `tokenId` will be minted for `to`.\r\n * - When `to` is zero, `tokenId` will be burned by `from`.\r\n * - `from` and `to` are never both zero.\r\n */\r\n function _extraData(\r\n address from,\r\n address to,\r\n uint24 previousExtraData\r\n ) internal view virtual returns (uint24) {}\r\n\r\n /**\r\n * @dev Returns the next extra data for the packed ownership data.\r\n * The returned result is shifted into position.\r\n */\r\n function _nextExtraData(\r\n address from,\r\n address to,\r\n uint256 prevOwnershipPacked\r\n ) private view returns (uint256) {\r\n uint24 extraData = uint24(prevOwnershipPacked \u003e\u003e _BITPOS_EXTRA_DATA);\r\n return uint256(_extraData(from, to, extraData)) \u003c\u003c _BITPOS_EXTRA_DATA;\r\n }\r\n\r\n // =============================================================\r\n // OTHER OPERATIONS\r\n // =============================================================\r\n\r\n /**\r\n * @dev Returns the message sender (defaults to `msg.sender`).\r\n *\r\n * If you are writing GSN compatible contracts, you need to override this function.\r\n */\r\n function _msgSenderERC721A() internal view virtual returns (address) {\r\n return msg.sender;\r\n }\r\n\r\n /**\r\n * @dev Converts a uint256 to its ASCII string decimal representation.\r\n */\r\n function _toString(uint256 value) internal pure virtual returns (string memory str) {\r\n assembly {\r\n // The maximum value of a uint256 contains 78 digits (1 byte per digit), but\r\n // we allocate 0xa0 bytes to keep the free memory pointer 32-byte word aligned.\r\n // We will need 1 word for the trailing zeros padding, 1 word for the length,\r\n // and 3 words for a maximum of 78 digits. Total: 5 * 0x20 = 0xa0.\r\n let m := add(mload(0x40), 0xa0)\r\n // Update the free memory pointer to allocate.\r\n mstore(0x40, m)\r\n // Assign the `str` to the end.\r\n str := sub(m, 0x20)\r\n // Zeroize the slot after the string.\r\n mstore(str, 0)\r\n\r\n // Cache the end of the memory to calculate the length later.\r\n let end := str\r\n\r\n // We write the string from rightmost digit to leftmost digit.\r\n // The following is essentially a do-while loop that also handles the zero case.\r\n // prettier-ignore\r\n for { let temp := value } 1 {} {\r\n str := sub(str, 1)\r\n // Write the character to the pointer.\r\n // The ASCII index of the \u00270\u0027 character is 48.\r\n mstore8(str, add(48, mod(temp, 10)))\r\n // Keep dividing `temp` until zero.\r\n temp := div(temp, 10)\r\n // prettier-ignore\r\n if iszero(temp) { break }\r\n }\r\n\r\n let length := sub(end, str)\r\n // Move the pointer 32 bytes leftwards to make room for the length.\r\n str := sub(str, 0x20)\r\n // Store the length.\r\n mstore(str, length)\r\n }\r\n }\r\n}"},"IERC721A.sol":{"content":"// SPDX-License-Identifier: MIT\r\n// ERC721A Contracts v4.2.3\r\n// Creator: Chiru Labs\r\n\r\npragma solidity ^0.8.4;\r\n\r\n/**\r\n * @dev Interface of ERC721A.\r\n */\r\ninterface IERC721A {\r\n /**\r\n * The caller must own the token or be an approved operator.\r\n */\r\n error ApprovalCallerNotOwnerNorApproved();\r\n\r\n /**\r\n * The token does not exist.\r\n */\r\n error ApprovalQueryForNonexistentToken();\r\n\r\n /**\r\n * Cannot query the balance for the zero address.\r\n */\r\n error BalanceQueryForZeroAddress();\r\n\r\n /**\r\n * Cannot mint to the zero address.\r\n */\r\n error MintToZeroAddress();\r\n\r\n /**\r\n * The quantity of tokens minted must be more than zero.\r\n */\r\n error MintZeroQuantity();\r\n\r\n /**\r\n * The token does not exist.\r\n */\r\n error OwnerQueryForNonexistentToken();\r\n\r\n /**\r\n * The caller must own the token or be an approved operator.\r\n */\r\n error TransferCallerNotOwnerNorApproved();\r\n\r\n /**\r\n * The token must be owned by `from`.\r\n */\r\n error TransferFromIncorrectOwner();\r\n\r\n /**\r\n * Cannot safely transfer to a contract that does not implement the\r\n * ERC721Receiver interface.\r\n */\r\n error TransferToNonERC721ReceiverImplementer();\r\n\r\n /**\r\n * Cannot transfer to the zero address.\r\n */\r\n error TransferToZeroAddress();\r\n\r\n /**\r\n * The token does not exist.\r\n */\r\n error URIQueryForNonexistentToken();\r\n\r\n /**\r\n * The `quantity` minted with ERC2309 exceeds the safety limit.\r\n */\r\n error MintERC2309QuantityExceedsLimit();\r\n\r\n /**\r\n * The `extraData` cannot be set on an unintialized ownership slot.\r\n */\r\n error OwnershipNotInitializedForExtraData();\r\n\r\n // =============================================================\r\n // STRUCTS\r\n // =============================================================\r\n\r\n struct TokenOwnership {\r\n // The address of the owner.\r\n address addr;\r\n // Stores the start time of ownership with minimal overhead for tokenomics.\r\n uint64 startTimestamp;\r\n // Whether the token has been burned.\r\n bool burned;\r\n // Arbitrary data similar to `startTimestamp` that can be set via {_extraData}.\r\n uint24 extraData;\r\n }\r\n\r\n // =============================================================\r\n // TOKEN COUNTERS\r\n // =============================================================\r\n\r\n /**\r\n * @dev Returns the total number of tokens in existence.\r\n * Burned tokens will reduce the count.\r\n * To get the total number of tokens minted, please see {_totalMinted}.\r\n */\r\n function totalSupply() external view returns (uint256);\r\n\r\n // =============================================================\r\n // IERC165\r\n // =============================================================\r\n\r\n /**\r\n * @dev Returns true if this contract implements the interface defined by\r\n * `interfaceId`. See the corresponding\r\n * [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified)\r\n * to learn more about how these ids are created.\r\n *\r\n * This function call must use less than 30000 gas.\r\n */\r\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\r\n\r\n // =============================================================\r\n // IERC721\r\n // =============================================================\r\n\r\n /**\r\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\r\n */\r\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\r\n\r\n /**\r\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\r\n */\r\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\r\n\r\n /**\r\n * @dev Emitted when `owner` enables or disables\r\n * (`approved`) `operator` to manage all of its assets.\r\n */\r\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\r\n\r\n /**\r\n * @dev Returns the number of tokens in `owner`\u0027s account.\r\n */\r\n function balanceOf(address owner) external view returns (uint256 balance);\r\n\r\n /**\r\n * @dev Returns the owner of the `tokenId` token.\r\n *\r\n * Requirements:\r\n *\r\n * - `tokenId` must exist.\r\n */\r\n function ownerOf(uint256 tokenId) external view returns (address owner);\r\n\r\n /**\r\n * @dev Safely transfers `tokenId` token from `from` to `to`,\r\n * checking first that contract recipients are aware of the ERC721 protocol\r\n * to prevent tokens from being forever locked.\r\n *\r\n * Requirements:\r\n *\r\n * - `from` cannot be the zero address.\r\n * - `to` cannot be the zero address.\r\n * - `tokenId` token must exist and be owned by `from`.\r\n * - If the caller is not `from`, it must be have been allowed to move\r\n * this token by either {approve} or {setApprovalForAll}.\r\n * - If `to` refers to a smart contract, it must implement\r\n * {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\r\n *\r\n * Emits a {Transfer} event.\r\n */\r\n function safeTransferFrom(\r\n address from,\r\n address to,\r\n uint256 tokenId,\r\n bytes calldata data\r\n ) external payable;\r\n\r\n /**\r\n * @dev Equivalent to `safeTransferFrom(from, to, tokenId, \u0027\u0027)`.\r\n */\r\n function safeTransferFrom(\r\n address from,\r\n address to,\r\n uint256 tokenId\r\n ) external payable;\r\n\r\n /**\r\n * @dev Transfers `tokenId` from `from` to `to`.\r\n *\r\n * WARNING: Usage of this method is discouraged, use {safeTransferFrom}\r\n * whenever possible.\r\n *\r\n * Requirements:\r\n *\r\n * - `from` cannot be the zero address.\r\n * - `to` cannot be the zero address.\r\n * - `tokenId` token must be owned by `from`.\r\n * - If the caller is not `from`, it must be approved to move this token\r\n * by either {approve} or {setApprovalForAll}.\r\n *\r\n * Emits a {Transfer} event.\r\n */\r\n function transferFrom(\r\n address from,\r\n address to,\r\n uint256 tokenId\r\n ) external payable;\r\n\r\n /**\r\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\r\n * The approval is cleared when the token is transferred.\r\n *\r\n * Only a single account can be approved at a time, so approving the\r\n * zero address clears previous approvals.\r\n *\r\n * Requirements:\r\n *\r\n * - The caller must own the token or be an approved operator.\r\n * - `tokenId` must exist.\r\n *\r\n * Emits an {Approval} event.\r\n */\r\n function approve(address to, uint256 tokenId) external payable;\r\n\r\n /**\r\n * @dev Approve or remove `operator` as an operator for the caller.\r\n * Operators can call {transferFrom} or {safeTransferFrom}\r\n * for any token owned by the caller.\r\n *\r\n * Requirements:\r\n *\r\n * - The `operator` cannot be the caller.\r\n *\r\n * Emits an {ApprovalForAll} event.\r\n */\r\n function setApprovalForAll(address operator, bool _approved) external;\r\n\r\n /**\r\n * @dev Returns the account approved for `tokenId` token.\r\n *\r\n * Requirements:\r\n *\r\n * - `tokenId` must exist.\r\n */\r\n function getApproved(uint256 tokenId) external view returns (address operator);\r\n\r\n /**\r\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\r\n *\r\n * See {setApprovalForAll}.\r\n */\r\n function isApprovedForAll(address owner, address operator) external view returns (bool);\r\n\r\n // =============================================================\r\n // IERC721Metadata\r\n // =============================================================\r\n\r\n /**\r\n * @dev Returns the token collection name.\r\n */\r\n function name() external view returns (string memory);\r\n\r\n /**\r\n * @dev Returns the token collection symbol.\r\n */\r\n function symbol() external view returns (string memory);\r\n\r\n /**\r\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\r\n */\r\n function tokenURI(uint256 tokenId) external view returns (string memory);\r\n\r\n // =============================================================\r\n // IERC2309\r\n // =============================================================\r\n\r\n /**\r\n * @dev Emitted when tokens in `fromTokenId` to `toTokenId`\r\n * (inclusive) is transferred from `from` to `to`, as defined in the\r\n * [ERC2309](https://eips.ethereum.org/EIPS/eip-2309) standard.\r\n *\r\n * See {_mintERC2309} for more details.\r\n */\r\n event ConsecutiveTransfer(uint256 indexed fromTokenId, uint256 toTokenId, address indexed from, address indexed to);\r\n}"},"IOperatorFilterRegistry.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\ninterface IOperatorFilterRegistry {\n function isOperatorAllowed(address registrant, address operator) external view returns (bool);\n function register(address registrant) external;\n function registerAndSubscribe(address registrant, address subscription) external;\n function registerAndCopyEntries(address registrant, address registrantToCopy) external;\n function unregister(address addr) external;\n function updateOperator(address registrant, address operator, bool filtered) external;\n function updateOperators(address registrant, address[] calldata operators, bool filtered) external;\n function updateCodeHash(address registrant, bytes32 codehash, bool filtered) external;\n function updateCodeHashes(address registrant, bytes32[] calldata codeHashes, bool filtered) external;\n function subscribe(address registrant, address registrantToSubscribe) external;\n function unsubscribe(address registrant, bool copyExistingEntries) external;\n function subscriptionOf(address addr) external returns (address registrant);\n function subscribers(address registrant) external returns (address[] memory);\n function subscriberAt(address registrant, uint256 index) external returns (address);\n function copyEntriesOf(address registrant, address registrantToCopy) external;\n function isOperatorFiltered(address registrant, address operator) external returns (bool);\n function isCodeHashOfFiltered(address registrant, address operatorWithCode) external returns (bool);\n function isCodeHashFiltered(address registrant, bytes32 codeHash) external returns (bool);\n function filteredOperators(address addr) external returns (address[] memory);\n function filteredCodeHashes(address addr) external returns (bytes32[] memory);\n function filteredOperatorAt(address registrant, uint256 index) external returns (address);\n function filteredCodeHashAt(address registrant, uint256 index) external returns (bytes32);\n function isRegistered(address addr) external returns (bool);\n function codeHashOf(address addr) external returns (bytes32);\n}\n"},"Markle.sol":{"content":"// SPDX-License-Identifier: MIT\r\n\r\npragma solidity ^0.8.0;\r\n\r\n/**\r\n * @dev These functions deal with verification of Merkle Trees proofs.\r\n *\r\n * The proofs can be generated using the JavaScript library\r\n * https://github.com/miguelmota/merkletreejs[merkletreejs].\r\n * Note: the hashing algorithm should be keccak256 and pair sorting should be enabled.\r\n *\r\n * See `test/utils/cryptography/MerkleProof.test.js` for some examples.\r\n *\r\n * WARNING: You should avoid using leaf values that are 64 bytes long prior to\r\n * hashing, or use a hash function other than keccak256 for hashing leaves.\r\n * This is because the concatenation of a sorted pair of internal nodes in\r\n * the merkle tree could be reinterpreted as a leaf value.\r\n */\r\nlibrary MerkleProof {\r\n /**\r\n * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree\r\n * defined by `root`. For this, a `proof` must be provided, containing\r\n * sibling hashes on the branch from the leaf to the root of the tree. Each\r\n * pair of leaves and each pair of pre-images are assumed to be sorted.\r\n */\r\n function verify(\r\n bytes32[] memory proof,\r\n bytes32 root,\r\n bytes32 leaf\r\n ) internal pure returns (bool) {\r\n return processProof(proof, leaf) == root;\r\n }\r\n\r\n /**\r\n * @dev Returns the rebuilt hash obtained by traversing a Merkle tree up\r\n * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt\r\n * hash matches the root of the tree. When processing the proof, the pairs\r\n * of leafs \u0026 pre-images are assumed to be sorted.\r\n *\r\n * _Available since v4.4._\r\n */\r\n function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) {\r\n bytes32 computedHash = leaf;\r\n for (uint256 i = 0; i \u003c proof.length; i++) {\r\n bytes32 proofElement = proof[i];\r\n if (computedHash \u003c= proofElement) {\r\n // Hash(current computed hash + current element of the proof)\r\n computedHash = _efficientHash(computedHash, proofElement);\r\n } else {\r\n // Hash(current element of the proof + current computed hash)\r\n computedHash = _efficientHash(proofElement, computedHash);\r\n }\r\n }\r\n return computedHash;\r\n }\r\n\r\n function _efficientHash(bytes32 a, bytes32 b) private pure returns (bytes32 value) {\r\n assembly {\r\n mstore(0x00, a)\r\n mstore(0x20, b)\r\n value := keccak256(0x00, 0x40)\r\n }\r\n }\r\n}"},"Math.sol":{"content":"// SPDX-License-Identifier: MIT\r\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)\r\n\r\npragma solidity ^0.8.0;\r\n\r\n/**\r\n * @dev Standard math utilities missing in the Solidity language.\r\n */\r\nlibrary Math {\r\n enum Rounding {\r\n Down, // Toward negative infinity\r\n Up, // Toward infinity\r\n Zero // Toward zero\r\n }\r\n\r\n /**\r\n * @dev Returns the largest of two numbers.\r\n */\r\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\r\n return a \u003e b ? a : b;\r\n }\r\n\r\n /**\r\n * @dev Returns the smallest of two numbers.\r\n */\r\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\r\n return a \u003c b ? a : b;\r\n }\r\n\r\n /**\r\n * @dev Returns the average of two numbers. The result is rounded towards\r\n * zero.\r\n */\r\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\r\n // (a + b) / 2 can overflow.\r\n return (a \u0026 b) + (a ^ b) / 2;\r\n }\r\n\r\n /**\r\n * @dev Returns the ceiling of the division of two numbers.\r\n *\r\n * This differs from standard division with `/` in that it rounds up instead\r\n * of rounding down.\r\n */\r\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\r\n // (a + b - 1) / b can overflow on addition, so we distribute.\r\n return a == 0 ? 0 : (a - 1) / b + 1;\r\n }\r\n\r\n /**\r\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\r\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\r\n * with further edits by Uniswap Labs also under MIT license.\r\n */\r\n function mulDiv(\r\n uint256 x,\r\n uint256 y,\r\n uint256 denominator\r\n ) internal pure returns (uint256 result) {\r\n unchecked {\r\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\r\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\r\n // variables such that product = prod1 * 2^256 + prod0.\r\n uint256 prod0; // Least significant 256 bits of the product\r\n uint256 prod1; // Most significant 256 bits of the product\r\n assembly {\r\n let mm := mulmod(x, y, not(0))\r\n prod0 := mul(x, y)\r\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\r\n }\r\n\r\n // Handle non-overflow cases, 256 by 256 division.\r\n if (prod1 == 0) {\r\n return prod0 / denominator;\r\n }\r\n\r\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\r\n require(denominator \u003e prod1);\r\n\r\n ///////////////////////////////////////////////\r\n // 512 by 256 division.\r\n ///////////////////////////////////////////////\r\n\r\n // Make division exact by subtracting the remainder from [prod1 prod0].\r\n uint256 remainder;\r\n assembly {\r\n // Compute remainder using mulmod.\r\n remainder := mulmod(x, y, denominator)\r\n\r\n // Subtract 256 bit number from 512 bit number.\r\n prod1 := sub(prod1, gt(remainder, prod0))\r\n prod0 := sub(prod0, remainder)\r\n }\r\n\r\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always \u003e= 1.\r\n // See https://cs.stackexchange.com/q/138556/92363.\r\n\r\n // Does not overflow because the denominator cannot be zero at this stage in the function.\r\n uint256 twos = denominator \u0026 (~denominator + 1);\r\n assembly {\r\n // Divide denominator by twos.\r\n denominator := div(denominator, twos)\r\n\r\n // Divide [prod1 prod0] by twos.\r\n prod0 := div(prod0, twos)\r\n\r\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\r\n twos := add(div(sub(0, twos), twos), 1)\r\n }\r\n\r\n // Shift in bits from prod1 into prod0.\r\n prod0 |= prod1 * twos;\r\n\r\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\r\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\r\n // four bits. That is, denominator * inv = 1 mod 2^4.\r\n uint256 inverse = (3 * denominator) ^ 2;\r\n\r\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel\u0027s lifting lemma, this also works\r\n // in modular arithmetic, doubling the correct bits in each step.\r\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\r\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\r\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\r\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\r\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\r\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\r\n\r\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\r\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\r\n // less than 2^256, this is the final result. We don\u0027t need to compute the high bits of the result and prod1\r\n // is no longer required.\r\n result = prod0 * inverse;\r\n return result;\r\n }\r\n }\r\n\r\n /**\r\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\r\n */\r\n function mulDiv(\r\n uint256 x,\r\n uint256 y,\r\n uint256 denominator,\r\n Rounding rounding\r\n ) internal pure returns (uint256) {\r\n uint256 result = mulDiv(x, y, denominator);\r\n if (rounding == Rounding.Up \u0026\u0026 mulmod(x, y, denominator) \u003e 0) {\r\n result += 1;\r\n }\r\n return result;\r\n }\r\n\r\n /**\r\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\r\n *\r\n * Inspired by Henry S. Warren, Jr.\u0027s \"Hacker\u0027s Delight\" (Chapter 11).\r\n */\r\n function sqrt(uint256 a) internal pure returns (uint256) {\r\n if (a == 0) {\r\n return 0;\r\n }\r\n\r\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\r\n //\r\n // We know that the \"msb\" (most significant bit) of our target number `a` is a power of 2 such that we have\r\n // `msb(a) \u003c= a \u003c 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\r\n //\r\n // This can be rewritten `2**log2(a) \u003c= a \u003c 2**(log2(a) + 1)`\r\n // → `sqrt(2**k) \u003c= sqrt(a) \u003c sqrt(2**(k+1))`\r\n // → `2**(k/2) \u003c= sqrt(a) \u003c 2**((k+1)/2) \u003c= 2**(k/2 + 1)`\r\n //\r\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\r\n uint256 result = 1 \u003c\u003c (log2(a) \u003e\u003e 1);\r\n\r\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\r\n // since it is the square root of a uint256. Newton\u0027s method converges quadratically (precision doubles at\r\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\r\n // into the expected uint128 result.\r\n unchecked {\r\n result = (result + a / result) \u003e\u003e 1;\r\n result = (result + a / result) \u003e\u003e 1;\r\n result = (result + a / result) \u003e\u003e 1;\r\n result = (result + a / result) \u003e\u003e 1;\r\n result = (result + a / result) \u003e\u003e 1;\r\n result = (result + a / result) \u003e\u003e 1;\r\n result = (result + a / result) \u003e\u003e 1;\r\n return min(result, a / result);\r\n }\r\n }\r\n\r\n /**\r\n * @notice Calculates sqrt(a), following the selected rounding direction.\r\n */\r\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\r\n unchecked {\r\n uint256 result = sqrt(a);\r\n return result + (rounding == Rounding.Up \u0026\u0026 result * result \u003c a ? 1 : 0);\r\n }\r\n }\r\n\r\n /**\r\n * @dev Return the log in base 2, rounded down, of a positive value.\r\n * Returns 0 if given 0.\r\n */\r\n function log2(uint256 value) internal pure returns (uint256) {\r\n uint256 result = 0;\r\n unchecked {\r\n if (value \u003e\u003e 128 \u003e 0) {\r\n value \u003e\u003e= 128;\r\n result += 128;\r\n }\r\n if (value \u003e\u003e 64 \u003e 0) {\r\n value \u003e\u003e= 64;\r\n result += 64;\r\n }\r\n if (value \u003e\u003e 32 \u003e 0) {\r\n value \u003e\u003e= 32;\r\n result += 32;\r\n }\r\n if (value \u003e\u003e 16 \u003e 0) {\r\n value \u003e\u003e= 16;\r\n result += 16;\r\n }\r\n if (value \u003e\u003e 8 \u003e 0) {\r\n value \u003e\u003e= 8;\r\n result += 8;\r\n }\r\n if (value \u003e\u003e 4 \u003e 0) {\r\n value \u003e\u003e= 4;\r\n result += 4;\r\n }\r\n if (value \u003e\u003e 2 \u003e 0) {\r\n value \u003e\u003e= 2;\r\n result += 2;\r\n }\r\n if (value \u003e\u003e 1 \u003e 0) {\r\n result += 1;\r\n }\r\n }\r\n return result;\r\n }\r\n\r\n /**\r\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\r\n * Returns 0 if given 0.\r\n */\r\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\r\n unchecked {\r\n uint256 result = log2(value);\r\n return result + (rounding == Rounding.Up \u0026\u0026 1 \u003c\u003c result \u003c value ? 1 : 0);\r\n }\r\n }\r\n\r\n /**\r\n * @dev Return the log in base 10, rounded down, of a positive value.\r\n * Returns 0 if given 0.\r\n */\r\n function log10(uint256 value) internal pure returns (uint256) {\r\n uint256 result = 0;\r\n unchecked {\r\n if (value \u003e= 10**64) {\r\n value /= 10**64;\r\n result += 64;\r\n }\r\n if (value \u003e= 10**32) {\r\n value /= 10**32;\r\n result += 32;\r\n }\r\n if (value \u003e= 10**16) {\r\n value /= 10**16;\r\n result += 16;\r\n }\r\n if (value \u003e= 10**8) {\r\n value /= 10**8;\r\n result += 8;\r\n }\r\n if (value \u003e= 10**4) {\r\n value /= 10**4;\r\n result += 4;\r\n }\r\n if (value \u003e= 10**2) {\r\n value /= 10**2;\r\n result += 2;\r\n }\r\n if (value \u003e= 10**1) {\r\n result += 1;\r\n }\r\n }\r\n return result;\r\n }\r\n\r\n /**\r\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\r\n * Returns 0 if given 0.\r\n */\r\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\r\n unchecked {\r\n uint256 result = log10(value);\r\n return result + (rounding == Rounding.Up \u0026\u0026 10**result \u003c value ? 1 : 0);\r\n }\r\n }\r\n\r\n /**\r\n * @dev Return the log in base 256, rounded down, of a positive value.\r\n * Returns 0 if given 0.\r\n *\r\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\r\n */\r\n function log256(uint256 value) internal pure returns (uint256) {\r\n uint256 result = 0;\r\n unchecked {\r\n if (value \u003e\u003e 128 \u003e 0) {\r\n value \u003e\u003e= 128;\r\n result += 16;\r\n }\r\n if (value \u003e\u003e 64 \u003e 0) {\r\n value \u003e\u003e= 64;\r\n result += 8;\r\n }\r\n if (value \u003e\u003e 32 \u003e 0) {\r\n value \u003e\u003e= 32;\r\n result += 4;\r\n }\r\n if (value \u003e\u003e 16 \u003e 0) {\r\n value \u003e\u003e= 16;\r\n result += 2;\r\n }\r\n if (value \u003e\u003e 8 \u003e 0) {\r\n result += 1;\r\n }\r\n }\r\n return result;\r\n }\r\n\r\n /**\r\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\r\n * Returns 0 if given 0.\r\n */\r\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\r\n unchecked {\r\n uint256 result = log256(value);\r\n return result + (rounding == Rounding.Up \u0026\u0026 1 \u003c\u003c (result \u003c\u003c 3) \u003c value ? 1 : 0);\r\n }\r\n }\r\n}"},"OperatorFilterer.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\nimport {IOperatorFilterRegistry} from \"./IOperatorFilterRegistry.sol\";\n\nabstract contract OperatorFilterer {\n error OperatorNotAllowed(address operator);\n\n IOperatorFilterRegistry constant operatorFilterRegistry =\n IOperatorFilterRegistry(0x000000000000AAeB6D7670E522A718067333cd4E);\n\n constructor(address subscriptionOrRegistrantToCopy, bool subscribe) {\n // If an inheriting token contract is deployed to a network without the registry deployed, the modifier\n // will not revert, but the contract will need to be registered with the registry once it is deployed in\n // order for the modifier to filter addresses.\n if (address(operatorFilterRegistry).code.length \u003e 0) {\n if (subscribe) {\n operatorFilterRegistry.registerAndSubscribe(address(this), subscriptionOrRegistrantToCopy);\n } else {\n if (subscriptionOrRegistrantToCopy != address(0)) {\n operatorFilterRegistry.registerAndCopyEntries(address(this), subscriptionOrRegistrantToCopy);\n } else {\n operatorFilterRegistry.register(address(this));\n }\n }\n }\n }\n\n modifier onlyAllowedOperator(address from) virtual {\n // Check registry code length to facilitate testing in environments without a deployed registry.\n if (address(operatorFilterRegistry).code.length \u003e 0) {\n // Allow spending tokens from addresses with balance\n // Note that this still allows listings and marketplaces with escrow to transfer tokens if transferred\n // from an EOA.\n if (from == msg.sender) {\n _;\n return;\n }\n if (\n !(\n operatorFilterRegistry.isOperatorAllowed(address(this), msg.sender)\n \u0026\u0026 operatorFilterRegistry.isOperatorAllowed(address(this), from)\n )\n ) {\n revert OperatorNotAllowed(msg.sender);\n }\n }\n _;\n }\n}\n"},"OperatorFilterRegistry.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\nimport {IOperatorFilterRegistry} from \"./IOperatorFilterRegistry.sol\";\nimport {Ownable} from \"./Ownable.sol\";\nimport {EnumerableSet} from \"./EnumerableSet.sol\";\nimport {OperatorFilterRegistryErrorsAndEvents} from \"./OperatorFilterRegistryErrorsAndEvents.sol\";\n\n/**\n * @title OperatorFilterRegistry\n * @notice Borrows heavily from the QQL BlacklistOperatorFilter contract:\n * https://github.com/qql-art/contracts/blob/main/contracts/BlacklistOperatorFilter.sol\n * @notice This contracts allows tokens or token owners to register specific addresses or codeHashes that may be\n * * restricted according to the isOperatorAllowed function.\n */\ncontract OperatorFilterRegistry is IOperatorFilterRegistry, OperatorFilterRegistryErrorsAndEvents {\n using EnumerableSet for EnumerableSet.AddressSet;\n using EnumerableSet for EnumerableSet.Bytes32Set;\n\n /// @dev initialized accounts have a nonzero codehash (see https://eips.ethereum.org/EIPS/eip-1052)\n /// Note that this will also be a smart contract\u0027s codehash when making calls from its constructor.\n bytes32 constant EOA_CODEHASH = keccak256(\"\");\n\n mapping(address =\u003e EnumerableSet.AddressSet) private _filteredOperators;\n mapping(address =\u003e EnumerableSet.Bytes32Set) private _filteredCodeHashes;\n mapping(address =\u003e address) private _registrations;\n mapping(address =\u003e EnumerableSet.AddressSet) private _subscribers;\n\n /**\n * @notice restricts method caller to the address or EIP-173 \"owner()\"\n */\n modifier onlyAddressOrOwner(address addr) {\n if (msg.sender != addr) {\n try Ownable(addr).owner() returns (address owner) {\n if (msg.sender != owner) {\n revert OnlyAddressOrOwner();\n }\n } catch (bytes memory reason) {\n if (reason.length == 0) {\n revert NotOwnable();\n } else {\n /// @solidity memory-safe-assembly\n assembly {\n revert(add(32, reason), mload(reason))\n }\n }\n }\n }\n _;\n }\n\n /**\n * @notice Returns true if operator is not filtered for a given token, either by address or codeHash. Also returns\n * true if supplied registrant address is not registered.\n */\n function isOperatorAllowed(address registrant, address operator) external view returns (bool) {\n address registration = _registrations[registrant];\n if (registration != address(0)) {\n EnumerableSet.AddressSet storage filteredOperatorsRef;\n EnumerableSet.Bytes32Set storage filteredCodeHashesRef;\n\n filteredOperatorsRef = _filteredOperators[registration];\n filteredCodeHashesRef = _filteredCodeHashes[registration];\n\n if (filteredOperatorsRef.contains(operator)) {\n revert AddressFiltered(operator);\n }\n if (operator.code.length \u003e 0) {\n bytes32 codeHash = operator.codehash;\n if (filteredCodeHashesRef.contains(codeHash)) {\n revert CodeHashFiltered(operator, codeHash);\n }\n }\n }\n return true;\n }\n\n //////////////////\n // AUTH METHODS //\n //////////////////\n\n /**\n * @notice Registers an address with the registry. May be called by address itself or by EIP-173 owner.\n */\n function register(address registrant) external onlyAddressOrOwner(registrant) {\n if (_registrations[registrant] != address(0)) {\n revert AlreadyRegistered();\n }\n _registrations[registrant] = registrant;\n emit RegistrationUpdated(registrant, true);\n }\n\n /**\n * @notice Unregisters an address with the registry and removes its subscription. May be called by address itself or by EIP-173 owner.\n * Note that this does not remove any filtered addresses or codeHashes.\n * Also note that any subscriptions to this registrant will still be active and follow the existing filtered addresses and codehashes.\n */\n function unregister(address registrant) external onlyAddressOrOwner(registrant) {\n address registration = _registrations[registrant];\n if (registration == address(0)) {\n revert NotRegistered(registrant);\n }\n if (registration != registrant) {\n _subscribers[registration].remove(registrant);\n emit SubscriptionUpdated(registrant, registration, false);\n }\n _registrations[registrant] = address(0);\n emit RegistrationUpdated(registrant, false);\n }\n\n /**\n * @notice Registers an address with the registry and \"subscribes\" to another address\u0027s filtered operators and codeHashes.\n */\n function registerAndSubscribe(address registrant, address subscription) external onlyAddressOrOwner(registrant) {\n address registration = _registrations[registrant];\n if (registration != address(0)) {\n revert AlreadyRegistered();\n }\n if (registrant == subscription) {\n revert CannotSubscribeToSelf();\n }\n address subscriptionRegistration = _registrations[subscription];\n if (subscriptionRegistration == address(0)) {\n revert NotRegistered(subscription);\n }\n if (subscriptionRegistration != subscription) {\n revert CannotSubscribeToRegistrantWithSubscription(subscription);\n }\n\n _registrations[registrant] = subscription;\n _subscribers[subscription].add(registrant);\n emit RegistrationUpdated(registrant, true);\n emit SubscriptionUpdated(registrant, subscription, true);\n }\n\n /**\n * @notice Registers an address with the registry and copies the filtered operators and codeHashes from another\n * address without subscribing.\n */\n function registerAndCopyEntries(address registrant, address registrantToCopy)\n external\n onlyAddressOrOwner(registrant)\n {\n if (registrantToCopy == registrant) {\n revert CannotCopyFromSelf();\n }\n address registration = _registrations[registrant];\n if (registration != address(0)) {\n revert AlreadyRegistered();\n }\n address registrantRegistration = _registrations[registrantToCopy];\n if (registrantRegistration == address(0)) {\n revert NotRegistered(registrantToCopy);\n }\n _registrations[registrant] = registrant;\n emit RegistrationUpdated(registrant, true);\n _copyEntries(registrant, registrantToCopy);\n }\n\n /**\n * @notice Update an operator address for a registered address - when filtered is true, the operator is filtered.\n */\n function updateOperator(address registrant, address operator, bool filtered)\n external\n onlyAddressOrOwner(registrant)\n {\n address registration = _registrations[registrant];\n if (registration == address(0)) {\n revert NotRegistered(registrant);\n }\n if (registration != registrant) {\n revert CannotUpdateWhileSubscribed(registration);\n }\n EnumerableSet.AddressSet storage filteredOperatorsRef = _filteredOperators[registrant];\n\n if (!filtered) {\n bool removed = filteredOperatorsRef.remove(operator);\n if (!removed) {\n revert AddressNotFiltered(operator);\n }\n } else {\n bool added = filteredOperatorsRef.add(operator);\n if (!added) {\n revert AddressAlreadyFiltered(operator);\n }\n }\n emit OperatorUpdated(registrant, operator, filtered);\n }\n\n /**\n * @notice Update a codeHash for a registered address - when filtered is true, the codeHash is filtered.\n */\n function updateCodeHash(address registrant, bytes32 codeHash, bool filtered)\n external\n onlyAddressOrOwner(registrant)\n {\n if (codeHash == EOA_CODEHASH) {\n revert CannotFilterEOAs();\n }\n address registration = _registrations[registrant];\n if (registration == address(0)) {\n revert NotRegistered(registrant);\n }\n if (registration != registrant) {\n revert CannotUpdateWhileSubscribed(registration);\n }\n EnumerableSet.Bytes32Set storage filteredCodeHashesRef = _filteredCodeHashes[registrant];\n\n if (!filtered) {\n bool removed = filteredCodeHashesRef.remove(codeHash);\n if (!removed) {\n revert CodeHashNotFiltered(codeHash);\n }\n } else {\n bool added = filteredCodeHashesRef.add(codeHash);\n if (!added) {\n revert CodeHashAlreadyFiltered(codeHash);\n }\n }\n emit CodeHashUpdated(registrant, codeHash, filtered);\n }\n\n /**\n * @notice Update multiple operators for a registered address - when filtered is true, the operators will be filtered. Reverts on duplicates.\n */\n function updateOperators(address registrant, address[] calldata operators, bool filtered)\n external\n onlyAddressOrOwner(registrant)\n {\n address registration = _registrations[registrant];\n if (registration == address(0)) {\n revert NotRegistered(registrant);\n }\n if (registration != registrant) {\n revert CannotUpdateWhileSubscribed(registration);\n }\n EnumerableSet.AddressSet storage filteredOperatorsRef = _filteredOperators[registrant];\n uint256 operatorsLength = operators.length;\n unchecked {\n if (!filtered) {\n for (uint256 i = 0; i \u003c operatorsLength; ++i) {\n address operator = operators[i];\n bool removed = filteredOperatorsRef.remove(operator);\n if (!removed) {\n revert AddressNotFiltered(operator);\n }\n }\n } else {\n for (uint256 i = 0; i \u003c operatorsLength; ++i) {\n address operator = operators[i];\n bool added = filteredOperatorsRef.add(operator);\n if (!added) {\n revert AddressAlreadyFiltered(operator);\n }\n }\n }\n }\n emit OperatorsUpdated(registrant, operators, filtered);\n }\n\n /**\n * @notice Update multiple codeHashes for a registered address - when filtered is true, the codeHashes will be filtered. Reverts on duplicates.\n */\n function updateCodeHashes(address registrant, bytes32[] calldata codeHashes, bool filtered)\n external\n onlyAddressOrOwner(registrant)\n {\n address registration = _registrations[registrant];\n if (registration == address(0)) {\n revert NotRegistered(registrant);\n }\n if (registration != registrant) {\n revert CannotUpdateWhileSubscribed(registration);\n }\n EnumerableSet.Bytes32Set storage filteredCodeHashesRef = _filteredCodeHashes[registrant];\n uint256 codeHashesLength = codeHashes.length;\n unchecked {\n if (!filtered) {\n for (uint256 i = 0; i \u003c codeHashesLength; ++i) {\n bytes32 codeHash = codeHashes[i];\n bool removed = filteredCodeHashesRef.remove(codeHash);\n if (!removed) {\n revert CodeHashNotFiltered(codeHash);\n }\n }\n } else {\n for (uint256 i = 0; i \u003c codeHashesLength; ++i) {\n bytes32 codeHash = codeHashes[i];\n if (codeHash == EOA_CODEHASH) {\n revert CannotFilterEOAs();\n }\n bool added = filteredCodeHashesRef.add(codeHash);\n if (!added) {\n revert CodeHashAlreadyFiltered(codeHash);\n }\n }\n }\n }\n emit CodeHashesUpdated(registrant, codeHashes, filtered);\n }\n\n /**\n * @notice Subscribe an address to another registrant\u0027s filtered operators and codeHashes. Will remove previous\n * subscription if present.\n * Note that accounts with subscriptions may go on to subscribe to other accounts - in this case,\n * subscriptions will not be forwarded. Instead the former subscription\u0027s existing entries will still be\n * used.\n */\n function subscribe(address registrant, address newSubscription) external onlyAddressOrOwner(registrant) {\n if (registrant == newSubscription) {\n revert CannotSubscribeToSelf();\n }\n if (newSubscription == address(0)) {\n revert CannotSubscribeToZeroAddress();\n }\n address registration = _registrations[registrant];\n if (registration == address(0)) {\n revert NotRegistered(registrant);\n }\n if (registration == newSubscription) {\n revert AlreadySubscribed(newSubscription);\n }\n address newSubscriptionRegistration = _registrations[newSubscription];\n if (newSubscriptionRegistration == address(0)) {\n revert NotRegistered(newSubscription);\n }\n if (newSubscriptionRegistration != newSubscription) {\n revert CannotSubscribeToRegistrantWithSubscription(newSubscription);\n }\n\n if (registration != registrant) {\n _subscribers[registration].remove(registrant);\n emit SubscriptionUpdated(registrant, registration, false);\n }\n _registrations[registrant] = newSubscription;\n _subscribers[newSubscription].add(registrant);\n emit SubscriptionUpdated(registrant, newSubscription, true);\n }\n\n /**\n * @notice Unsubscribe an address from its current subscribed registrant, and optionally copy its filtered operators and codeHashes.\n */\n function unsubscribe(address registrant, bool copyExistingEntries) external onlyAddressOrOwner(registrant) {\n address registration = _registrations[registrant];\n if (registration == address(0)) {\n revert NotRegistered(registrant);\n }\n if (registration == registrant) {\n revert NotSubscribed();\n }\n _subscribers[registration].remove(registrant);\n _registrations[registrant] = registrant;\n emit SubscriptionUpdated(registrant, registration, false);\n if (copyExistingEntries) {\n _copyEntries(registrant, registration);\n }\n }\n\n /**\n * @notice Copy filtered operators and codeHashes from a different registrantToCopy to addr.\n */\n function copyEntriesOf(address registrant, address registrantToCopy) external onlyAddressOrOwner(registrant) {\n if (registrant == registrantToCopy) {\n revert CannotCopyFromSelf();\n }\n address registration = _registrations[registrant];\n if (registration == address(0)) {\n revert NotRegistered(registrant);\n }\n if (registration != registrant) {\n revert CannotUpdateWhileSubscribed(registration);\n }\n address registrantRegistration = _registrations[registrantToCopy];\n if (registrantRegistration == address(0)) {\n revert NotRegistered(registrantToCopy);\n }\n _copyEntries(registrant, registrantToCopy);\n }\n\n /// @dev helper to copy entries from registrantToCopy to registrant and emit events\n function _copyEntries(address registrant, address registrantToCopy) private {\n EnumerableSet.AddressSet storage filteredOperatorsRef = _filteredOperators[registrantToCopy];\n EnumerableSet.Bytes32Set storage filteredCodeHashesRef = _filteredCodeHashes[registrantToCopy];\n uint256 filteredOperatorsLength = filteredOperatorsRef.length();\n uint256 filteredCodeHashesLength = filteredCodeHashesRef.length();\n unchecked {\n for (uint256 i = 0; i \u003c filteredOperatorsLength; ++i) {\n address operator = filteredOperatorsRef.at(i);\n bool added = _filteredOperators[registrant].add(operator);\n if (added) {\n emit OperatorUpdated(registrant, operator, true);\n }\n }\n for (uint256 i = 0; i \u003c filteredCodeHashesLength; ++i) {\n bytes32 codehash = filteredCodeHashesRef.at(i);\n bool added = _filteredCodeHashes[registrant].add(codehash);\n if (added) {\n emit CodeHashUpdated(registrant, codehash, true);\n }\n }\n }\n }\n\n //////////////////\n // VIEW METHODS //\n //////////////////\n\n /**\n * @notice Get the subscription address of a given registrant, if any.\n */\n function subscriptionOf(address registrant) external view returns (address subscription) {\n subscription = _registrations[registrant];\n if (subscription == address(0)) {\n revert NotRegistered(registrant);\n } else if (subscription == registrant) {\n subscription = address(0);\n }\n }\n\n /**\n * @notice Get the set of addresses subscribed to a given registrant.\n * Note that order is not guaranteed as updates are made.\n */\n function subscribers(address registrant) external view returns (address[] memory) {\n return _subscribers[registrant].values();\n }\n\n /**\n * @notice Get the subscriber at a given index in the set of addresses subscribed to a given registrant.\n * Note that order is not guaranteed as updates are made.\n */\n function subscriberAt(address registrant, uint256 index) external view returns (address) {\n return _subscribers[registrant].at(index);\n }\n\n /**\n * @notice Returns true if operator is filtered by a given address or its subscription.\n */\n function isOperatorFiltered(address registrant, address operator) external view returns (bool) {\n address registration = _registrations[registrant];\n if (registration != registrant) {\n return _filteredOperators[registration].contains(operator);\n }\n return _filteredOperators[registrant].contains(operator);\n }\n\n /**\n * @notice Returns true if a codeHash is filtered by a given address or its subscription.\n */\n function isCodeHashFiltered(address registrant, bytes32 codeHash) external view returns (bool) {\n address registration = _registrations[registrant];\n if (registration != registrant) {\n return _filteredCodeHashes[registration].contains(codeHash);\n }\n return _filteredCodeHashes[registrant].contains(codeHash);\n }\n\n /**\n * @notice Returns true if the hash of an address\u0027s code is filtered by a given address or its subscription.\n */\n function isCodeHashOfFiltered(address registrant, address operatorWithCode) external view returns (bool) {\n bytes32 codeHash = operatorWithCode.codehash;\n address registration = _registrations[registrant];\n if (registration != registrant) {\n return _filteredCodeHashes[registration].contains(codeHash);\n }\n return _filteredCodeHashes[registrant].contains(codeHash);\n }\n\n /**\n * @notice Returns true if an address has registered\n */\n function isRegistered(address registrant) external view returns (bool) {\n return _registrations[registrant] != address(0);\n }\n\n /**\n * @notice Returns a list of filtered operators for a given address or its subscription.\n */\n function filteredOperators(address registrant) external view returns (address[] memory) {\n address registration = _registrations[registrant];\n if (registration != registrant) {\n return _filteredOperators[registration].values();\n }\n return _filteredOperators[registrant].values();\n }\n\n /**\n * @notice Returns the set of filtered codeHashes for a given address or its subscription.\n * Note that order is not guaranteed as updates are made.\n */\n function filteredCodeHashes(address registrant) external view returns (bytes32[] memory) {\n address registration = _registrations[registrant];\n if (registration != registrant) {\n return _filteredCodeHashes[registration].values();\n }\n return _filteredCodeHashes[registrant].values();\n }\n\n /**\n * @notice Returns the filtered operator at the given index of the set of filtered operators for a given address or\n * its subscription.\n * Note that order is not guaranteed as updates are made.\n */\n function filteredOperatorAt(address registrant, uint256 index) external view returns (address) {\n address registration = _registrations[registrant];\n if (registration != registrant) {\n return _filteredOperators[registration].at(index);\n }\n return _filteredOperators[registrant].at(index);\n }\n\n /**\n * @notice Returns the filtered codeHash at the given index of the list of filtered codeHashes for a given address or\n * its subscription.\n * Note that order is not guaranteed as updates are made.\n */\n function filteredCodeHashAt(address registrant, uint256 index) external view returns (bytes32) {\n address registration = _registrations[registrant];\n if (registration != registrant) {\n return _filteredCodeHashes[registration].at(index);\n }\n return _filteredCodeHashes[registrant].at(index);\n }\n\n /// @dev Convenience method to compute the code hash of an arbitrary contract\n function codeHashOf(address a) external view returns (bytes32) {\n return a.codehash;\n }\n}\n"},"OperatorFilterRegistryErrorsAndEvents.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\ncontract OperatorFilterRegistryErrorsAndEvents {\n error CannotFilterEOAs();\n error AddressAlreadyFiltered(address operator);\n error AddressNotFiltered(address operator);\n error CodeHashAlreadyFiltered(bytes32 codeHash);\n error CodeHashNotFiltered(bytes32 codeHash);\n error OnlyAddressOrOwner();\n error NotRegistered(address registrant);\n error AlreadyRegistered();\n error AlreadySubscribed(address subscription);\n error NotSubscribed();\n error CannotUpdateWhileSubscribed(address subscription);\n error CannotSubscribeToSelf();\n error CannotSubscribeToZeroAddress();\n error NotOwnable();\n error AddressFiltered(address filtered);\n error CodeHashFiltered(address account, bytes32 codeHash);\n error CannotSubscribeToRegistrantWithSubscription(address registrant);\n error CannotCopyFromSelf();\n\n event RegistrationUpdated(address indexed registrant, bool indexed registered);\n event OperatorUpdated(address indexed registrant, address indexed operator, bool indexed filtered);\n event OperatorsUpdated(address indexed registrant, address[] operators, bool indexed filtered);\n event CodeHashUpdated(address indexed registrant, bytes32 indexed codeHash, bool indexed filtered);\n event CodeHashesUpdated(address indexed registrant, bytes32[] codeHashes, bool indexed filtered);\n event SubscriptionUpdated(address indexed registrant, address indexed subscription, bool indexed subscribed);\n}\n"},"Ownable.sol":{"content":"// SPDX-License-Identifier: MIT\r\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\r\n\r\npragma solidity ^0.8.0;\r\n\r\nimport \"./Context.sol\";\r\n\r\n/**\r\n * @dev Contract module which provides a basic access control mechanism, where\r\n * there is an account (an owner) that can be granted exclusive access to\r\n * specific functions.\r\n *\r\n * By default, the owner account will be the one that deploys the contract. This\r\n * can later be changed with {transferOwnership}.\r\n *\r\n * This module is used through inheritance. It will make available the modifier\r\n * `onlyOwner`, which can be applied to your functions to restrict their use to\r\n * the owner.\r\n */\r\nabstract contract Ownable is Context {\r\n address private _owner;\r\n\r\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\r\n\r\n /**\r\n * @dev Initializes the contract setting the deployer as the initial owner.\r\n */\r\n constructor() {\r\n _transferOwnership(_msgSender());\r\n }\r\n\r\n /**\r\n * @dev Throws if called by any account other than the owner.\r\n */\r\n modifier onlyOwner() {\r\n _checkOwner();\r\n _;\r\n }\r\n\r\n /**\r\n * @dev Returns the address of the current owner.\r\n */\r\n function owner() public view virtual returns (address) {\r\n return _owner;\r\n }\r\n\r\n /**\r\n * @dev Throws if the sender is not the owner.\r\n */\r\n function _checkOwner() internal view virtual {\r\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\r\n }\r\n\r\n /**\r\n * @dev Leaves the contract without owner. It will not be possible to call\r\n * `onlyOwner` functions anymore. Can only be called by the current owner.\r\n *\r\n * NOTE: Renouncing ownership will leave the contract without an owner,\r\n * thereby removing any functionality that is only available to the owner.\r\n */\r\n function renounceOwnership() public virtual onlyOwner {\r\n _transferOwnership(address(0));\r\n }\r\n\r\n /**\r\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\r\n * Can only be called by the current owner.\r\n */\r\n function transferOwnership(address newOwner) public virtual onlyOwner {\r\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\r\n _transferOwnership(newOwner);\r\n }\r\n\r\n /**\r\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\r\n * Internal function without access restriction.\r\n */\r\n function _transferOwnership(address newOwner) internal virtual {\r\n address oldOwner = _owner;\r\n _owner = newOwner;\r\n emit OwnershipTransferred(oldOwner, newOwner);\r\n }\r\n}"},"OwnedRegistrant.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\nimport {IOperatorFilterRegistry} from \"./IOperatorFilterRegistry.sol\";\nimport {Ownable2Step} from \"./EnumerableSet.sol\";\n\n/**\n * @title OwnedRegistrant\n * @notice Ownable contract that registers itself with the OperatorFilterRegistry and administers its own entries,\n * to facilitate a subscription whose ownership can be transferred.\n */\ncontract OwnedRegistrant is Ownable2Step {\n address constant registry = 0x000000000000AAeB6D7670E522A718067333cd4E;\n\n constructor(address _owner) {\n IOperatorFilterRegistry(registry).register(address(this));\n transferOwnership(_owner);\n }\n}\n"},"Sanctum.sol":{"content":"// SPDX-License-Identifier: MIT\r\n\r\n/* _____ _ ____ _ \r\n|_ _| |__ ___ / ___| __ _ _ __ ___| |_ _ _ _ __ ___ \r\n | | | \u0027_ \\ / _ \\ \\___ \\ / _` | \u0027_ \\ / __| __| | | | \u0027_ ` _ \\ \r\n | | | | | | __/ ___) | (_| | | | | (__| |_| |_| | | | | | |\r\n |_| |_| |_|\\___| |____/ \\__,_|_| |_|\\___|\\__|\\__,_|_| |_| |_|\r\n*/\r\n\r\n\r\npragma solidity ^0.8.7;\r\nimport \"./Ownable.sol\";\r\nimport \"./Strings.sol\";\r\nimport \"./ERC721A.sol\";\r\nimport \"./Markle.sol\";\r\n\r\n\r\ncontract TheSanctum_Neophytes is ERC721A, Ownable{\r\n using Strings for uint256;\r\n \r\n uint public tokenPrice = 0.01 ether;\r\n uint constant maxSupply = 10000;\r\n uint constant GenesismaxSupply = 2000;\r\n bool public Genesis_status = false;\r\n bool public Presale_status = false;\r\n bool public public_sale_status = false;\r\n bool public isBurnEnabled=false;\r\n bytes32 public whitelistMerkleRoot;\r\n bytes32 public GenesisMerkleRoot;\r\n \r\n mapping(address =\u003e bool) private presaleList;\r\n string public baseURI;\r\n mapping(address =\u003e uint256) public totalPublicMint;\r\n mapping(address =\u003e uint256) public totalWhitelistMint;\r\n mapping(address =\u003e uint256) public totalGenesisMint;\r\n mapping(uint256 =\u003e address) public burnedby;\r\n mapping(address =\u003e bool) public isclaimedbyaddress;\r\n mapping(uint =\u003e bool) public isclaimedbytoken;\r\n uint public maxPerTransaction = 5; //Max Limit Per TX\r\n uint public maxPerWalletPresale = 2; //Max Limit for Presale\r\n uint public maxPerGenesis = 1;\r\n \r\n constructor() ERC721A(\"The Sanctum-Neophytes\", \"Neophytes\"){}\r\n\r\n\r\n function Public_mint(uint _count) public payable{\r\n require(public_sale_status == true, \"Sale is Paused.\");\r\n require(_count \u003e 0, \"mint at least one token\");\r\n require(totalSupply() + _count \u003c= maxSupply, \"Sold Out!\");\r\n require(msg.value \u003e= tokenPrice * _count, \"incorrect ether amount\");\r\n require(_count \u003c= maxPerTransaction, \"ONLY 5 NEOPHYTES ALLOWED PER TRANSACTION\");\r\n totalPublicMint[msg.sender] += _count;\r\n _safeMint(msg.sender, _count);\r\n }\r\n\r\n function Whitelist_mint(uint _count,bytes32[] calldata merkleProof) external payable{ \r\n uint genesis_token_id=Genesis_holders(msg.sender);\r\n require(Presale_status == true, \"THE MAGIC MINT HAS NOT STARTED YET\");\r\n require(MerkleProof.verify(merkleProof,whitelistMerkleRoot,keccak256(abi.encodePacked(msg.sender))),\"YOUR WALLET IS NOT WHITELISTED\");\r\n require(_count \u003c= maxPerWalletPresale, \"ONLY 2 NEOPHYTES ALLOWED PER TRANSACTION\");\r\n require(totalSupply() + _count \u003c= maxSupply, \"Sold Out!\");\r\n require((totalWhitelistMint[msg.sender] +_count) \u003c= maxPerWalletPresale, \"ONLY 2 NEOPHYTES ALLOWED PER WALLET\");\r\n if(genesis_token_id==0)\r\n {\r\n require(msg.value \u003e= tokenPrice * _count, \"incorrect ether amount\");\r\n _safeMint(msg.sender, _count);\r\n totalWhitelistMint[msg.sender] += _count;\r\n }\r\n else{\r\n require(msg.value \u003e= (tokenPrice * _count)-(tokenPrice/10), \"incorrect ether amount\");\r\n _safeMint(msg.sender, _count);\r\n totalWhitelistMint[msg.sender] += _count;\r\n isclaimedbyaddress[msg.sender] = true;\r\n isclaimedbytoken[genesis_token_id] = true;\r\n\r\n }\r\n }\r\n\r\n function Genesis_mint(uint _count,bytes32[] calldata merkleProof) external{ \r\n require(Genesis_status == true, \"THE MAGIC MINT HAS NOT STARTED YET\");\r\n require(MerkleProof.verify(merkleProof,GenesisMerkleRoot,keccak256(abi.encodePacked(msg.sender))),\"YOUR WALLET IS NOT WHITELISTED\");\r\n require(_count \u003c= maxPerGenesis, \"max per transaction 1\");\r\n require(totalSupply() + _count\u003c= GenesismaxSupply, \"Genesis Collection Sold out\");\r\n require((totalGenesisMint[msg.sender] +_count) \u003c= maxPerGenesis, \"ONLY 1 GENESIS NEOPHYTE ALLOWED PER WALLET\");\r\n \r\n totalGenesisMint[msg.sender] += _count;\r\n _safeMint(msg.sender, _count);\r\n }\r\n\r\n function Whitelist_checker(address walletAddress, bytes32[] calldata merkleProof) public view returns (bool){ \r\n if(MerkleProof.verify(merkleProof,whitelistMerkleRoot,keccak256(abi.encodePacked(walletAddress))))\r\n {\r\n return true;\r\n }\r\n else\r\n {return false;}\r\n \r\n }\r\n function Genesis_checker(address walletAddress, bytes32[] calldata merkleProof) public view returns (bool){ \r\n if(MerkleProof.verify(merkleProof,GenesisMerkleRoot,keccak256(abi.encodePacked(walletAddress))))\r\n {\r\n return true;\r\n }\r\n else\r\n {return false;}\r\n \r\n }\r\n function Genesis_holders(address walletAddress) public view returns (uint){ \r\n uint value=0;\r\n uint maxlimit= GenesismaxSupply;\r\n if(totalSupply()\u003cGenesismaxSupply){\r\n maxlimit=totalSupply();\r\n }\r\n for(uint i=1; i\u003c=maxlimit; i++)\r\n {\r\n if(ownerOf(i)==walletAddress \u0026\u0026 !isclaimedbyaddress[walletAddress] \u0026\u0026 !isclaimedbytoken[i])\r\n {\r\n value=i;\r\n break;\r\n }\r\n }\r\n return value;\r\n \r\n }\r\n\r\n function adminMint(uint _count) external onlyOwner{\r\n require(_count \u003e 0, \"mint at least one token\");\r\n require(totalSupply() + _count \u003c= maxSupply, \"Sold Out!\");\r\n _safeMint(msg.sender, _count);\r\n }\r\n\r\n function sendGifts(address[] memory _wallets) public onlyOwner{\r\n require(totalSupply() + _wallets.length \u003c= maxSupply, \"Sold Out!\");\r\n for(uint i = 0; i \u003c _wallets.length; i++)\r\n _safeMint(_wallets[i], 1);\r\n }\r\n function _baseURI() internal view virtual override returns (string memory) {\r\n return baseURI;\r\n }\r\n\r\n //return uri for certain token\r\n function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {\r\n require(_exists(tokenId), \"ERC721Metadata: URI query for nonexistent token\");\r\n\r\n return bytes(baseURI).length \u003e 0 ? string(abi.encodePacked(baseURI, tokenId.toString(), \".json\")) : \"\";\r\n }\r\n\r\n function setBaseUri(string memory _uri) external onlyOwner {\r\n baseURI = _uri;\r\n }\r\n function Presale_Status(bool status) external onlyOwner {\r\n Presale_status = status;\r\n }\r\n function Genesis_status_update(bool status) external onlyOwner {\r\n Genesis_status = status;\r\n }\r\n function Public_status_update(bool status) external onlyOwner {\r\n public_sale_status = status;\r\n }\r\n function update_burning_status(bool status) external onlyOwner {\r\n isBurnEnabled = status;\r\n }\r\n\r\n function SetWhitelist(bytes32 merkleRoot) external onlyOwner {\r\n\t\twhitelistMerkleRoot = merkleRoot;\r\n\t}\r\n function SetGenesis(bytes32 merkleRoot) external onlyOwner {\r\n\t\tGenesisMerkleRoot = merkleRoot;\r\n\t}\r\n \r\n function burn(uint256 tokenId) external \r\n {\r\n require(isBurnEnabled, \"burning disabled\");\r\n require(\r\n _isApprovedOrOwner(msg.sender, tokenId),\r\n \"burn caller is not approved\"\r\n );\r\n _burn(tokenId);\r\n burnedby[tokenId] = msg.sender;\r\n }\r\n function public_sale_price(uint pr) external onlyOwner {\r\n tokenPrice = pr;\r\n }\r\n\r\n function withdraw() external onlyOwner {\r\n payable(owner()).transfer(address(this).balance);\r\n }\r\n}"},"Strings.sol":{"content":"// SPDX-License-Identifier: MIT\r\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol)\r\n\r\npragma solidity ^0.8.0;\r\n\r\nimport \"./Math.sol\";\r\n\r\n/**\r\n * @dev String operations.\r\n */\r\nlibrary Strings {\r\n bytes16 private constant _SYMBOLS = \"0123456789abcdef\";\r\n uint8 private constant _ADDRESS_LENGTH = 20;\r\n\r\n /**\r\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\r\n */\r\n function toString(uint256 value) internal pure returns (string memory) {\r\n unchecked {\r\n uint256 length = Math.log10(value) + 1;\r\n string memory buffer = new string(length);\r\n uint256 ptr;\r\n /// @solidity memory-safe-assembly\r\n assembly {\r\n ptr := add(buffer, add(32, length))\r\n }\r\n while (true) {\r\n ptr--;\r\n /// @solidity memory-safe-assembly\r\n assembly {\r\n mstore8(ptr, byte(mod(value, 10), _SYMBOLS))\r\n }\r\n value /= 10;\r\n if (value == 0) break;\r\n }\r\n return buffer;\r\n }\r\n }\r\n\r\n /**\r\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\r\n */\r\n function toHexString(uint256 value) internal pure returns (string memory) {\r\n unchecked {\r\n return toHexString(value, Math.log256(value) + 1);\r\n }\r\n }\r\n\r\n /**\r\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\r\n */\r\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\r\n bytes memory buffer = new bytes(2 * length + 2);\r\n buffer[0] = \"0\";\r\n buffer[1] = \"x\";\r\n for (uint256 i = 2 * length + 1; i \u003e 1; --i) {\r\n buffer[i] = _SYMBOLS[value \u0026 0xf];\r\n value \u003e\u003e= 4;\r\n }\r\n require(value == 0, \"Strings: hex length insufficient\");\r\n return string(buffer);\r\n }\r\n\r\n /**\r\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\r\n */\r\n function toHexString(address addr) internal pure returns (string memory) {\r\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\r\n }\r\n}"}}