Address: 0xbB846B7827D8705Bf886C68ef6B4Fdde738A139A
Balance (XRP): 0 XRP
Bytecode: 0x608060408181526004918236101561001657600080fd5b600092833560e01c91826301ffc9a714610ea55750816306fdde0314610df4578163081812fc14610db8578163095ea7b314610cdb57816318160ddd14610cbc57816323b872dd14610ca45781632f745c5914610c2057816340c10f1914610b9757816342842e0e14610b4957816342966c6814610ae5578163481c6a7514610abc5781634f6ccce714610a6757816355f804b31461091c5781636352211e146108eb5781636c0360eb1461084a57816370a082311461081d578163938e3d7b1461068e57816395d89b41146105da578163a22cb4651461053c578163b88d4fde146104d4578163c87b56dd1461026357508063e8a3d485146101725763e985e9c51461012257600080fd5b3461016e578060031936011261016e5760ff81602093610140610f72565b610148610f8d565b6001600160a01b0391821683526005875283832091168252855220549151911615158152f35b5080fd5b5090346102605780600319360112610260578151918282600b54610195816110a2565b90818452602095600191876001821691826000146102395750506001146101dd575b5050506101d992916101ca910385610fd8565b51928284938452830190610f4d565b0390f35b9190869350600b83527f0175b7a638427703f0dbe7bb9bbf987a2551717b34e79f33b5b1008d1fa01db95b82841061022157505050820101816101ca6101d96101b7565b8054848a018601528895508794909301928101610208565b60ff19168782015293151560051b860190930193508492506101ca91506101d990506101b7565b80fd5b919050346104d057602091826003193601126104cc578035906102858261131e565b50819085907a184f03e93ff9f4daa797ed6e38ed64bf6a1f01000000000000000083818110156104bf575b5050856d04ee2d6d415b85acef8100000000808510156104b0575b5050662386f26fc10000808410156104a1575b506305f5e10080841015610492575b5061271080841015610486575b50506064821015610478575b600a80921015610470575b6001918282019383602161033c61032788611010565b976103348a51998a610fd8565b808952611010565b878a019590601f1901368737870101905b610441575b505050835195869381600a5490610368826110a2565b918987821691826000146104185750506001146103c3575b50509264173539b7b760d91b600693836103af6101ca97602f60f81b6101d99b9a975251809386840190610f2a565b019182015203601919810187520185610fd8565b88929350600a8198979698526000805160206119748339815191525b828210610400575095969495508501019064173539b7b760d91b6006610380565b80548b83018501528a965089939091019088016103df565b60ff1916818a01528315159093028801909201935064173539b7b760d91b915060069050610380565b600019019082906f181899199a1a9b1b9c1cb0b131b232b360811b8282061a83530490848261034d5750610352565b600101610311565b906064600291049101610306565b909204910138806102fa565b600891929304920190386102ed565b601091929304920190386102de565b909192930492019085386102cb565b04925084915038806102b0565b8380fd5b8280fd5b83903461016e57608036600319011261016e576104ef610f72565b6104f7610f8d565b9060643567ffffffffffffffff81116105385736602382011215610538576105359381602461052b9336930135910161102c565b91604435916111cf565b80f35b8480fd5b919050346104d057806003193601126104d057610557610f72565b9060243591821515809303610538576001600160a01b03169283156105c55750338452600560205280842083855260205280842060ff1981541660ff8416179055519081527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3160203392a380f35b836024925191630b61174360e31b8352820152fd5b828434610260578060031936011261026057815191828260019360015494610601866110a2565b9182855260209687600182169182600014610239575050600114610632575050506101d992916101ca910385610fd8565b9190869350600183527fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf65b82841061067657505050820101816101ca6101d96101b7565b8054848a01860152889550879490930192810161065d565b8391503461016e5761069f36611063565b600c549093906001600160a01b03163303610810575082519067ffffffffffffffff82116107fd57506106d3600b546110a2565b601f811161079a575b50602080601f83116001146107195750829382939261070e575b50508160011b916000199060031b1c191617600b5580f35b0151905083806106f6565b600b8452601f198316947f0175b7a638427703f0dbe7bb9bbf987a2551717b34e79f33b5b1008d1fa01db9929185905b878210610782575050836001959610610769575b505050811b01600b5580f35b015160001960f88460031b161c1916905583808061075d565b80600185968294968601518155019501930190610749565b600b83527f0175b7a638427703f0dbe7bb9bbf987a2551717b34e79f33b5b1008d1fa01db9601f830160051c810191602084106107f3575b601f0160051c01905b8181106107e857506106dc565b8381556001016107db565b90915081906107d2565b634e487b7160e01b835260419052602482fd5b516347de47bb60e11b8152fd5b50503461016e57602036600319011261016e5760209061084361083e610f72565b611196565b9051908152f35b8284346102605780600319360112610260578151918282600a5461086d816110a2565b90818452602095600191876001821691826000146102395750506001146108a1575050506101d992916101ca910385610fd8565b9190869350600a83526000805160206119748339815191525b8284106108d357505050820101816101ca6101d96101b7565b8054848a0186015288955087949093019281016108ba565b828434610260576020366003190112610260575061090b6020923561131e565b90516001600160a01b039091168152f35b8391503461016e5761092d36611063565b600c549093906001600160a01b03163303610810575082519067ffffffffffffffff82116107fd5750610961600a546110a2565b601f8111610a16575b50602080601f83116001146109a75750829382939261099c575b50508160011b916000199060031b1c191617600a5580f35b015190508380610984565b600a8452601f19831694600080516020611974833981519152929185905b8782106109fe5750508360019596106109e5575b505050811b01600a5580f35b015160001960f88460031b161c191690558380806109d9565b806001859682949686015181550195019301906109c5565b600a8352600080516020611974833981519152601f830160051c81019160208410610a5d575b601f0160051c01905b818110610a52575061096a565b838155600101610a45565b9091508190610a3c565b9050346104d05760203660031901126104d057803592600854841015610aa157602083610a9386611149565b91905490519160031b1c8152f35b6044939192519263295f44f760e21b84528301526024820152fd5b50503461016e578160031936011261016e57600c5490516001600160a01b039091168152602090f35b919050346104d05760203660031901126104d057600c54823591906001600160a01b039081163303610b3957610b1a83611682565b1615610b24578380f35b51637e27328960e01b81529182015260249150fd5b81516347de47bb60e11b81528490fd5b83833461016e57610b5936610fa3565b91835193602085019085821067ffffffffffffffff831117610b8457610535969750528584526111cf565b634e487b7160e01b875260418852602487fd5b919050346104d057806003193601126104d057610bb2610f72565b600c546001600160a01b03919082163303610c115781811615610bfa57610bdc9060243590611359565b16610be5578280f35b9160249251916339e3563760e11b8352820152fd5b8251633250574960e11b8152808501869052602490fd5b5050516347de47bb60e11b8152fd5b828434610260578160031936011261026057610c3a610f72565b9260243590610c4885611196565b821015610c7857506001600160a01b03909316815260066020908152828220938252928352819020549051908152f35b925163295f44f760e21b81526001600160a01b0390941692840192835260208301525081906040010390fd5b833461026057610535610cb636610fa3565b916110dc565b50503461016e578160031936011261016e576020906008549051908152f35b919050346104d057806003193601126104d057610cf6610f72565b91602435610d038161131e565b33151580610da5575b80610d7c575b610d66576001600160a01b039485169482918691167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258880a48452602052822080546001600160a01b031916909117905580f35b835163a9fbf51f60e01b81523381850152602490fd5b506001600160a01b03811686526005602090815284872033885290528386205460ff1615610d12565b506001600160a01b038116331415610d0c565b9050346104d05760203660031901126104d057918260209335610dda8161131e565b50825283528190205490516001600160a01b039091168152f35b82843461026057806003193601126102605781519182828354610e16816110a2565b9081845260209560019187600182169182600014610239575050600114610e4a575050506101d992916101ca910385610fd8565b91908693508280527f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e5635b828410610e8d57505050820101816101ca6101d96101b7565b8054848a018601528895508794909301928101610e74565b8491346104d05760203660031901126104d0573563ffffffff60e01b81168091036104d0576020925063780e9d6360e01b8114908115610ee7575b5015158152f35b6380ac58cd60e01b811491508115610f19575b8115610f08575b5083610ee0565b6301ffc9a760e01b14905083610f01565b635b5e139f60e01b81149150610efa565b60005b838110610f3d5750506000910152565b8181015183820152602001610f2d565b90602091610f6681518092818552858086019101610f2a565b601f01601f1916010190565b600435906001600160a01b0382168203610f8857565b600080fd5b602435906001600160a01b0382168203610f8857565b6060906003190112610f88576001600160a01b03906004358281168103610f8857916024359081168103610f88579060443590565b90601f8019910116810190811067ffffffffffffffff821117610ffa57604052565b634e487b7160e01b600052604160045260246000fd5b67ffffffffffffffff8111610ffa57601f01601f191660200190565b92919261103882611010565b916110466040519384610fd8565b829481845281830111610f88578281602093846000960137010152565b6020600319820112610f88576004359067ffffffffffffffff8211610f885780602383011215610f885781602461109f9360040135910161102c565b90565b90600182811c921680156110d2575b60208310146110bc57565b634e487b7160e01b600052602260045260246000fd5b91607f16916110b1565b91906001600160a01b039081811615611130576110fc8291843391611808565b931692169082820361110d57505050565b60649350604051926364283d7b60e01b8452600484015260248301526044820152fd5b604051633250574960e11b815260006004820152602490fd5b6008548110156111805760086000527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30190600090565b634e487b7160e01b600052603260045260246000fd5b6001600160a01b031680156111b657600052600360205260406000205490565b6040516322718ad960e21b815260006004820152602490fd5b6111da8383836110dc565b813b6111e7575b50505050565b604051630a85bd0160e11b8082523360048301526001600160a01b03928316602483015260448201949094526080606482015260209592909116939092908390611235906084830190610f4d565b039285816000958187895af18491816112de575b506112a9575050503d6000146112a1573d61126381611010565b906112716040519283610fd8565b81528091843d92013e5b8051928361129c57604051633250574960e11b815260048101849052602490fd5b019050fd5b50606061127b565b919450915063ffffffff60e01b16036112c65750388080806111e1565b60249060405190633250574960e11b82526004820152fd5b9091508681813d8311611317575b6112f68183610fd8565b8101031261053857516001600160e01b031981168103610538579038611249565b503d6112ec565b6000818152600260205260409020546001600160a01b0316908115611341575090565b60249060405190637e27328960e01b82526004820152fd5b60008281526020906002825260018060a01b039360409480868420541694851590811561164f575b8281169081158015611639575b8587526002885289872080546001600160a01b0319168417905585838a7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8a80a483156115bd5760085486885260098952808b892055600160401b8110156115a9578661140482600161141d9401600855611149565b90919082549060031b91821b91600019901b1916179055565b1561155f5750506008546000199081810190811161154b57848652600987526114498987205491611149565b90549060031b1c61145d8161140484611149565b8652600987528886205583855284888120556008548015611537570161149661148582611149565b8154906000199060031b1b19169055565b6008555b61152e578390600c541691602487518094819363f4c3b4d760e01b835260048301525afa9283156115245782936114e9575b5050506114e4578151630d93a39b60e01b8152600490fd5b905090565b9080929350813d831161151d575b6115018183610fd8565b8101031261016e575190811515820361026057503880806114cc565b503d6114f7565b85513d84823e3d90fd5b50505050905090565b634e487b7160e01b86526031600452602486fd5b634e487b7160e01b86526011600452602486fd5b81880361156e575b505061149a565b61157790611196565b60001981019190821161154b578552600686528785208186528652838886205583855260078652878520553880611567565b634e487b7160e01b88526041600452602488fd5b88831461141d576115cd89611196565b868852600789528a882054818103611602575b50868852878b812055898852600689528a88209088528852868a81205561141d565b8a895260068a528b8920828a528a528b8920548b8a5260068b528c8a20828b528b52808d8b2055895260078a528b892055386115e0565b828752600388528987206001815401905561138e565b600084815260046020526040902080546001600160a01b0319169055868552600386528785208054600019019055611381565b60008181526002602090815260408083205490936001600160a01b03918216939184158015806117d5575b8385526002865287852080546001600160a01b03191690558385887fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8280a4811561175b5750600854838552600986528088862055600160401b81101561174757836114048260016117229401600855611149565b6008546000199081810190811161154b57848652600987526114498987205491611149565b634e487b7160e01b85526041600452602485fd5b156117225761176986611196565b838552600786528785205481810361179e575b5083855284888120558685526006865287852090855285528387812055611722565b87865260068752888620828752875288862054888752600688528987208288528852808a882055865260078752888620553861177c565b600084815260046020526040902080546001600160a01b03191690558685526003865287852080546000190190556116ad565b60008281526002602090815260408083205490956001600160a01b039182169592949082811680151590816118c6575b505050851590811561164f578281169081158015611639578587526002885289872080546001600160a01b0319168417905585838a7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8a80a483156115bd5760085486885260098952808b892055600160401b8110156115a9578661140482600161141d9401600855611149565b81611926575b50156118d9578080611838565b87849188156000146118fd578151637e27328960e01b815260048101849052602490fd5b905163177e802f60e01b81526001600160a01b0390911660048201526024810191909152604490fd5b88811491508115611956575b8115611940575b50386118cc565b9050848652600487528389872054161438611939565b8887526005885289872081885288528987205460ff16915061193256fec65a7bb8d6351c1cf70c95a316cc6a92839c986682d98bc35f958f4883f9d2a8a2646970667358221220eb37fae9c6c217793a8d77e88f43dab862a128134e35d3258f8c96dd897e6d1364736f6c63430008180033
draft-IERC6093.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC6093.sol) pragma solidity ^0.8.20; /** * @dev Standard ERC20 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC20 tokens. */ interface IERC20Errors { /** * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. * @param balance Current balance for the interacting account. * @param needed Minimum amount required to perform a transfer. */ error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed); /** * @dev Indicates a failure with the token `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. */ error ERC20InvalidSender(address sender); /** * @dev Indicates a failure with the token `receiver`. Used in transfers. * @param receiver Address to which tokens are being transferred. */ error ERC20InvalidReceiver(address receiver); /** * @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers. * @param spender Address that may be allowed to operate on tokens without being their owner. * @param allowance Amount of tokens a `spender` is allowed to operate with. * @param needed Minimum amount required to perform a transfer. */ error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed); /** * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals. * @param approver Address initiating an approval operation. */ error ERC20InvalidApprover(address approver); /** * @dev Indicates a failure with the `spender` to be approved. Used in approvals. * @param spender Address that may be allowed to operate on tokens without being their owner. */ error ERC20InvalidSpender(address spender); } /** * @dev Standard ERC721 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC721 tokens. */ interface IERC721Errors { /** * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in EIP-20. * Used in balance queries. * @param owner Address of the current owner of a token. */ error ERC721InvalidOwner(address owner); /** * @dev Indicates a `tokenId` whose `owner` is the zero address. * @param tokenId Identifier number of a token. */ error ERC721NonexistentToken(uint256 tokenId); /** * @dev Indicates an error related to the ownership over a particular token. Used in transfers. * @param sender Address whose tokens are being transferred. * @param tokenId Identifier number of a token. * @param owner Address of the current owner of a token. */ error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner); /** * @dev Indicates a failure with the token `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. */ error ERC721InvalidSender(address sender); /** * @dev Indicates a failure with the token `receiver`. Used in transfers. * @param receiver Address to which tokens are being transferred. */ error ERC721InvalidReceiver(address receiver); /** * @dev Indicates a failure with the `operator`’s approval. Used in transfers. * @param operator Address that may be allowed to operate on tokens without being their owner. * @param tokenId Identifier number of a token. */ error ERC721InsufficientApproval(address operator, uint256 tokenId); /** * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals. * @param approver Address initiating an approval operation. */ error ERC721InvalidApprover(address approver); /** * @dev Indicates a failure with the `operator` to be approved. Used in approvals. * @param operator Address that may be allowed to operate on tokens without being their owner. */ error ERC721InvalidOperator(address operator); } /** * @dev Standard ERC1155 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC1155 tokens. */ interface IERC1155Errors { /** * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. * @param balance Current balance for the interacting account. * @param needed Minimum amount required to perform a transfer. * @param tokenId Identifier number of a token. */ error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId); /** * @dev Indicates a failure with the token `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. */ error ERC1155InvalidSender(address sender); /** * @dev Indicates a failure with the token `receiver`. Used in transfers. * @param receiver Address to which tokens are being transferred. */ error ERC1155InvalidReceiver(address receiver); /** * @dev Indicates a failure with the `operator`’s approval. Used in transfers. * @param operator Address that may be allowed to operate on tokens without being their owner. * @param owner Address of the current owner of a token. */ error ERC1155MissingApprovalForAll(address operator, address owner); /** * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals. * @param approver Address initiating an approval operation. */ error ERC1155InvalidApprover(address approver); /** * @dev Indicates a failure with the `operator` to be approved. Used in approvals. * @param operator Address that may be allowed to operate on tokens without being their owner. */ error ERC1155InvalidOperator(address operator); /** * @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation. * Used in batch transfers. * @param idsLength Length of the array of token identifiers * @param valuesLength Length of the array of token amounts */ error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength); }
ERC721.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/ERC721.sol) pragma solidity ^0.8.20; import {IERC721} from "./IERC721.sol"; import {IERC721Receiver} from "./IERC721Receiver.sol"; import {IERC721Metadata} from "./extensions/IERC721Metadata.sol"; import {Context} from "../../utils/Context.sol"; import {Strings} from "../../utils/Strings.sol"; import {IERC165, ERC165} from "../../utils/introspection/ERC165.sol"; import {IERC721Errors} from "../../interfaces/draft-IERC6093.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ abstract contract ERC721 is Context, ERC165, IERC721, IERC721Metadata, IERC721Errors { using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; mapping(uint256 tokenId => address) private _owners; mapping(address owner => uint256) private _balances; mapping(uint256 tokenId => address) private _tokenApprovals; mapping(address owner => mapping(address operator => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual returns (uint256) { if (owner == address(0)) { revert ERC721InvalidOwner(address(0)); } return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual returns (address) { return _requireOwned(tokenId); } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual returns (string memory) { _requireOwned(tokenId); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string.concat(baseURI, tokenId.toString()) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overridden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual { _approve(to, tokenId, _msgSender()); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual returns (address) { _requireOwned(tokenId); return _getApproved(tokenId); } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom(address from, address to, uint256 tokenId) public virtual { if (to == address(0)) { revert ERC721InvalidReceiver(address(0)); } // Setting an "auth" arguments enables the `_isAuthorized` check which verifies that the token exists // (from != 0). Therefore, it is not needed to verify that the return value is not 0 here. address previousOwner = _update(to, tokenId, _msgSender()); if (previousOwner != from) { revert ERC721IncorrectOwner(from, tokenId, previousOwner); } } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom(address from, address to, uint256 tokenId) public { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public virtual { transferFrom(from, to, tokenId); _checkOnERC721Received(from, to, tokenId, data); } /** * @dev Returns the owner of the `tokenId`. Does NOT revert if token doesn't exist * * IMPORTANT: Any overrides to this function that add ownership of tokens not tracked by the * core ERC721 logic MUST be matched with the use of {_increaseBalance} to keep balances * consistent with ownership. The invariant to preserve is that for any address `a` the value returned by * `balanceOf(a)` must be equal to the number of tokens such that `_ownerOf(tokenId)` is `a`. */ function _ownerOf(uint256 tokenId) internal view virtual returns (address) { return _owners[tokenId]; } /** * @dev Returns the approved address for `tokenId`. Returns 0 if `tokenId` is not minted. */ function _getApproved(uint256 tokenId) internal view virtual returns (address) { return _tokenApprovals[tokenId]; } /** * @dev Returns whether `spender` is allowed to manage `owner`'s tokens, or `tokenId` in * particular (ignoring whether it is owned by `owner`). * * WARNING: This function assumes that `owner` is the actual owner of `tokenId` and does not verify this * assumption. */ function _isAuthorized(address owner, address spender, uint256 tokenId) internal view virtual returns (bool) { return spender != address(0) && (owner == spender || isApprovedForAll(owner, spender) || _getApproved(tokenId) == spender); } /** * @dev Checks if `spender` can operate on `tokenId`, assuming the provided `owner` is the actual owner. * Reverts if `spender` does not have approval from the provided `owner` for the given token or for all its assets * the `spender` for the specific `tokenId`. * * WARNING: This function assumes that `owner` is the actual owner of `tokenId` and does not verify this * assumption. */ function _checkAuthorized(address owner, address spender, uint256 tokenId) internal view virtual { if (!_isAuthorized(owner, spender, tokenId)) { if (owner == address(0)) { revert ERC721NonexistentToken(tokenId); } else { revert ERC721InsufficientApproval(spender, tokenId); } } } /** * @dev Unsafe write access to the balances, used by extensions that "mint" tokens using an {ownerOf} override. * * NOTE: the value is limited to type(uint128).max. This protect against _balance overflow. It is unrealistic that * a uint256 would ever overflow from increments when these increments are bounded to uint128 values. * * WARNING: Increasing an account's balance using this function tends to be paired with an override of the * {_ownerOf} function to resolve the ownership of the corresponding tokens so that balances and ownership * remain consistent with one another. */ function _increaseBalance(address account, uint128 value) internal virtual { unchecked { _balances[account] += value; } } /** * @dev Transfers `tokenId` from its current owner to `to`, or alternatively mints (or burns) if the current owner * (or `to`) is the zero address. Returns the owner of the `tokenId` before the update. * * The `auth` argument is optional. If the value passed is non 0, then this function will check that * `auth` is either the owner of the token, or approved to operate on the token (by the owner). * * Emits a {Transfer} event. * * NOTE: If overriding this function in a way that tracks balances, see also {_increaseBalance}. */ function _update(address to, uint256 tokenId, address auth) internal virtual returns (address) { address from = _ownerOf(tokenId); // Perform (optional) operator check if (auth != address(0)) { _checkAuthorized(from, auth, tokenId); } // Execute the update if (from != address(0)) { // Clear approval. No need to re-authorize or emit the Approval event _approve(address(0), tokenId, address(0), false); unchecked { _balances[from] -= 1; } } if (to != address(0)) { unchecked { _balances[to] += 1; } } _owners[tokenId] = to; emit Transfer(from, to, tokenId); return from; } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal { if (to == address(0)) { revert ERC721InvalidReceiver(address(0)); } address previousOwner = _update(to, tokenId, address(0)); if (previousOwner != address(0)) { revert ERC721InvalidSender(address(0)); } } /** * @dev Mints `tokenId`, transfers it to `to` and checks for `to` acceptance. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint(address to, uint256 tokenId, bytes memory data) internal virtual { _mint(to, tokenId); _checkOnERC721Received(address(0), to, tokenId, data); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * This is an internal function that does not check if the sender is authorized to operate on the token. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal { address previousOwner = _update(address(0), tokenId, address(0)); if (previousOwner == address(0)) { revert ERC721NonexistentToken(tokenId); } } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer(address from, address to, uint256 tokenId) internal { if (to == address(0)) { revert ERC721InvalidReceiver(address(0)); } address previousOwner = _update(to, tokenId, address(0)); if (previousOwner == address(0)) { revert ERC721NonexistentToken(tokenId); } else if (previousOwner != from) { revert ERC721IncorrectOwner(from, tokenId, previousOwner); } } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking that contract recipients * are aware of the ERC721 standard to prevent tokens from being forever locked. * * `data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is like {safeTransferFrom} in the sense that it invokes * {IERC721Receiver-onERC721Received} on the receiver, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `tokenId` token must exist and be owned by `from`. * - `to` cannot be the zero address. * - `from` cannot be the zero address. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer(address from, address to, uint256 tokenId) internal { _safeTransfer(from, to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeTransfer-address-address-uint256-}[`_safeTransfer`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeTransfer(address from, address to, uint256 tokenId, bytes memory data) internal virtual { _transfer(from, to, tokenId); _checkOnERC721Received(from, to, tokenId, data); } /** * @dev Approve `to` to operate on `tokenId` * * The `auth` argument is optional. If the value passed is non 0, then this function will check that `auth` is * either the owner of the token, or approved to operate on all tokens held by this owner. * * Emits an {Approval} event. * * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument. */ function _approve(address to, uint256 tokenId, address auth) internal { _approve(to, tokenId, auth, true); } /** * @dev Variant of `_approve` with an optional flag to enable or disable the {Approval} event. The event is not * emitted in the context of transfers. */ function _approve(address to, uint256 tokenId, address auth, bool emitEvent) internal virtual { // Avoid reading the owner unless necessary if (emitEvent || auth != address(0)) { address owner = _requireOwned(tokenId); // We do not use _isAuthorized because single-token approvals should not be able to call approve if (auth != address(0) && owner != auth && !isApprovedForAll(owner, auth)) { revert ERC721InvalidApprover(auth); } if (emitEvent) { emit Approval(owner, to, tokenId); } } _tokenApprovals[tokenId] = to; } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Requirements: * - operator can't be the address zero. * * Emits an {ApprovalForAll} event. */ function _setApprovalForAll(address owner, address operator, bool approved) internal virtual { if (operator == address(0)) { revert ERC721InvalidOperator(operator); } _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Reverts if the `tokenId` doesn't have a current owner (it hasn't been minted, or it has been burned). * Returns the owner. * * Overrides to ownership logic should be done to {_ownerOf}. */ function _requireOwned(uint256 tokenId) internal view returns (address) { address owner = _ownerOf(tokenId); if (owner == address(0)) { revert ERC721NonexistentToken(tokenId); } return owner; } /** * @dev Private function to invoke {IERC721Receiver-onERC721Received} on a target address. This will revert if the * recipient doesn't accept the token transfer. The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param data bytes optional data to send along with the call */ function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory data) private { if (to.code.length > 0) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) { if (retval != IERC721Receiver.onERC721Received.selector) { revert ERC721InvalidReceiver(to); } } catch (bytes memory reason) { if (reason.length == 0) { revert ERC721InvalidReceiver(to); } else { /// @solidity memory-safe-assembly assembly { revert(add(32, reason), mload(reason)) } } } } } }
IERC721.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721.sol) pragma solidity ^0.8.20; import {IERC165} from "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon * a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external; /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or * {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon * a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721 * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must * understand this adds an external call which potentially creates a reentrancy vulnerability. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 tokenId) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the address zero. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool approved) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); }
IERC721Receiver.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.20; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be * reverted. * * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); }
ERC721Enumerable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/extensions/ERC721Enumerable.sol) pragma solidity ^0.8.20; import {ERC721} from "../ERC721.sol"; import {IERC721Enumerable} from "./IERC721Enumerable.sol"; import {IERC165} from "../../../utils/introspection/ERC165.sol"; /** * @dev This implements an optional extension of {ERC721} defined in the EIP that adds enumerability * of all the token ids in the contract as well as all token ids owned by each account. * * CAUTION: `ERC721` extensions that implement custom `balanceOf` logic, such as `ERC721Consecutive`, * interfere with enumerability and should not be used together with `ERC721Enumerable`. */ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { mapping(address owner => mapping(uint256 index => uint256)) private _ownedTokens; mapping(uint256 tokenId => uint256) private _ownedTokensIndex; uint256[] private _allTokens; mapping(uint256 tokenId => uint256) private _allTokensIndex; /** * @dev An `owner`'s token query was out of bounds for `index`. * * NOTE: The owner being `address(0)` indicates a global out of bounds index. */ error ERC721OutOfBoundsIndex(address owner, uint256 index); /** * @dev Batch mint is not allowed. */ error ERC721EnumerableForbiddenBatchMint(); /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual returns (uint256) { if (index >= balanceOf(owner)) { revert ERC721OutOfBoundsIndex(owner, index); } return _ownedTokens[owner][index]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual returns (uint256) { if (index >= totalSupply()) { revert ERC721OutOfBoundsIndex(address(0), index); } return _allTokens[index]; } /** * @dev See {ERC721-_update}. */ function _update(address to, uint256 tokenId, address auth) internal virtual override returns (address) { address previousOwner = super._update(to, tokenId, auth); if (previousOwner == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (previousOwner != to) { _removeTokenFromOwnerEnumeration(previousOwner, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (previousOwner != to) { _addTokenToOwnerEnumeration(to, tokenId); } return previousOwner; } /** * @dev Private function to add a token to this extension's ownership-tracking data structures. * @param to address representing the new owner of the given token ID * @param tokenId uint256 ID of the token to be added to the tokens list of the given address */ function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = balanceOf(to) - 1; _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } /** * @dev Private function to add a token to this extension's token tracking data structures. * @param tokenId uint256 ID of the token to be added to the tokens list */ function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } /** * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for * gas optimizations e.g. when performing a transfer operation (avoiding double writes). * This has O(1) time complexity, but alters the order of the _ownedTokens array. * @param from address representing the previous owner of the given token ID * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = balanceOf(from); uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } /** * @dev Private function to remove a token from this extension's token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } /** * See {ERC721-_increaseBalance}. We need that to account tokens that were minted in batch */ function _increaseBalance(address account, uint128 amount) internal virtual override { if (amount > 0) { revert ERC721EnumerableForbiddenBatchMint(); } super._increaseBalance(account, amount); } }
IERC721Enumerable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/extensions/IERC721Enumerable.sol) pragma solidity ^0.8.20; import {IERC721} from "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); }
IERC721Metadata.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.20; import {IERC721} from "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); }
Context.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol) pragma solidity ^0.8.20; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } function _contextSuffixLength() internal view virtual returns (uint256) { return 0; } }
Strings.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/Strings.sol) pragma solidity ^0.8.20; import {Math} from "./math/Math.sol"; import {SignedMath} from "./math/SignedMath.sol"; /** * @dev String operations. */ library Strings { bytes16 private constant HEX_DIGITS = "0123456789abcdef"; uint8 private constant ADDRESS_LENGTH = 20; /** * @dev The `value` string doesn't fit in the specified `length`. */ error StringsInsufficientHexLength(uint256 value, uint256 length); /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { unchecked { uint256 length = Math.log10(value) + 1; string memory buffer = new string(length); uint256 ptr; /// @solidity memory-safe-assembly assembly { ptr := add(buffer, add(32, length)) } while (true) { ptr--; /// @solidity memory-safe-assembly assembly { mstore8(ptr, byte(mod(value, 10), HEX_DIGITS)) } value /= 10; if (value == 0) break; } return buffer; } } /** * @dev Converts a `int256` to its ASCII `string` decimal representation. */ function toStringSigned(int256 value) internal pure returns (string memory) { return string.concat(value < 0 ? "-" : "", toString(SignedMath.abs(value))); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { unchecked { return toHexString(value, Math.log256(value) + 1); } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { uint256 localValue = value; bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = HEX_DIGITS[localValue & 0xf]; localValue >>= 4; } if (localValue != 0) { revert StringsInsufficientHexLength(value, length); } return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal * representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), ADDRESS_LENGTH); } /** * @dev Returns true if the two strings are equal. */ function equal(string memory a, string memory b) internal pure returns (bool) { return bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b)); } }
ERC165.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol) pragma solidity ^0.8.20; import {IERC165} from "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
IERC165.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
Math.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol) pragma solidity ^0.8.20; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Muldiv operation overflow. */ error MathOverflowedMulDiv(); enum Rounding { Floor, // Toward negative infinity Ceil, // Toward positive infinity Trunc, // Toward zero Expand // Away from zero } /** * @dev Returns the addition of two unsigned integers, with an overflow flag. */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the subtraction of two unsigned integers, with an overflow flag. */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds towards infinity instead * of rounding towards zero. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { if (b == 0) { // Guarantee the same behavior as in a regular Solidity division. return a / b; } // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or * denominator == 0. * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by * Uniswap Labs also under MIT license. */ function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0 = x * y; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { // Solidity will revert if denominator == 0, unlike the div opcode on its own. // The surrounding unchecked block does not change this fact. // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic. return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. if (denominator <= prod1) { revert MathOverflowedMulDiv(); } /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. // Always >= 1. See https://cs.stackexchange.com/q/138556/92363. uint256 twos = denominator & (0 - denominator); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also // works in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded * towards zero. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2 of a positive value rounded towards zero. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10 of a positive value rounded towards zero. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10 ** 64) { value /= 10 ** 64; result += 64; } if (value >= 10 ** 32) { value /= 10 ** 32; result += 32; } if (value >= 10 ** 16) { value /= 10 ** 16; result += 16; } if (value >= 10 ** 8) { value /= 10 ** 8; result += 8; } if (value >= 10 ** 4) { value /= 10 ** 4; result += 4; } if (value >= 10 ** 2) { value /= 10 ** 2; result += 2; } if (value >= 10 ** 1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0); } } /** * @dev Return the log in base 256 of a positive value rounded towards zero. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 256, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0); } } /** * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers. */ function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) { return uint8(rounding) % 2 == 1; } }
SignedMath.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SignedMath.sol) pragma solidity ^0.8.20; /** * @dev Standard signed math utilities missing in the Solidity language. */ library SignedMath { /** * @dev Returns the largest of two signed numbers. */ function max(int256 a, int256 b) internal pure returns (int256) { return a > b ? a : b; } /** * @dev Returns the smallest of two signed numbers. */ function min(int256 a, int256 b) internal pure returns (int256) { return a < b ? a : b; } /** * @dev Returns the average of two signed numbers without overflow. * The result is rounded towards zero. */ function average(int256 a, int256 b) internal pure returns (int256) { // Formula from the book "Hacker's Delight" int256 x = (a & b) + ((a ^ b) >> 1); return x + (int256(uint256(x) >> 255) & (a ^ b)); } /** * @dev Returns the absolute unsigned value of a signed value. */ function abs(int256 n) internal pure returns (uint256) { unchecked { // must be unchecked in order to support `n = type(int256).min` return uint256(n >= 0 ? n : -n); } } }
FreeMintManager.sol
//SPDX-License-Identifier: MIT pragma solidity 0.8.24; import {FreeMintNFT} from "./FreeMintNFT.sol"; contract FreeMintManager { ////////////////////////////// // Errors // ////////////////////////////// error FreeMintManager__MustBeAdmin(); error FreeMintManager__MustBeOperator(); error FreeMintManager__CampaignAlreadyCreated(); error FreeMintManager__CampaignNotCreated(); error FreeMintManager__CampaignNotStarted(); error FreeMintManager__CampaignEnded(); error FreeMintManager__CampaignTotalSupplyExceeded(); error FreeMintManager__CampaignTotalLimitByPeriodExceeded(); ////////////////////////////// // State Variables // ////////////////////////////// address public nft; address public admin; mapping(address => bool) public operators; mapping(uint256 => bool) public campaignCreated; mapping(uint256 => CampaignInfo) public campaignInfo; mapping(address => mapping(uint256 => UserLimitInfo)) public userLimitInfo; mapping(uint256 => bool) public campaignTransferable; ////////////////////////////// // Events // ////////////////////////////// event CampaignCreated( uint256 campaignId, address creator, uint256 startedAt, uint256 endedAt ); event CampaignRemoved(uint256 campaignId, address creator); ////////////////////////////// // Modifiers // ////////////////////////////// modifier onlyAdmin(address _sender) { if (_sender != admin) { revert FreeMintManager__MustBeAdmin(); } _; } modifier onlyOperator(address _sender) { if (!operators[_sender] && _sender != admin) { revert FreeMintManager__MustBeOperator(); } _; } ////////////////////////////// // Structs // ////////////////////////////// struct CampaignInfo { uint256 startTime; uint256 endTime; uint256 maxSupply; uint256 currentSupply; uint256 totalLimitByPeriod; uint256 totalLimitPeriod; uint256 totalCurrentSupply; uint256 totalLimitCheckpoint; uint256 userLimitByPeriod; uint256 userLimitPeriod; } struct UserLimitInfo { uint256 userCurrentSupply; uint256 userLimitCheckpoint; } ////////////////////////////// // Constructor // ////////////////////////////// constructor(string memory _baseURI) { nft = address( new FreeMintNFT("Hawl Terminal FreeMint", "#FreeMint", _baseURI) ); admin = msg.sender; } ////////////////////////////// // Public Functions // ////////////////////////////// function freeMint(uint256 _campaignId) external { if (!campaignCreated[_campaignId]) { revert FreeMintManager__CampaignNotCreated(); } CampaignInfo storage campaign = campaignInfo[_campaignId]; uint256 currentTime = block.timestamp; // Check if campaign is active if (currentTime < campaign.startTime) { revert FreeMintManager__CampaignNotStarted(); } if (campaign.endTime > 0 && currentTime > campaign.endTime) { revert FreeMintManager__CampaignEnded(); } // Check campaign total supply if ( campaign.maxSupply > 0 && campaign.currentSupply >= campaign.maxSupply ) { revert FreeMintManager__CampaignTotalSupplyExceeded(); } campaign.currentSupply = campaign.currentSupply + 1; // Check campaign total limit by period if (campaign.totalLimitByPeriod > 0) { if (currentTime > campaign.totalLimitCheckpoint) { campaign.totalLimitCheckpoint = ((currentTime - campaign.startTime) / campaign.totalLimitPeriod + 1) * campaign.totalLimitPeriod + campaign.startTime; campaign.totalCurrentSupply = 0; } if (campaign.totalCurrentSupply >= campaign.totalLimitByPeriod) { revert FreeMintManager__CampaignTotalLimitByPeriodExceeded(); } campaign.totalCurrentSupply = campaign.totalCurrentSupply + 1; } // Check user limit by period if (campaign.userLimitByPeriod > 0) { UserLimitInfo storage userLimit = userLimitInfo[msg.sender][ _campaignId ]; if (currentTime > userLimit.userLimitCheckpoint) { userLimit.userLimitCheckpoint = ((currentTime - campaign.startTime) / campaign.userLimitPeriod + 1) * campaign.userLimitPeriod + campaign.startTime; userLimit.userCurrentSupply = 0; } if (userLimit.userCurrentSupply >= campaign.userLimitByPeriod) { revert FreeMintManager__CampaignTotalLimitByPeriodExceeded(); } userLimit.userCurrentSupply = userLimit.userCurrentSupply + 1; } // Mint NFT uint256 tokenId; tokenId |= (_campaignId << 192); // 64 bits for campaignId tokenId |= campaign.currentSupply; // 192 bits for tokenId FreeMintNFT(nft).mint(msg.sender, tokenId); } ////////////////////////////// // View Functions // ////////////////////////////// function mintable( uint256 _campaignId, address _minter ) external view returns (uint256 errorCode, uint256 mintableCountDown) { if (!campaignCreated[_campaignId]) { return (1, 0); // 1: Campaign not created } CampaignInfo storage campaign = campaignInfo[_campaignId]; uint256 currentTime = block.timestamp; // Check if campaign is active if (currentTime < campaign.startTime) { return (2, campaign.startTime - currentTime); // 2: Campaign not started } if (campaign.endTime > 0 && currentTime > campaign.endTime) { return (3, 0); // 3: Campaign ended } // Check campaign total supply if ( campaign.maxSupply > 0 && campaign.currentSupply >= campaign.maxSupply ) { return (4, 0); // 4: Campaign total supply exceeded } // Check campaign total limit by period if (campaign.totalLimitByPeriod > 0) { uint256 totalCurrentSupply = campaign.totalCurrentSupply; if (currentTime > campaign.totalLimitCheckpoint) { totalCurrentSupply = 0; } if (totalCurrentSupply >= campaign.totalLimitByPeriod) { return (5, campaign.totalLimitCheckpoint - currentTime); // 5: Campaign total limit by period exceeded } } // Check user limit by period if (campaign.userLimitByPeriod > 0) { UserLimitInfo storage userLimit = userLimitInfo[_minter][ _campaignId ]; uint256 userCurrentSupply = userLimit.userCurrentSupply; if (currentTime > userLimit.userLimitCheckpoint) { userCurrentSupply = 0; } if (userLimit.userCurrentSupply >= campaign.userLimitByPeriod) { return (6, userLimit.userLimitCheckpoint - currentTime); // 6: User limit by period exceeded } } return (0, 0); } function transferable(uint256 _tokenId) external view returns (bool) { uint256 campaignId = _tokenId >> 64; return campaignTransferable[campaignId]; } ////////////////////////////// // Admin Functions // ////////////////////////////// function addOperators( address[] calldata _operators ) external onlyAdmin(msg.sender) { for (uint256 i = 0; i < _operators.length; i++) { operators[_operators[i]] = true; } } function removeOperators( address[] calldata _operators ) external onlyAdmin(msg.sender) { for (uint256 i = 0; i < _operators.length; i++) { operators[_operators[i]] = false; } } function transferAdmin(address _newAdmin) external onlyAdmin(msg.sender) { admin = _newAdmin; } function setNFTBaseURI( string memory _baseURI ) external onlyAdmin(msg.sender) { FreeMintNFT(nft).setBaseURI(_baseURI); } ////////////////////////////// // Operator Functions // ////////////////////////////// function createCampaign( uint256 _campaignId, uint256 _startTime, uint256 _endTime, uint256 _maxSupply, uint256 _totalLimitByPeriod, uint256 _totalLimitPeriod, uint256 _userLimitByPeriod, uint256 _userLimitPeriod ) external onlyOperator(msg.sender) { if (campaignCreated[_campaignId]) { revert FreeMintManager__CampaignAlreadyCreated(); } campaignInfo[_campaignId] = CampaignInfo({ startTime: _startTime, endTime: _endTime, maxSupply: _maxSupply, currentSupply: 0, totalLimitByPeriod: _totalLimitByPeriod, totalLimitPeriod: _totalLimitPeriod, totalCurrentSupply: 0, totalLimitCheckpoint: block.timestamp, userLimitByPeriod: _userLimitByPeriod, userLimitPeriod: _userLimitPeriod }); campaignCreated[_campaignId] = true; campaignTransferable[_campaignId] = true; emit CampaignCreated(_campaignId, msg.sender, _startTime, _endTime); } function removeCampaign( uint256 _campaignId ) external onlyOperator(msg.sender) { if (!campaignCreated[_campaignId]) { revert FreeMintManager__CampaignNotCreated(); } uint256 nftMinted = campaignInfo[_campaignId].currentSupply; // burn all NFTs for (uint256 i = 1; i <= nftMinted; i++) { uint256 _tokenId; _tokenId |= (_campaignId << 64); // 192 bits for campaignId _tokenId |= i; // 64 bits for tokenId FreeMintNFT(nft).burn(_tokenId); } delete campaignInfo[_campaignId]; delete campaignCreated[_campaignId]; delete campaignTransferable[_campaignId]; emit CampaignRemoved(_campaignId, msg.sender); } function setCampaignTransferable( uint256 _campaignId, bool _transferable ) external onlyOperator(msg.sender) { campaignTransferable[_campaignId] = _transferable; } }
FreeMintNFT.sol
//SPDX-License-Identifier: MIT pragma solidity 0.8.24; import {ERC721, ERC721Enumerable} from "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; import {Strings} from "@openzeppelin/contracts/utils/Strings.sol"; import {FreeMintManager} from "./FreeMintManager.sol"; contract FreeMintNFT is ERC721Enumerable { using Strings for uint256; ////////////////////////////// // Errors // ////////////////////////////// error FreeMintNFT__MustBeManager(); error FreeMintNFT__CannotTransfer(); ////////////////////////////// // State Variables // ////////////////////////////// string public baseURI; string public contractURI; address public manager; ////////////////////////////// // Modifiers // ////////////////////////////// modifier onlyManager() { if (msg.sender != manager) { revert FreeMintNFT__MustBeManager(); } _; } ////////////////////////////// // Constructor // ////////////////////////////// constructor( string memory name, string memory symbol, string memory _baseURI ) ERC721(name, symbol) { manager = msg.sender; baseURI = _baseURI; } //////////////////////////////// // View Function // //////////////////////////////// function tokenURI( uint256 tokenId ) public view override returns (string memory) { ownerOf(tokenId); // Check if tokenId exists return string(abi.encodePacked(baseURI, "/", tokenId.toString(), ".json")); } //////////////////////////////// // Manager Function // //////////////////////////////// function mint(address _owner, uint256 _tokenId) external onlyManager { _mint(_owner, _tokenId); } function burn(uint256 _tokenId) external onlyManager { _burn(_tokenId); } function setBaseURI(string memory _baseURI) external onlyManager { baseURI = _baseURI; } function setContractURI(string memory _contractURI) external onlyManager { contractURI = _contractURI; } function _update( address to, uint256 tokenId, address auth ) internal override returns (address) { address from = super._update(to, tokenId, auth); if (from == address(0)) { return from; } if ( from == address(0) || FreeMintManager(manager).transferable(tokenId) ) { return from; } revert FreeMintNFT__CannotTransfer(); } }
Gas Token: