Should ERC721 minting always start from tokenID=1 and continue sequentially? Or can I let the minter choose whichever token they want?

I'm trying to modify the OpenZeppelin ERC721 contract but I'm very new to this. So my question is:

Does "minting" always start from 1 and just go up one by one at a time? Or can I let the first user of the contract ever choose to mint for example the token with ID=431 and then the second minter would come and "choose" to mint the piece with tokenID=3. Is that possible at all with ERC721?

Hi, you can send any number as tokenId when minting.

1 Like

Thanks @JulissaDantes

Are there any modules or functions that I can import or use to securely and safely achieve this? I'm having a hard time finding even one example of anyone doing it

The ERC721 contract should be enough , please make sure you keep record of all tokenId used or you don't accidentally try to mint a new token with an existing token id because that will revert.

You ca see an example in our test for that contract where we mint 2 tokens with ids 5042 and 79217

@JulissaDantes This is really helpful. Thanks.

To use this approach, do I have to disable "Auto Increment Ids" and "Enumerable"? Or that doesn't matter and there won't be any conflict?

You just need to disable Auto Increment Ids