Decentralized Storage

Production engineering guide for decentralized storage in Web3 and blockchain systems.

Decentralized storage enables data to be persisted across a network of independent nodes, with no single point of control or failure. It matters when data must be available, immutable, verifiable, and resistant to censorship or downtime—common in blockchain applications, content delivery, and identity systems. Unlike centralized clouds, decentralized storage ensures that data remains accessible even if individual nodes fail, and that integrity is guaranteed through cryptographic proofs and distributed consensus.

Data Ingestion and Upload

To store data on a decentralized network, the first step is uploading a file or stream of bytes. The common workflow uses a client library or command-line tool to prepare and send data to a storage network.

curl -X POST \
  -H "Content-Type: application/json" \
  -d '{
    "data": "base64-encoded-content",
    "metadata": {
      "title": "User profile",
      "owner": "0x742d35cc6634c51d3650c5a35c3d1b13e5e3c3b1",
      "tags": ["profile", "public"]
    }
  }' \
  https://ipfs.example.com/api/v0/add

The server responds with a content identifier (CID), a cryptographic hash of the data and metadata:

{
  "Hash": "QmW2W4Ck1C3s1f85nS751473915Z2L5nC7Z2XxYR5pL3K7",
  "Name": "user-profile.json",
  "Size": 1024,
  "CumulativeSize": 1024
}

The CID is the universal key to retrieve the data. The upload process supports two modes: *direct* and *chunked*. Direct upload is suitable for small files (<1MB); chunked upload is required for large files and enables deduplication across the network.

When uploading large files, the client may use a chunkSize parameter to control the granularity of data division:

curl -X POST \
  -H "Content-Type: application/json" \
  -d '{
    "data": "base64-encoded-file",
    "chunkSize": 65536,
    "pin": true,
    "progress": true
  }' \
  https://ipfs.example.com/api/v0/add

Setting pin: true ensures the file is pinned to the network, preventing it from being garbage-collected. The progress: true flag enables real-time feedback via a stream of updates.

A common failure mode occurs when the upload client times out during a large file upload. The server may return a 202 Accepted status with a Location header pointing to a job endpoint:

HTTP/1.1 202 Accepted
Location: /api/v0/jobs/5a3b1c2d
Content-Type: application/json

{
  "jobId": "5a3b1c2d",
  "status": "in-progress",
  "uploadedBytes": 819200,
  "totalBytes": 1048576,
  "progress": 0.78125
}

The client must poll this job endpoint until status: "completed" or handle 408 Request Timeout on the initial upload.

Data Retrieval and Access

Once stored, data is accessible via its CID. The standard access method is a GET request to a gateway service:

GET /ipfs/QmW2W4Ck1C3s1f85nS751473915Z2L5nC7Z2XxYR5pL3K7 HTTP/1.1
Host: gateway.ipfs.io
Accept: application/json

The gateway returns the data as a stream, with Content-Type: application/octet-stream for raw data, or application/json for structured data.

For structured data, a common pattern is to use a *content-addressed path* to access nested resources:

GET /ipfs/QmW2W4Ck1C3s1f85nS751473915Z2L5nC7Z2XxYR5pL3K7/data/profile.json HTTP/1.1
Host: gateway.ipfs.io

This allows a single CID to represent a directory, with paths resolved within the content tree.

When clients need metadata or multiple files, they often fetch a manifest.json file stored at the root CID. This file contains a list of all files and their paths, enabling clients to discover the full dataset:

{
  "version": 1,
  "files": [
    {
      "path": "profile.json",
      "cid": "QmXyZ1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p7q8r9s0t1",
      "size": 1024
    },
    {
      "path": "avatar.jpg",
      "cid": "QmZ1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p7q8r9s0t1u2",
      "size": 20480
    }
  ]
}

Clients may cache this manifest locally, reducing the number of round trips. A failure mode arises when the manifest is updated but not re-cached: the client returns stale data until the next GET request.

Data Integrity and Verification

Decentralized storage guarantees data integrity through cryptographic hashing. Each file or directory is represented as a Merkle DAG node, where each node has a unique CID. The CID is computed as the SHA-256 hash of a serialized representation of the node.

Clients verify data integrity by recomputing the CID from the received data and comparing it to the expected value. The process is simple:

  1. Receive data from a gateway.
  2. Parse the data as a binary or JSON object.
  3. Compute the SHA-256 hash of the data.
  4. Compare the computed hash to the expected CID.

A common error occurs when the data is received in a different encoding: a base64-encoded file is decoded incorrectly, leading to a mismatched CID. The client must ensure the data is in the correct byte format before hashing.

For large datasets, clients may verify the full DAG. This involves fetching the root CID and recursively verifying all child nodes. A failure mode is a *missing link*—a child node whose CID does not match the expected value in the parent. The error message is usually a 404 Not Found with a X-CID-Expected header:

HTTP/1.1 404 Not Found
X-CID-Expected: QmXyZ1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p7q8r9s0t1
X-CID-Actual: QmZ1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p7q8r9s0t1u2
Content-Type: application/json

{
  "error": "Link mismatch",
  "expected": "QmXyZ1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p7q8r9s0t1",
  "actual": "QmZ1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p7q8r9s0t1u2"
}

Clients use this to detect data corruption or versioning errors.

Data Persistence and Pinning

