Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement ERC721 enumerable extension #148

Open
leoloco opened this issue Mar 4, 2024 · 0 comments
Open

Implement ERC721 enumerable extension #148

leoloco opened this issue Mar 4, 2024 · 0 comments

Comments

@leoloco
Copy link
Contributor

leoloco commented Mar 4, 2024

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:

  1. Viewing Owned NFTs:

    • A collector can view a list of all NFTs they own within a particular collection. This is made possible by the 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.
    • This enables user interfaces (UIs) to iterate over all NFTs owned by a user and display them, even if the total number is unknown beforehand.
  2. Exploring the Entire Collection:

    • Users can explore the entire collection of NFTs issued by the contract. The totalSupply() function returns the total number of tokens in existence, and tokenByIndex(uint256 index) allows enumeration over all tokens based on their indices.
    • This feature supports the creation of gallery views or marketplaces where users can browse through every NFT in a collection, facilitating discovery and trading.

For Developers and Marketplaces:

  1. Building Dynamic Interfaces:

    • Developers can leverage the Enumerable extension to build dynamic and responsive interfaces that automatically update to reflect the total supply and ownership distribution of NFTs in real-time.
    • This includes creating features like leaderboards, galleries, and personalized user dashboards that showcase NFT collections.
  2. Implementing Advanced Querying and Filtering:

    • With the ability to enumerate tokens, developers can implement advanced querying and filtering logic to allow users to search for NFTs based on various criteria (e.g., rarity, attributes) within a collection.
    • This enhances the user experience by making it easier to find specific NFTs in potentially large and diverse collections.
  3. Facilitating Efficient Transactions and Interactions:

    • The Enumerable extension makes it easier for contracts, such as marketplaces or games, to interact with NFT collections by providing structured ways to access and iterate over tokens.
    • This can lead to more efficient batch processing or aggregation operations, improving transaction efficiency and reducing costs.

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 NFT
  • NFT-enumerable-example which is an example implementation of an enumerable NFT and showcases how to use the methods defined in the corresponding -internals file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant