Setting up Decentralized Data Storage
Decentralized storage is needed not always and not everywhere. NFT metadata on a centralized server—real problem (if server goes down, NFT loses image). Documents for DAO voting on IPFS—justified. User sessions on Filecoin—excessive. Let's start with when this is really needed.
IPFS: Web3 Content Standard
IPFS (InterPlanetary File System)—content-addressed storage. Files identified by CID (Content Identifier)—hash of content. Key property: same file has same CID everywhere. This makes links immutable and verifiable.
Pinning Problem
IPFS doesn't guarantee storage. File exists while someone "pins" it (keeps it). If you just uploaded via ipfs add—in a few days garbage collector might delete file from your node, and if no one else pins—file disappears.
Solutions:
Pinning services:
- Pinata—most popular, REST API, convenient dashboard, $0 up to 1 GB
- web3.storage (from Protocol Labs)—free tier, stores in Filecoin under hood
- Infura IPFS—for teams already using Infura
import { PinataSDK } from 'pinata'
const pinata = new PinataSDK({ pinataJwt: process.env.PINATA_JWT })
// Upload file
const upload = await pinata.upload.file(file)
console.log(upload.IpfsHash) // CID: Qm... or bafy...
// Upload JSON metadata (NFT standard)
const metadata = await pinata.upload.json({
name: "My NFT",
description: "...",
image: `ipfs://${imageCID}`
})
Self-hosted IPFS node with Kubo:
ipfs init
ipfs daemon &
ipfs pin add QmYwAPJzv5CZsnA... # pin specific CID
For production—node with enough disk + pinning all app content. Combination of self-hosted + one pinning service as backup—reasonable minimum.
IPFS Gateway
Browsers don't understand ipfs:// natively (Brave is exception). For users need HTTP gateway:
-
https://ipfs.io/ipfs/{CID}—public, slow -
https://gateway.pinata.cloud/ipfs/{CID}—faster for pinned content - Own gateway—
ipfs daemoncan work as gateway on port 8080
For NFT marketplaces—own gateway mandatory. Dependence on ipfs.io violates decentralization.
Filecoin: Guaranteed Long-term Storage
IPFS—addressing protocol. Filecoin—economic layer on top. Storage Providers receive FIL for storing data by verifiable deal contracts.
Working with Filecoin directly is complex: need deals, minimum storage size, specific API. In practice use abstractions:
Lighthouse—simple API for Filecoin storage, works like pinning service:
import lighthouse from '@lighthouse-web3/sdk'
const response = await lighthouse.upload('./path/to/file', API_KEY)
console.log(response.data.Hash) // CID
// Data automatically stored in Filecoin deals
estuary (deprecated) / w3s (web3.storage)—similar approach.
Filecoin justified for: long-term archives, DAO data, compliance-sensitive documents where need proof of storage.
Arweave: "Pay Once, Store Forever"
Arweave—fundamentally different approach. One-time payment covers storage forever (mathematically: 200 years with current chain size). Uses Active Storage Model—AR token.
Cost: ~$5–10 per GB (changes with AR price). For small NFT collections—very attractive compared to monthly payments.
Bundlr (now Irys)—abstraction over Arweave, multi-currency payment (ETH, SOL, MATIC instead of AR):
import Irys from '@irys/sdk'
const irys = new Irys({
network: 'mainnet',
token: 'ethereum',
key: process.env.PRIVATE_KEY
})
const response = await irys.uploadFile('./nft-image.png')
console.log(`https://arweave.net/${response.id}`)
Arweave—first choice for NFT images and permanent on-chain data. Solana NFT ecosystem (Metaplex) historically uses Arweave.
Storj and Sia: Encrypted P2P Storage
Storj—enterprise-grade decentralized storage with S3-compatible API. Data encrypted and split across network nodes. For apps that need S3 replacement with privacy guarantees:
import { S3Client } from '@aws-sdk/client-s3'
const client = new S3Client({
endpoint: 'https://gateway.storjshare.io',
credentials: { accessKeyId: KEY, secretAccessKey: SECRET },
region: 'us-east-1'
})
// Then standard AWS S3 SDK
Storage Choice: Decision Matrix
| Use Case | Solution | Reason |
|---|---|---|
| NFT images | Arweave / IPFS + Pinata | Permanence, industry standard |
| NFT metadata JSON | Arweave / IPFS | Same |
| DAO documents | IPFS + Filecoin | Verifiability + long-term |
| User content (UGC) | IPFS + self-hosted gateway | Flexibility, control |
| Private encrypted data | Storj | S3 compatibility, encryption |
| Archives, compliance | Filecoin | Proof of storage |
What Gets Set Up in 1–3 Days
Choice and setup of storage for your use case, SDK integration into backend or smart contracts (CID in contract instead of HTTP URL), IPFS gateway setup (self-hosted or via CDN), upload pipeline for NFT content (image → CID → metadata JSON → CID → mint), automatic pinning of new files.







