skip to content
Steve Simkins

A Case for IPFS on Layer 1 Blockchains

There are so many new blockahins appearing and they all need a solution to off-chain storage

Link to Medium Read this post on Medium

There has been a Cambrian explosion of new layer 1 blockchains — all with brand new technologies that make them faster and more efficient. However there is one problem that no blockchain has managed to overcome: asset storage.

Blockchains are great for keeping a ledger of transactions, but storing large amounts of data on-chain is expensive and doesn’t scale well. Worse, most of the centralized off chain storage methods have a bad reputation of enabling rug pulls and bad actors in the NFT space. Even though Pinata solves these problems, giving creators and developers easy access to the heaven-sent distributed file system known as IPFS, many of these new layer 1 chains still don’t understand why IPFS is the solution to their problems. Let’s break it down.

A Brief history of NFTs (How we got here)

NFTs and web3 are still pretty bright and new, but they have already created quite the history over the last 5 to 6 years. Ethereum has been the original playground for NFTs since 2016, and with that early usage comes experience. There were a lot of problems to overcome when creating NFTs, mainly storage.

When it comes to storing data on chain, every byte counts and costs gas. If you have too many bytes, it will get expensive quickly. Some NFTs took the approach of on chain SVGs which work in a pinch, but if you want to host something like a Bored Ape, it would cost a lot of money to deploy 10,000 of them on chain. Because of this, Ethereum turned to off chain storage and used a link or “token URI” to point to metadata and images not on Ethereum. This saved gas, but the solutions had their own problems. Most of the early storage solutions were simply centralized storage services or private servers, and using these came with the risk of rugs. With a server or storage provider, the link “https://steve.com/api/images/1.png” could host pretty much anything. “1.png” could be an image of a cool Pinata one week, and then whoever is in control of the server could simply replace the image with a picture of PePe the Frog with the same name “1.png.”

Kinda goes against the point of NFTs and having actual ownership of the content; if the content can change, what’s the point of having the reference on chain?

The Birth of IPFS

IPFS (the Interplanetary File System) solved a lot of the problems that centralized storage had with NFTs, and still does to this day. Pinata started not too long after in 2018 at EthBerlin, creating an IPFS service that was easy to use and accessible to the average person. With that said, we’ve certainly seen it all over the years. Pinata has also witnessed the birth of many new blockchains such as Solana, Cardano, or Aptos. One of our favorite parts of IPFS is that it’s blockchain agnostic, meaning it will work with any blockchain! It’s been great to see creators build NFTs and amazing projects on these new blockchains using Pinata. With the great, we’ve also seen plenty of examples of creators make the same mistakes made by Ethereum back in the early days, using centralized storage methods and witnessing rugs right before our eyes.

In this post we’ll dive into IPFS, why it’s the most ideal solution, and best practices when implementing it across NFT projects!

Why should Layer 1 Blockchains use IPFS?

Sometimes covering IPFS can be daunting as there are lots of moving pieces, but after you break down some basic concepts, it can be much easier to grasp. If you are looking for a non-technical introduction we would highly recommend our blog post on Bueno.art which you can find here! With that said, let’s look into some reasons why IPFS should be considered for off chain storage for all blockchains.

Immutable and Verifiable

Right off the bat IPFS solves one of the biggest problems for off chain storage by introducing immutability. This means when you share a file with IPFS, the content cannot change. If you share an image, that image will stay the same; it cannot be altered in any way. The way IPFS achieves this is with the “CID” or “Content Identifier.” When you share a file on IPFS, it goes through a cryptographic process that spits out the CID, which can look something like this:

QmeUmuQaTpoqk51uEYgrSjZvCqvtPw2ARdWnZEMb2ky25N

Each piece of that CID, every letter and number, is determined by the contents of the file. So if we shared the same file but perhaps we changed just one pixel, it would spit out a different file. Recall our example from earlier about someone swapping out a picture of Pinnie for a Pepe the frog, its just not possible in IPFS. They are two different files and will result in two different CIDs based on their content.

This is incredibly powerful if you stop and think about all the ramifications beyond just images. Think of all the things we want to accomplish with smart contracts and NFTs: real estate, health documents, it just goes on. These are documents that depend on data being immutable and verifiable, and IPFS provides this. With the CID, the owner of an NFT can rest assured that they can verify content as the original when tied to a smart contract. Even in the case of smart contracts that have functions to update the token URI, that change is on chain and the user has visibility and know what they’re getting into.

Portability and Ownership

One of my favorite pieces of IPFS is the ability to truly take ownership of your content. Due to content on IPFS being immutable, and the CID serves as the unchanging reference to a file, it can be used to address the content too. With the CID, files can be shared from one owner to another. Not only can it be shared or viewed, the content can move from one owner to another.

