Why Off-Chain Storage?
Storing data on Ethereum costs approximately $20,000 per megabyte at typical gas prices. Images, videos, and large JSON files must live off-chain while their content hashes or URIs are stored on-chain for verification.
On-Chain vs Off-Chain Storage Tradeoffs
On-chain storage:
- Cost: ~$20,000 per MB (Ethereum mainnet at 30 gwei)
- Persistence: permanent — survives forever as long as Ethereum exists
- Access: any node, any time, instantly
- Suitable for: token balances, ownership records, critical state
Off-chain storage options:
1. IPFS — Content-addressed, decentralized, peer-to-peer
2. Filecoin — Pays nodes to store IPFS data reliably long-term
3. Arweave — One-time payment for permanent storage (~$0.01/MB)
4. Centralized (S3, CloudFront) — Cheap, fast, but single point of failure
The NFT metadata problem:
- On-chain: tokenURI() returns data:application/json;base64,... (base64 encoded JSON)
Very expensive but 100% permanent (used by rare NFTs like Nouns)
- IPFS: tokenURI() returns ipfs://QmHash... — permanent IF pinned
- HTTP: tokenURI() returns https://api.yourserver.com/1.json — server can die
This is NOT decentralized! Most NFTs still do this.Common Mistakes
- Using HTTP URIs for NFT metadata and calling it 'decentralized' — HTTP URIs are centralized. The server owner can change or delete your NFT image at any time.
- Not pinning IPFS content — IPFS content without a pin service (Pinata, Infura, nft.storage) is garbage-collected within days. NFT metadata MUST be pinned.
- Storing large images on-chain — base64 encoding and storing a 1MB image in contract storage would cost ~$20M on mainnet. Always use IPFS for images.
Tip
Tip
Practice Why OffChain Storage in small, isolated examples before integrating into larger projects. Breaking concepts into small experiments builds genuine understanding faster than reading alone.
Once deployed, smart contracts are immutable — code is law
Practice Task
Note
Practice Task — (1) Write a working example of Why OffChain Storage from scratch without looking at notes. (2) Modify it to handle an edge case (empty input, null value, or error state). (3) Share your solution in the Priygop community for feedback.
Quick Quiz
Common Mistake
Warning
A common mistake with Why OffChain Storage is skipping edge case testing — empty inputs, null values, and unexpected data types. Always validate boundary conditions to write robust, production-ready web3 code.
Key Takeaways
- Storing data on Ethereum costs approximately $20,000 per megabyte at typical gas prices.
- Using HTTP URIs for NFT metadata and calling it 'decentralized' — HTTP URIs are centralized. The server owner can change or delete your NFT image at any time.
- Not pinning IPFS content — IPFS content without a pin service (Pinata, Infura, nft.storage) is garbage-collected within days. NFT metadata MUST be pinned.
- Storing large images on-chain — base64 encoding and storing a 1MB image in contract storage would cost ~$20M on mainnet. Always use IPFS for images.