Skip to main content

Using IPFS to secure your NFT

· 3 min read
Raza Zaidi

This guide explains what pinning is and how thirdweb uses it.

What is IPFS

When you create an NFT, you can provide a link to an asset, like an image.

That image can be stored anywhere; most commonly, NFT assets are stored in IPFS (Inter Planetary File System).

This is because if an image is stored somewhere like a cloud provider, it is at risk of being deleted, lost, or corrupted; which could cause your NFT's asset to be lost.

IPFS solves this by saving your images on a network of different nodes. It’s not on the blockchain; but it’s a decentralized network.

IPFS alone is not secure forever, what if all the nodes stopped storing your asset? This is where pinning comes into play.

What is pinning

Pinning is the way of telling IPFS to always keep your asset stored somewhere.

This can be achieved by pinning it yourself and running a local IPFS node, or by using a third-party remote pinning service.

How do I pin my image

When you use thirdweb to mint your NFTs, you don't have to worry about pinning at all; We do that for you.

When you mint an NFT with thirdweb, we make use of the highest standards. We don’t use local storage or APIs. You own the smart contract, you own the NFT and we save the image in the best possible way.

How does pinning work

To pin an image, you need control over the IPFS node. This is where pinning services come in. A pinning service, like Pinata, has a decentralized storage solution.

Anyone can use Pinata to upload an image and pin it using IPFS, on their network. When you mint with thirdweb, we do this for you behind the scenes.

How do I access my image

When an image is pinned you get the unique footprint of the image. IPFS retrieves that image, based on that unique hash. This is an example👇

QmfM2r8seH2GiRaC4esTjeraXEachRt8ZsSeGaWTPLyMoG

The canonical link to that image looks like this 👇

ipfs://QmfM2r8seH2GiRaC4esTjeraXEachRt8ZsSeGaWTPLyMoG

If you pass that link in your browser, it won’t work, because your browser does not know how to get there.

Technically speaking your browser doesn’t have the tools to do so, but let’s not get into that.

To access that link you need an IPFS gateway. An IPFS gateway is like a bridge between traditional web browsers and IPFS.

There are public gateways and private gateways. Private gateways are used when your IPFS network is private, i.e. not available to outsiders.

Public

The easiest way to access your image is by using a public gateway. Simply speaking that means converting that link from this:

ipfs://QmfM2r8seH2GiRaC4esTjeraXEachRt8ZsSeGaWTPLyMoG

to this

https://ipfs.io/ipfs/QmfM2r8seH2GiRaC4esTjeraXEachRt8ZsSeGaWTPLyMoG

There are other public gateways that you can use. Check them out over here.