Book a free call

Blockchain and IPFS: How Decentralised Storage Works

IPFS stores files by content, not location, and a blockchain can record each file's fingerprint. Together they give apps storage no single server controls.

Hertiv engineering teamReviewed by a senior engineer
6 min read
Blockchain and IPFS: How Decentralised Storage Works
On this page

Short answer

IPFS is a peer-to-peer network for storing and sharing files by their content, and blockchains use it to hold the large files they cannot store themselves. The file lives on IPFS under a content fingerprint, while the blockchain records that fingerprint as proof of what the file is.

What is IPFS?

IPFS, the InterPlanetary File System, is a peer-to-peer network for storing and sharing files, where each file is found by its content rather than by its location. Instead of asking a server at an address for a file, you ask the network for the file with a given fingerprint, and any computer holding it can answer.

That fingerprint is a content identifier, or CID, which is a hash of the file itself. Change one byte in the file and the CID changes, so a CID always points to exactly one version of one file. This makes files easy to verify: if the hash matches, the file is the one you asked for.

IPFS is not a blockchain. It is a storage and sharing network that blockchains often use, because a blockchain is good at recording small pieces of data and bad at storing large files. The two fit together: the file lives on IPFS, and the blockchain records its CID.

How does content addressing work?

Content addressing means a file's address is derived from the file itself, not from where it is stored. The network splits a file into blocks, hashes each block, and builds a CID from those hashes, so the same file always produces the same CID on any computer.

Location addressingContent addressing
What the address isWhere the file sitsWhat the file contains
If the file movesThe link breaksThe CID still works
If the file changesThe link still points at itThe CID changes too
Who can serve itOnly the named serverAnyone holding a copy
Checking the fileTrust the serverCheck the hash

Because the CID comes from the content, two people storing the same file produce the same CID, and the network can fetch blocks from both at once. This also removes duplicates: the network stores one copy of each unique block, even if many files share it.

Content addressing is also the idea behind tokenization, where a token on a chain points to an asset stored somewhere else.

How do blockchains and IPFS fit together?

Blockchains and IPFS fit together because each covers the other's weakness. A blockchain gives a tamper-proof record and a shared order of events, but storing large files on it is slow and costly. IPFS stores large files cheaply, but on its own it cannot prove who owned what, or when.

The usual pattern is simple: put the file on IPFS, take its CID, and write the CID into a smart contract or transaction. Anyone can then read the CID from the chain, fetch the file from IPFS, and check the hash to confirm it is the file the chain points to.

This pattern is used for NFT metadata, where the token on the chain points to an image or document on IPFS, and for records that must stay readable for years, such as certificates and legal documents. The chain proves the reference, and IPFS holds the content. Teams building this pattern often work with a blockchain development partner to connect the chain record with the storage layer.

Where is IPFS used today?

IPFS is used wherever files need to stay available without a single company hosting them. The most common uses are NFT metadata, decentralised app frontends, public archives and shared datasets.

  • NFT metadata. The token on the chain stores a CID that points to the image, video or document the token represents.
  • App frontends. A decentralised app can serve its web pages from IPFS, so the interface stays up even if one host goes down.
  • Public archives. Libraries and research groups share datasets and documents that anyone can fetch and verify by hash.
  • Shared datasets. Teams working on the same data can fetch blocks from each other instead of one central server.

In each case the goal is the same: the file should still be there if one host goes away, and anyone should be able to check that the file they received is the file that was meant. IPFS gives both, as long as at least one computer keeps a copy.

For assets that also need ownership rules, the same pattern appears in RWA tokenization, where tokens on a chain represent real-world assets.

How do you store a file on IPFS in five steps?

Storing a file on IPFS takes five steps, and the only part that needs care is making sure the file stays pinned, so the network does not drop it.

  1. Add the file to an IPFS node. Run a node, or use a hosted service, and add the file. The node returns the file's CID.
  2. Copy the CID. This short string is the file's address. Share it, or store it in a smart contract.
  3. Pin the file. Tell a node to keep the file permanently. Without pinning, nodes clear unpinned files to save space.
  4. Record the CID on-chain. Write the CID into a transaction or smart contract so the reference is public and dated.
  5. Share the CID or a gateway link. Anyone with the CID can fetch the file from the network, or through a public gateway in a browser.

