Automatically Link IPFS CID To Each NFT in Collection

I have generated my artwork (50 images) using Hashlips and I have uploaded them, along with the metadata to NFT.Sorage but I am trying to figure out how to automatically have it so that each NFT minted is automatically linked to the correct corresponding image in the IPFS part of the metadata. I tried to just add the CID of the whole folder but that doesn’t show up for some reason, I used both Filebase and NFT Storage as an IPFS provider but the same result is occurring. However, when I add “/1.png” in front of the CID then the image shows up but I don’t know how to make it so that it is automatically linked to each corresponding image in the folder.

??? The metadata is supposed to be put on the chain, when minting the NFTs, not on IPFS.

What do you mean by “automatically”? Each NFT gets its own block of metadata …

… and in these individual blocks, you usually have the IPFS link with the CID of the individual image, not of the folder.

…, but of course it also works to use the CID of the folder with the path inside that folder, since this is just how folders on IPFS work.

Look for example at one of the minting transactions of SpaceBudz:

There are a lot of metadata blocks for each of the NFTs minted in that transactions in there and each has a different IPFS link to the specific image for that specific NFT.

You can, of course, use some script in the scripting language of your choice to generate that large metadata file for the minting transaction.

In contrast to that, it has become quite fashionable to mint the NFTs on demand only if there is a user paying for it and then mint it directly to the address of the user.

Totally random example (I’m not at all into CNFTs, don’t know which count as good and which as bad projects there): This project says: “Send us some ADA and we will mint an NFT directly to your address.”

So, this transaction sending 45 ADA to that address is answered by this transaction a minute later, minting the NFT directly into the user’s address.

For this to work, the users have to trust you that you will keep your part of the deal, you have to have a script running somewhere that monitors your payment address and answers with minting transactions. And you have to prepare the metadata for each of these minting transactions beforehand. You can again use a script in a language of your choice to prepare those files with the individual links for each of your NFTs.

Another, even more professional way, is to mint using a dApp connection to a wallet and doing it in one transaction, where the user pays and you mint the NFT to their address at the same time. If you don’t want to learn how to program that on your own, there are several providers of more or less fancy solutions out there.

Again, totally random example: CardanoPunks can be minted on
If I click through it, my Eternl asks me to sign a transaction, where I would pay and get the NFT in the very same moment:
Again, you’d have to provide individual metadata for the collection beforehand. Really don’t know how and other such servcies – NMKR, Anvil, … – want that, how much assistance they give you in preparing that.

Of course, you could also write such a dApp yourself and make it more individual, fancy, tailored to your project.

1 Like

I used excel … in combination with notepad ++
You will have a single metadata file with 50 lines… then on server run

x=0; cat bigfile.json | while read line; do echo $line >file$x.json ; x=$((x+1)); done

replace bigfile.json with the name of your folder
file is the name if the final file… for example test1.json, test2.json, etc

This will read the big file line by line and it will create a separate json file for each line

For your 50 NFTS should not take more than 5 minutes to build the metadata for all

1 Like

Thank you so much for the detailed response, I really appreciate it.

I am trying to build a lazy minting function with typescript and I just thought that there was a way to just input the CID of the whole images folder and then it would automatically match, for example the first time someone comes along and mints an NFT from my site and it’s the firs NFT, I would like it to realise that it’s NFT #1 so it automatically links to 1.png in the images folder on the IPFS, and so on with the following times that people mint on my site. But I see now by Spacebudz transaction metadata that that’s not how it works. Also I saw a new project on JPG Store called Micefia which has the CID of their whole images folder, along with “/1.png”, “/2.png”, etc… at the end of the IPFS url so I know that it’s OK to do it that way.

Thank you for this, it’s just that I used a slightly tweaked version of hashlips that’s built for the Cardano blockchain and the metadata is automatically generated for each image as they are generated. Do you know anything about Typescript?

Yeah, you can do it that way. If you know that your folder on IPFS is structured that way, you can build your own automatism for it in your lazy minting function.

But chances are not great that anybody has already done it, ready to use. It’s not a widely used standard setup. The files in that folder could also be “MyProject_001.png”, “MyProject_002.png”, … or “ham.png”, “spam.html”, “foo.css”, and “bar.js”. No way for a system-side automatism to guess what you are up to.

Do you know y any chance how other projects have done this? Like how is it that they have individual CIDs for each NFT, they wouldn’t have manually added that into the metadata of every single NFT? That would take way too long…

Also do you know anything about typescript?

They/you also have to manage all the other metadata of the NFTs – numbers, names, traits, … At some point in your workflow you assemble the metadata for a specific NFT. And at that point you can also add the link from some table in some format. It’s programming. There are many ways to do it.

You could upload to IPFS in the very same step, where you also assemble the metadata. Whatever library or tool you use to upload should have a way to give you the CID/link back.

You could upload the files one by one and record which NFT has which link in some table/file to use that table later in your metadata assembly code.

Or – if you created a directory in IPFS, which most projects do not seem to do – you can list it’s contents including the CIDs and the filenames to produce such a table:

Since you alrady have such a folder, you can also do it like Micefia did it according to your research and use the CID of the folder and just add /{number}.png at the end, when you assemble the metadata.

I know what it is and can hack around code that is given to me. But not fluently enough to just write down a solution for you. Would also need to know which libraries and frameworks you use and want to use.