How does IPFS work with NFTs?
Pinata has been empowering the NFT space since 2018 and there’s a good reason for that. IPFS is the perfect pairing for NFTs for several reasons.
- IPFS is Immutable - Anything that is uploaded to IPFS cannot change, which helps preserve the value of an NFT.
- IPFS is Decentralized - Instead of using a centralized server where one person can control the content, IPFS is distributed and makes sure anyone can pin the content and keep it persisted.
- IPFS is Portable - Since the CID for content will be constant, and IPFS pinning works in a decentralized manner, anyone can take a CID and pin it themselves. This allows content to be “transferred” and kept up on the network as people value it. (read more about that concept here)
One of the biggest reasons you want to use IPFS for NFTs is to prevent tampering or “rug pulls” where someone can just delete the data for an NFT and make it worthless. NFTs are tokens on the blockchain that have a “Token URI” which is simply a link pointing to data about that NFT off-chain, because putting data on-chain is far too expensive. If this link is a centralized server, like https://server.com/pinnie.png
, then whoever has control of the server can simply upload totally different content and keep the same name, thus keeping the same link. Or they could just delete it and it would be empty!
This is where IPFS becomes necessary. Since the address or link to the content on IPFS is the CID, which is based on the content itself and is immutable, you can’t change it or alter it. In addition, the ability for multiple people to pin content and help it persist on the network makes it harder for something to just be deleted.
How to Make an NFT with Pinata
It’s important to note that Pinata is currently not providing any minting services. This means you would use Pinata to host the media content and the metadata for the NFT, and then another service or self-deployed smart contract to actually mint the NFT. But don’t worry, we’ll show you a few different ways you could do that!
Step 1: Upload the Content
The first thing you need to do is upload the content to Pinata. Since IPFS supports any kind of file, the truth is any kind of file can be an NFT. How that file is referenced in the metadata is a bit of a different story, so be sure to check metadata standards to make sure you content will be seen on marketplaces or wallets.
To upload the content you can either do a simple upload through the Pinata App by navigating to the files page and uploading through the UI like so:
Or you can upload through the SDK using a script like this:
In each case you will want to grab the CID for that file, which will look something like this:
Step 2: Create and Upload Metadata
Now that we have the CID for our content on IPFS, we need to create a metadata file that will have all the other information about the NFT. You will want to use a JSON format and follow industry metadata standards to make sure that it will show up in marketplaces and wallets. You can use the template below as we’ll walk through each piece.
name
- This will be the name of this particular NFT, not the collection.description
- Describes the NFT.external_url
- A link to the website of the NFT project or creator.image
- This would be the link to the image, if it was a video or gif then you would want to follow metadata standards and have a backup image, and also add ananimation_url
for the video.
You’ll notice that we are using the IPFS protocol URL for the image link. There are other ways to reference CIDs in NFT metadata which you can read about more here.
Once you have that file filled out you will want to save it as something like metadata.json
(this might be different if you are making a large project using folders). Then you can upload the metadata file to Pinata using the app like before, or if you are using the API we have a JSON endpoint you can use to simplify the process, like so:
After the metadata is uploaded you should now have a CID for that metadata file; this will be the core identity of your NFT and will act as the Token URI.
Step 3: Mint the NFT
Now that you have the all important Token URI metadata CID, you can mint an NFT! How you go about doing this will depend on multiple factors.
Starting an NFT Project
If you are non-technical and you’re just looking for the easy way to create an NFT project, you will likely want to use a minting service like Bueno, Mintplex.xyz, or Manifold. There are a lot of complexities with smart contracts and making sure the content is setup properly, and using a service like this will make things much easier!
Just Exploring NFTs
If you want to get your feet wet with smart contracts you could follow the video below! It covers the Base layer 2 blockchain in particular, but the method will work on other EVM chains.
Implementing into an Decentralized App
If you are a developer that is trying to do NFT minting on a larger scale, you could use an NFT minting API like Crossmint. Lucky for you we have some tutorials on how to do just that!