Pinning is the step people forget. IPFS nodes clear unpinned files to save space, so a file that nobody pins can vanish even though its CID still exists. A pinning service keeps a copy online for a fee, so check the vendor's site for current pricing, or run your own node.

Example (hypothetical): an archive of 12,000 land documents

Example (hypothetical): a regional registry holds 12,000 scanned land documents, each about 400 KB. Stored on IPFS, the whole archive is 12,000 x 400 KB = 4,800,000 KB, or about 4.8 GB — easy for one pinned node to hold.

On the chain, the registry stores only the CID of each document. Each CID is about 46 bytes, so 12,000 CIDs take 12,000 x 46 = 552,000 bytes, or about 552 KB — a small record that anyone can read to find and verify any document.

If a document is later corrected, the new version gets a new CID, and the chain records the update. The old version stays on IPFS under its old CID, so the history of changes is never lost.

What are the common mistakes?

The most common mistakes are assuming a CID means the file is stored forever, putting private data on IPFS without encrypting it first, and storing the whole file on a chain instead of only its CID.

  • Forgetting to pin. A CID is an address, not storage. Unpinned files are cleared by nodes that need the space.
  • Publishing private files in plain text. Anything on IPFS can be fetched by anyone with the CID, so encrypt sensitive files first.
  • Expecting fast reads everywhere. A file with only one copy on a slow node loads slowly. Pin it in more than one place.
  • Using one gateway as the only access. Gateways are a convenience, not the network. Share the CID itself too.
  • Ignoring content updates. A changed file has a new CID, so update the chain record or the old CID points to the old file.

Key takeaways

  • IPFS finds files by content, not by location
  • A CID is a hash of the file, so it always points to one exact version
  • Blockchains record CIDs; IPFS holds the files themselves
  • Pinning is what keeps a file available — unpinned files can be dropped
  • Encrypt private files before adding them to IPFS

Frequently asked questions

Is IPFS a blockchain?

No. IPFS is a peer-to-peer file network, not a chain of blocks. It stores and shares files by content, while a blockchain records small pieces of data in order. The two are often used together, with the chain holding a file's CID.

What is a CID?

A CID, or content identifier, is a short string made by hashing a file. Because it comes from the file's contents, the same file always produces the same CID, and any change to the file produces a different one.

Does IPFS store files forever?

No. IPFS stores a file only while at least one node keeps a copy, which is called pinning. Nodes clear unpinned files to save space, so a file nobody pins can disappear even though its CID still exists.

Can anyone see files on IPFS?

Yes, anyone with a file's CID can fetch it, so IPFS is not private by default. Files that must stay private should be encrypted before they are added, with the key shared only with the people who should read them.

Why not store files directly on a blockchain?

Storing large files on a chain is slow and costly, because every node in the network must hold a copy. The usual pattern is to store the file on IPFS and record only its small CID on the chain.

What is pinning in IPFS?

Pinning tells an IPFS node to keep a file permanently instead of clearing it when space runs low. You can pin files on your own node or pay a pinning service to keep a copy online.

Found this useful? Share it.
Hertiv engineering team

Written from projects we build for clients: blockchain systems in production. Every post is reviewed by a senior engineer before publishing and updated when practice changes.

About HertivHow we work

Building a decentralised app that needs storage? Talk to Hertiv.

A senior engineer replies within one business day. Or see our Blockchain Development service.

Book a free call

Keep reading

All posts

Tell us what you want to build

A senior engineer reads every request and replies within one business day with questions, a rough range, or a call link.

  • NDA on request before any details
  • You own all code, models and IP
  • US, UK and EU time-zone overlap

Your email app should open with your message ready to send. If it does not, write to [email protected].

Prefer email? Write to [email protected]
Estimate costBook a call