Open leoloco opened 8 months ago
IMPORTANT NOTE: on top of enumerable, add METADATA extension to the ERC721 contract as part of this issue please. (see for more details: https://github.com/OpenZeppelin/openzeppelin-contracts/tree/master/contracts/token/ERC721/extensions)
Context
Currently, the NFT standard only allows retrieving a particular token based on its tokenId.
The Enumerable extension for ERC721 tokens, typically represented in smart contracts by interfaces such as
IERC721Enumerable
, adds functionality for discovering and navigating through all tokens in a contract, as well as querying tokens owned by a particular account. This extension enhances the ERC721 standard by providing a way to enumerate over all tokens or all tokens owned by a user, which is particularly useful for contracts that need to display or operate on a collection of NFTs.User flow
For NFT Owners and Collectors:
Viewing Owned NFTs:
tokenOfOwnerByIndex(address owner, uint256 index)
function, which returns the token ID owned by a user at a given index within their list of owned tokens.Exploring the Entire Collection:
totalSupply()
function returns the total number of tokens in existence, andtokenByIndex(uint256 index)
allows enumeration over all tokens based on their indices.For Developers and Marketplaces:
Building Dynamic Interfaces:
Implementing Advanced Querying and Filtering:
Facilitating Efficient Transactions and Interactions:
Technical details
Based on openzeplin's implementation https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC721/extensions/ERC721Enumerable.sol Implement
NFT-enumerable-internals
which defines the datastructure and internals function of an enumerable NFTNFT-enumerable-example
which is an example implementation of an enumerable NFT and showcases how to use the methods defined in the corresponding -internals file