ERC721 Storing on IPFS without revealing not minted tokens

I am looking at many existing NFT projects and I see that they set base url to point to a IPFS with metadata that also has the pointer to the png. All of these projects also simply mint id being equal to totalSupply() + 1 on each mint. That means given the base URI and appending an id of the next token to be minted you should be able to see what token you would mint or it's rarity. This is in no way fair.

So far I know only of few solutions:

  1. Set the baseURI to some placeholder metadata and once you are fully minted set the baseURI to actual tokens. The down side is that you can indefinitely wait to be fully minted.
  2. Generate and upload the files to IPFS as some one is minting. You would need to listen to the on chain events and run a backend for that. Might become complex.
  3. Upload a random sequence to the contract so you mint not just N+1 index but a sequence[N+1]. Problem is that people will see the sequence in constructor arguments for example.
  4. Set baseURI to the backend that queries the NFT's contract for it's total supply and only responds with metadata if the id of requested token is already minted. This will be a bottleneck to call blockchain every-time someone requests metadata until the collection is fully minted and you can set the baseURI direclty to IPFS.

My question is what is the most optimal way to deal with this problem without building a super complex infrastructure around it. May be there is already an elegant solution to this that I am just not aware of?

Hello @Gain_Weighted

What about if the sequence could be unknown, because its drawn randomly. The analogy would be a deck of card, where you know which cards are in the game, which one have been drawn, but everytime some mints, a card is drawn randomly.

This library implements that

Sir, this is very nice! My socks are blown off... Very nice utilization of the sstore. Just want an opinion of a more experienced developer, what are the gas implication of instantiating large arrays with this method? Anything one should be aware of?