[Ethereum] Most efficient way of generating random ERC 721 NFT

contract-developmentcontract-invocationerc-721solidity

I'm just getting into Solidity by building a first project around collectibles, ERC 721.

There's for example 1500 different collectibles, each has an available amount defined by a criteria. These collectibles will be distributed in packs of 5, totally randomly after an initial purchase. These collectibles will be generated from a database that has properties like "name", "image", "id", etc

How would one go about generating 1500 * availability tokens (amounting to a total of 150000 tokens)? Pass an array of ids to a function called only once from a specific private address and generate them and store them in a mapping storage? I'm anticipating this will require a lot of gas, how could I evaluate the costs of creating such a large number of tokens?

Best Answer

First of all, ERC721 has its amount fixed as 1, so you might wanna use ERC1155.

If you want to create 1500K ERC721 or 1500 ERC1155(1K of each) collectibles, I would not suggest you create all of them in one go, as there is a high possibility that they will exceed the block gas limit.

From your question, I see that you have all the different token URIs stored in a database. So, you can create these collectibles in batches, such that it's efficient for you.

You can use truffle or hardhat for gas estimation.

Related Topic