chiru-labs / ERC721A

https://ERC721A.org
MIT License
2.5k stars 840 forks source link

Precalculate TokenIds? #467

Open genecyber opened 1 year ago

genecyber commented 1 year ago

I really would like to use these new features, but have one significant issue. It appears part of the magic is with sequential toeknIds. My application associates a tokenID with an off chain asset. Typically I do this by generating my tokenID based off a few bits of information known before mint.

If sequential only, my prior method of associating a tokenID with an item is fraught with race conditions.

1: is it possible to mint out of order? 2: if not, is there a way to provide info at mint time to associate a tokenID with some key that I can use to associate with a specific off chain “thing”?

nidhhoggr commented 1 year ago
  1. minting out of order is not possible
  2. Yes, you can make an internal call to setExtraDataAt which stores an uint24 at the specified mintIndex https://github.com/chiru-labs/ERC721A/blob/c66792253580acb2b7a873046858175d213e5b65/contracts/ERC721A.sol#L1040