0

The ERC-721 specification indexes NFTs by a tokenId, a variable of type uint256.

Are there any best practices on how the ids should be generated?

For instance, is it fine to use a simple integer counter that starts at 1?

2 Answers 2

1

By reading the EIP-721 it mentions the NFT Identifiers.

It states:

While some ERC-721 smart contracts may find it convenient to start with ID 0 and simply increment by one for each new NFT, callers SHALL NOT assume that ID numbers have any specific pattern to them, and MUST treat the ID as a “black box”.

So anyway you choose as long as the identifier is unique is good by standard.

1

Yes, you can use integer counters to increment the tokenId and because in Ethereum, transactions are processed sequentially (based on transaction gas fees chosen by the validators), the counters will work correctly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.