Solidity – How to Deal with Unique Off-Chain Metadata in Lazy Minting Contract

mintnftsoliditytokens

Let's say I want to create a digital card collection. I create the metadata and image parts, and then combine them. So now I have a few thousand unique images.

Now I want people to be able to lazy mint them. How would the smart contract look like given that the IPFS metadata and image uri would have to be different for every minted card?

I have an idea on how it would work if I used HTTPS instead, I could just create the links myself and only change some id at the end in the contract, but I'd rather avoid using a central database.

Best Answer

It's possible to publish folders to IPFS. So you'll put metadata files for all the NFTs into that folder and receive an IPFS hash. To access individual file use this: folderIPFSHash/fileName

In the ERC-721 contract, add the folderIPFSHash into _baseURI variable, and for each tokenId a unique metadata path can be generated by concatenating strings to form: _baseURI/tokenId.json as output for the tokenURI function.