Data is not automatically persistent in decentralized storage. To ensure it remains available, the network must *pin* the data to one or more nodes. A pinned file is marked as “important” and is not eligible for garbage collection.

Clients can pin a CID via a POST request to a pinning service:

POST /pin HTTP/1.1
Host: pinning-service.example.com
Content-Type: application/json

{
  "cid": "QmW2W4Ck1C3s1f85nS751473915Z2L5nC7Z2XxYR5pL3K7",
  "type": "recursive",
  "name": "user-profile-v1"
}

The type field can be direct, recursive, or cascade. recursive pins the root CID and all its children. cascade also pins all ancestors of the root CID.

The service responds with a 201 Created status and a Location header:

HTTP/1.1 201 Created
Location: /pins/QmW2W4Ck1C3s1f85nS751473915Z2L5nC7Z2XxYR5pL3K7
Content-Type: application/json

{
  "pinId": "QmW2W4Ck1C3s1f85nS751473915Z2L5nC7Z2XxYR5pL3K7",
  "status": "pending",
  "type": "recursive",
  "name": "user-profile-v1",
  "createdAt": "2023-09-15T10:00:00Z"
}

A silent failure occurs when the client forgets to poll the pin status. The pinning service may report status: "pending" but never transition to completed. This leads to data being available in the network but not yet fully validated.

Clients often use a retry mechanism with exponential backoff. A typical configuration includes:

This prevents unnecessary load on the network during transient failures.

Data Versioning and Updates

When a file is updated, the new version is stored under a new CID. The system supports versioning through a *versioned manifest* pattern. The root CID points to a manifest.json that includes a version field and an array of history entries:

{
  "version": "2.1.0",
  "timestamp": "2023-09-15T12:30:00Z",
  "history": [
    {
      "version": "2.0.0",
      "cid": "QmXyZ1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p7q8r9s0t1",
      "timestamp": "2023-09-14T08:00:00Z",
      "author": "0x742d35cc6634c51d3650c5a35c3d1b13e5e3c3b1"
    },
    {
      "version": "1.0.0",
      "cid": "QmW2W4Ck1C3s1f85nS751473915Z2L5nC7Z2XxYR5pL3K7",
      "timestamp": "2023-09-01T09:15:00Z",
      "author": "0x1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p7q8r9s0t1u2"
    }
  ]
}

Clients can fetch the latest version by resolving the latest CID and retrieving the manifest. To update a file, the client:

  1. Uploads the new file.
  2. Computes the new CID.
  3. Updates the manifest with the new version.
  4. Uploads the updated manifest.
  5. Pins the new manifest and the new data.

A subtle error occurs when the manifest is updated but the new data is not pinned. The client fetches the manifest and sees the new version, but the underlying data is not available. This leads to 404 errors on individual files.

Data Discovery and Naming

While CIDs are universal, they are opaque. To make data discoverable, systems use *content naming*—mapping human-readable names to CIDs.

The most common approach is a *name resolution* service that maps a string to a CID. Clients send a GET request with a name:

GET /name/username/avatar HTTP/1.1
Host: resolver.example.com

The resolver returns a 302 Found redirect to the corresponding CID:

HTTP/1.1 302 Found
Location: /ipfs/QmZ1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p7q8r9s0t1u2
Content-Type: text/plain

QmZ1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p7q8r9s0t1u2

Clients can resolve names in a pipeline: first resolve the name to a CID, then fetch the data from the CID.

A common failure is *name caching*. A client resolves username/avatar and caches the CID locally. But when the name is updated, the old CID remains in the cache. The client must either:

The resolver may also return a Link header pointing to the canonical name:

Link: <https://resolver.example.com/name/username/avatar>; rel="canonical"

Clients use this to build a graph of name references across the network.

Data Lifecycle and Orchestration

Large applications orchestrate storage across multiple stages. A typical workflow includes:

  1. Upload a file to a temporary storage.
  2. Compute its CID and store it in a database.
  3. Pin the CID to a pinning service.
  4. Update a manifest with the new version.
  5. Publish the manifest to a content naming service.

This workflow is often implemented as a series of curl commands in a shell script or a systemd service.

A critical configuration key is retryStrategy in the pinning service configuration:

{
  "retryStrategy": {
    "initialDelay": 1000,
    "maxDelay": 30000,
    "maxAttempts": 10,
    "backoffFactor": 2,
    "retryOn": ["5xx", "429"]
  }
}

The backoffFactor of 2 means each retry waits double the time of the previous one. This prevents the network from being overwhelmed during a failure.

A sharp edge is the *stale pin* problem: a node pins a CID but does not update it when the data changes. The client must periodically verify that the pinned data matches the latest version. The verification process involves:

  1. Fetching the latest CID.
  2. Comparing it to the pinned CID.
  3. If different, re-pinning the new CID.

This can be automated with a cron job:

0 */6 * * * /opt/pin-checker --interval=6h --max-age=1d

The --max-age=1d flag ensures that a pin is updated if it is older than one day.

Decentralized storage is not just about storing data—it is about building a resilient, verifiable, and discoverable data layer that underpins modern web applications. The patterns described here are not tied to a single platform but are the shared foundation of decentralized systems.

This page was rewritten on 18 October 2026. It replaced a templated version that was not specific to its own title. How these pages are written and checked. If anything here is wrong, tell us at [email protected] and we will correct it.