0

This is the mint function I write in my contract. Each non-fungible token here represents a mobile device with a unique device ID and the device belongs to a certain owner. So apart from the token id, it contains owner's information including his/her ID, wallet address and ipfs hash value of user identity profile. The token does not contain any metadata.

First part of the function is a for loop mapping owner's information to the token; Second is the mintBatch function that actually mints multiple non-fungible tokens to one address.

enter image description here

I am wondering if there is any upper limit on the number of NFTs I can mint using this function.

For instance, if I mint 100,000 such NFTs to an address, would the miner be unwilling to package this transaction into a new block because the size of the transaction is too big that it would slow down the whole mining process.

And would the EVM be able to handle such a large amount of state changes in a short time?

2 Answers 2

1

Developer advocate from Chainstack here. Hope I can help you with this.

TL,DR: There is no hard limit on the number of NFTs you can mint in a transaction. But there are other limitations.

Using Ethereum as an example. NFTs are smart contracts/Dapp on Chain. Each NFT holder is simply an address-token pair in the Ethereum client's database. Minting can be simply seen as creating such pairs. Theoretically, you can mint as many tokens as you want in a single transaction.

The limitation comes in when the transaction is mined/validated. I think you already have some ideas about this.

Basically, Ethereum's gas fee is calculated based on the computation power and memory consumption. If you want to mint 10K NFTs in one call, you are likely to pay really high gas fee. I think that might be where Taras' rule of thumb comes from.

I don't think miners/validators purposely drop complex transactions. first of all, the mining work is already finished when they are choosing which tx to be included in a block. Secondly, a miner/validator doesn't choose based on complexity but merely on how "profitable" a tx is. Which is the gas fee + tips.

Hope it helps. Happy coding!

0

The rule of thumb seems to be up to 20 NFTs if you want to be sure it fits into a block the traditional way.

Otherwise you might want to look into Ghost minting and LazyArray techniques pioneered by William Entriken in AreaWorld project:

https://github.com/AreaWorld/ethereum-contracts

https://etherscan.io/address/0xf85c6320cc60DEC45Af1f7cE82B13dd24D539690#code#F5#L58

4
  • Thank you sir, I will look up the project you mentioned. And by the way, I would like to ask if there's a limit on the number of erc20 tokens that can be minted in one transaction? Dec 10, 2021 at 8:43
  • I don't think there is a limit for fungible tokens as you don't have to loop through a cycle. Dec 10, 2021 at 23:10
  • :) you're welcome, please feel free to mark the answer as correct if you think it is Dec 13, 2021 at 13:24
  • Hi Taras Filatov, not to be rude but where do you find this 20 NFT, rule of thumb?
    – Lonewarp
    Jun 28, 2022 at 8:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.