For example, if I own an NFT that has metadata (the name of the nft, description, image link, etc.) and an image hosted on IPFS, I can get the CIDs for both and pin it to my Pinata account. When a file is pinned on IPFS, it keeps it from falling off the network during garbage collection run on individual IPFS nodes. So in our scenario, if the original creator of the NFT ever stopped pinning the content on his end, the NFT would live on because I’m taking responsibility for the content and keeping it alive.

We call this portability and ownership, as the content can freely be persisted by any individual or community. It makes data ownership and sharing actually possible, where in the past the data was truly owned by a larger cloud provider. This IPFS ability also helps save projects from rugs. I can’t count the number of communities I’ve helped over the past year recover their project due to someone abandoning it. Thanks to IPFS all they have to do is get the CIDs, which is usually just two, and pin by CID through their Pinata account. Just like that, the project continues to live!

Our CEO Kyle Tut wrote a great piece on how IPFS portability changes the responsibility of hosting content from the creator to the owner, and how communities can help preserve data very similar to how art is preserved. You can read that here if you’re interested!

Speed and Efficiency

Believe it or not, IPFS does have the ability to be fast. If you are accessing IPFS through a local IPFS node, your experience will likely not be the best. However with the right tools, IPFS can be ideal for delivering content at blazing speeds. Since the content does not change and neither does the CID, the reference to the file, this makes an excellent use case for caching content.

Pinata released Dedicated Gateways back in 2021 that use a global CDN with 200 worldwide locations, so when content is loaded through the gateway, that content is cached. This makes every other request after that incredibly fast.

In addition to speed, IPFS is also efficient with data that is no longer wanted or used. In order for content to stay on IPFS, it has to be pinned by at least one IPFS node. If it is no longer pinned on any nodes, then it will slowly fall off the network as IPFS nodes run garbage collection. Some people might see this as a downside, but in reality this gives us a much more practical way of handling data and reducing data waste. It gives users the option of data persistence, rather than being forced into a model of permanence.

Best Practices

Now that you have an itch to try out IPFS and see for yourself, you might want to consider some best practices for how you want to reference IPFS content in NFT projects and other use cases.

Protocol URIs

One of the oldest and best ways to make sure IPFS data is future proof and easy to preserve is to use the protocol URI, especially in a smart contract for NFTs. The protocol URI starts with “ipfs://”, and a full url might look something like this:

ipfs://QmeUmuQaTpoqk51uEYgrSjZvCqvtPw2ARdWnZEMb2ky25N

At the time of this article, you may not be able to simply copy and paste this URL into your browser (unless you are using a browser like Brave or have a browser extension). Why? Because these normally require you to run an IPFS node to access them. That might change overtime, but right now this is the easiest way for marketplaces and wallets to locate the CID and run it through their gateway of choice.

This is a common practice on Ethereum where IPFS makes sense (BAYC is an example), however it’s not as popular on Layer 1 blockchains that expect a working HTTP url. We hope that as IPFS grows on those Layer 1 chains that fact will change, as people see the value in a data persistence model.

Public Gateways

Another way to access IPFS content is through a public gateway like this one:

https://gateway.pinata.cloud/ipfs/QmeUmuQaTpoqk51uEYgrSjZvCqvtPw2ARdWnZEMb2ky25N

Gateways are simply bridges between the IPFS protocol and the HTTP protocol that works on everyone’s computers. With them we can fetch content from IPFS without a local node running, making it really easy for everyone!

These are best used in testing environments or low traffic scenarios as public gateways are usually rate limited and under heavy use due to their open nature. This can also make them a bit slower.

Dedicated Gateways

If you want to take full advantage of IPFS, a Dedicated Gateway or Private IPFS Gateway is the ideal way to go! These have extra features built in to make streaming content faster and more reliable. An example of one might look like this:

https://stevedsimkins.mypinata.cloud/ipfs/QmeUmuQaTpoqk51uEYgrSjZvCqvtPw2ARdWnZEMb2ky25N

Not only do Pinata’s Dedicated Gateways include that global CDN we talked about earlier, but they can also do video streaming, and image optimizations. They’re fast enough that you can host entire applications on them to create App / Executable NFTs on them. For personal use they can be a great way to share content or display your NFT collection on your own personal website, and in the hands of a platform like OpenSea, they can be used to display tens of thousands of NFT collections with speed and reliability.

The Future

One of the best parts of my job is interacting with all the different blockchains out there and helping them use IPFS through Pinata. I also love helping communities across these chains understand the power of IPFS and how it can really save a rugged project in this space whether the founder knew it or not. The worst part is easily when there’s nothing I can do because the data sits on a centralized server that the community will never have access to.

The future of the web that I want to help build is one where the responsibility of data lies with the user and the communities that find value in it. Whether it’s a moving essay, a photo of a volcano, or some picture of a goblin, IPFS is here to make it possible for data to persist beyond its original source and into the future of web3. Let’s build something great together.