What is IPFS?

What is IPFS and why do we use it for NFTs

InterPlanetary File System (IPFS) is a peer-to-peer protocol for storing and sharing data in a distributed file system. Currently, IPFS is the primary protocol for storing digital media, which many NFTs represent. In short, the NFT is on the blockchain and points to IPFS media files in it's metadata.

Why IPFS?

Minting Tokens as Fully-On-Chain NFTs can be very complicated and is also limited by the maximum metadata size of currently 16kb of a transaction. This is why the most common way to add media files to your tokens is to store them externally and link them in the metadata of the token. As IPFS stores the files in a distribution system and it has no file size limitation, it is the most practical solution to achieve that.

How does it work

Every file that is added to IPFS is assigned a unique address based on a hash of the file's content. This address is referred to as a Content Identifier (CID), and it combines the file's hash and a unique identifier for the hash algorithm used into a single string. As a result, if you upload the same exact file again, it will always receive the same IPFS hash / CID. This means that even if the third party you used to upload your tokens no longer supports your files and "deletes" them, you can reupload the files on your own and the NFT will now correctly fetch the media files.

At NMKR Studio, we are uploading and pinning the media files with our own bare metal servers. If you decide to upload the media files on your own to IPFS, you can also use the hashes and insert them to your metadata.

The CID in the Metadata of an NFT

As an example we want to show you how the IPFS will be used with your metadata.A CID / IPFS hash of an uploaded file will look something like the following string.

QmQ878cbFuPj9GWij1KXowcQP6RY1kHQm3Y6dkAe4VPaRz

The metadata of your token now contains a field that links this hash to your NFT, makes it viewable on explorers, in wallets and DApps.

"src": "ipfs://QmSz8jA6LfU6NSSaobybvzsobbuaQwVBZ8CCBe2hmpfFDg",

As IPFS does not make any differentiation of the file formats, your metadata also contains a field that identifies the media file in the correct format.

"mediaType": "image/jpeg",