Back to blog

Stop Using Folders For NFT Collections

Stop Using Folders For NFT Collections

Steve

IPFS has been used for many different kinds of applications, but the most popular by far is NFT metadata and assets. From the dawn of NFTs, there was a need to have offchain blockchain storage that could be held accountable, distributed across nodes, and verifiable for content integrity. NFTs took the world by storm with the meta of a 10,000 NFT collection where each asset is unique. With that comes the challenge of managing 10K JSON files and 10K image files, and doing that on IPFS through folders has always been rough.

It makes sense to a point: upload a folder of images to get a folder CID so you can access each image with ipfs://FOLDER_CID/1.png for NFT #1, so on and so forth. Then, for the metadata, JSON files use those image links in each file, then upload the metadata folder so you can have a base URI of ipfs://METADATA_FOLDER_CID/1 making it a smooth experience for the smart contract to append each Token ID. While this sounds straight forward, it starts to break down if you make a mistake. Since folders on IPFS are immutable, you can’t go back and change something. You have to delete it and start the upload all over again, and if your images are large, then it could take a lot of time to do over and over again. It’s unforgiving.

{
  "name": "Name of NFT",
  "description": "Description of NFT",
  "external_url": "<https://pinata.cloud>",
  "image": "ipfs://FOLDER_CID/1.png"
}

It’s also unforgiving against collectors. One of the best reasons to use IPFS is the ability for collectors to back up the NFTs they own by pinning the CIDs with their own IPFS node or Pinata account. If you use a massive image folder it means they have to pin the whole thing, which could be very costly depending on their setup. Pinata has been helping developers and creators alike for years and have seen the pain here — that’s why we built Groups.

Instead of uploading a folder to IPFS, you can create a new Group for your NFT collection, then upload the files to that group or add existing files to that group. When you upload the files individually to a group you can update, add, or delete files from that group.

// Upload to a group
const upload = await pinata.upload
  .file(file)
  .group("84fd4dac-3be4-46d3-86d4-24359aaefb07")

// List files for a given group
const files = await pinata
  .listFiles()
  .group('84fd4dac-3be4-46d3-86d4-24359aaefb07')

// Add a new file
const group = await pinata.groups.addCids({
	groupId: "84fd4dac-3be4-46d3-86d4-24359aaefb07",
	cids: ["bafkreih5aznjvttude6c3wbvqeebb6rlx5wkbzyppv7garjiubll2ceym4"]

Thanks to the power of our API and SDK, you have all the information of each file at your finger tips, making it a breeze to add them to metadata files or export them as a list of CIDs. When you use groups, it’s a benefit for the collectors too! With the aforementioned ability to list your files and each individual CID, you could build a reference for each token ID to backup their NFT by pinning the target CID.

One of the best things you can do when you encounter a problem is to think outside the box. Rather than trying to make IPFS folders work, think of how Groups could be used instead. Many developers are already unlocking this, so don’t struggle anymore and give it a try today!

Happy Pinning 😄

Subscribe to paid plan image

Share this post:

Stay up to date

Join our newsletter for the latest stories & product updates from the Pinata community.