Bulk Minting NFT
In this article, i will describe solidity smart contract and nodeJS app to perform bulk minting of NFT. The discussion is applicable to Ethereum compatible blockchain.
Referring to the diagram below:
The mintManyNFT function is part of the solidity smart contract. It takes as input array of addresses, and a baseURI. It loops through the number of addresses, and for each address, it mints an unique token Id to the address and sets the tokenURI.
In the nodeJS app, it calls the mintManyNFT function, passing in the array of addresses and the tokenURI.
The full source code is available at:
GitHub - victoryeo/maticNFT: bulk minting NFT on Polygon matic testnet
This project demonstrates a basic NFT and bulk minting NFT using Hardhat.
Note: The solidity smart contract function is not optimised for gas. There are several ways to optimise the function.
- Set the base token URI only once. Do not set the token URI for each address.
- Do not use the ERC721URIStorage contract, use your own counter to minimise storage cost.
- Any more ideas?