0

I am creating a bunch of NFTs using ERC721.

However I see that many other contracts just use centralized hosts to serve their metadata, which means one day these servers will be gone and so will the NFTs...

Eg. Bored Apes collection does it like this:

I wanted to upload the metadata to the IPFS, with the images as well, and it seems there is a service that already does that very easily: https://nft.storage/

However, there is still a problem...

From what I understood, this nft.storage solution still generates URLs like:

ipfs://bafyreib4pff766vhpbxbhjbqqnsh5emeznvujayjj4z2iu533cprgbz23m/metadata.json

Which means I need to store a big URI per NFT in my ERC721 contract (the bafyreib4pff766vhpbxbhjbqqnsh5emeznvujayjj4z2iu533cprgbz23m part).

This will basically kill the project due to the high storage cost/gas fees on the ETH mainnet.

So my question is: Is there a way to generate links that share the same base URI, but then I am allowed to chose the suffix part? Eg. To me this would be the ideal scenario:

  • ipfs://<SAME HASH ON ALL URLs>/tokens/1.json

  • ipfs://<SAME HASH ON ALL URLs>/tokens/1.jpg

  • ipfs://<SAME HASH ON ALL URLs>/tokens/2.json

  • ipfs://<SAME HASH ON ALL URLs>/tokens/2.jpg

  • ...

Is this possible?

1 Answer 1

1

Yes, IPFS support folders. Just pay attention to the CID generation, which is based on the folder content -> once uploaded, the content cannot be changed anymore (without having a new CID).

Feel free to try it for yourself, I just pinned this test folder via Pinata : https://gateway.pinata.cloud/ipfs/QmTcZ21jK22QxPAooVZEr5jFW6u1gpS5REsuVBMZbcNwka

2
  • Amazing, this is it! Will this URL live forever as long as the files don't change? What happens if pinata goes offline?
    – PedroD
    Commented Nov 9, 2021 at 20:53
  • Pinata offer a pining service, meaning your file will live in IPFS as long as it's pinned -> if pinata goes down, you need to pin it somewhere else (or run an ipfs node) - see docs.ipfs.io/how-to/pin-files Commented Nov 9, 2021 at 20:56

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.