Search code examples
ethereumsoliditysmartcontracts

Batch Minting vs Lazy Minting Directly to user wallet


I'm writing a solidity smart contract and I'm trying to decide which

  1. is more performant
  2. saves gas fees

This is based on a NFT marketplace

Option 1: Mint 10,000 NFTs to my wallet, and then transfer each NFT to a buyers wallet on purchase

Option 2: Mint directly to the buyers wallet on purchase

Assumptions:

  1. For now lets assume the tokenURI is constant and we dont need to rebuild it each time in option 2, because the time to upload to IPFS can be alot

Questions:

  1. Does minting cost more than a transfer, or are they the same?
  2. Is there a "quantity" where batch minting is more efficient?
  3. Is there any scenario where batch minting can be better?
  4. If we ignore the assumption and time to upload to IPFS is an added variable, would batch minting be more desirable?

Solution

  • Let me answer all the questions,

    1. Does minting cost more than a transfer, or are they the same?

    Answer : Minting cost will be higher than transfer. Because on minting function you will push a new value to the storage. mapping(uint256 => address) which you update address non-zero from zero, so it costs much more than non-zero to non-zero.

    1. Is there a "quantity" where batch minting is more efficient?

    Answer : With batch minting it can be efficient because some checks (value, amount etc.) done once at the beginning of transaction.

    1. Is there any scenario where batch minting can be better?

    Answer : You can use merkle-proofs for initial owners. But that approach usually used for whitelist, but i think it can be fit on that situation as well. There some other standarts like ERC721-A which is more gas efficient and ERC1155 which is more gas efficient on batch transactions. Maybe there is new standarts too...

    1. If we ignore the assumption and time to upload to IPFS is an added variable, would batch minting be more desirable?

    Answer : I dont think there is a connection between ipfs base uri and batch minting. The only thing you have to care about is wont let users see collection image order before minting. To hide this use a hidden NFT and assign that uri to all NFT's until all get minted and revealed.