defi

How NFTs Are Stored On-Chain vs. Off-Chain

Learn how NFTs are stored on-chain vs off-chain, including IPFS, Arweave, and smart contract metadata. Understand permanence, cost, and which method protects your digital assets.

How NFTs Are Stored On-Chain vs. Off-Chain

NFTs are stored either directly on a blockchain (on-chain) or by referencing external data (off-chain). Understanding the difference between these two storage methods is crucial for anyone minting, buying, or building with non-fungible tokens. This article breaks down how each approach works, its trade-offs, and why most NFTs you encounter actually live off-chain.

How On-Chain Storage Works for NFTs

When an NFT is stored fully on-chain, every byte of its data — including the image, metadata, and any associated files — is written directly into the blockchain’s ledger. This is the most permanent form of storage because the data becomes part of the immutable history of the network. No external server or third party is required to view or verify the asset; anyone can read the raw data from a blockchain node.

The technical process

Most NFTs on Ethereum follow the ERC-721 standard, which specifies a tokenURI field. For on-chain storage, a smart contract generates the metadata (name, description, attributes) and even the visual content using base64 encoding or SVG generation within the contract itself. For example, a simple on-chain NFT might be a programmatically generated SVG of a colored square, with its color and shape defined entirely by the contract’s logic. The blockchain stores the contract bytecode and the state that defines each token’s properties.

Key point: On-chain storage guarantees permanence — as long as the blockchain exists, the NFT’s data exists exactly as minted. Projects like Larva Labs’ CryptoPunks originally stored punks’ attributes on-chain (while the images were later moved to IPFS in 2019 – see note below). A more modern example is Chainlink VRF-powered generative art where every pixel is rendered on-chain.

⚠️ Note on CryptoPunks: The original CryptoPunks smart contract stored punk attribute strings (e.g., “Zombie,” “Alien”) on-chain, but the 8-bit pixel images were hosted on a web server. In 2019, the images were moved to IPFS to improve decentralization. This illustrates that even early projects didn’t store everything fully on-chain.

Why on-chain storage is rare

Fully on-chain NFTs are uncommon because storage on a blockchain is expensive. Every byte written into a transaction costs gas, and the cost scales with data size. A 1 MB image stored on Ethereum mainnet would cost thousands of dollars in gas fees, making it impractical for anything but tiny files. This is why most NFTs use off-chain storage.

Off-Chain Storage: Where Most NFTs Actually Live

The vast majority of NFTs — including popular collections like Bored Ape Yacht Club, Azuki, and most generative art — store their visual content and metadata off-chain. The blockchain holds only a pointer (a URL or a content hash) that points to the actual data stored elsewhere. The smart contract’s tokenURI returns a link, and wallets like MetaMask or OpenSea fetch the metadata from that location.

Common off-chain storage services

  • IPFS (InterPlanetary File System): A peer-to-peer, content-addressed file system. Data is stored across a network of nodes, and the hash of the content becomes the address (e.g., ipfs://Qm...). IPFS offers content-addressing: if someone modifies the file, the hash changes, so the NFT remains permanently linked to the original file (unless the pinning service removes it).
  • Arweave: A permanent storage network that charges a one-time fee to store data forever. Arweave is used by many NFT platforms because it guarantees data retention without ongoing costs.
  • Centralized servers: Some NFTs point to URLs like https://example.com/nft/1.json. This is risky because the owner of the server can change or delete the image, breaking the NFT.

Example: A Bored Ape Yacht Club NFT’s metadata JSON file is stored on IPFS. The smart contract’s tokenURI returns ipfs://Qm.... When you view the ape in a wallet, the metadata is fetched from IPFS, which contains the link to the actual image (also on IPFS). OpenSea pins this data to ensure availability.

The trade-off: persistence vs. cost

Off-chain storage solves the cost problem but introduces a potential single point of failure. If the storage provider goes offline or stops hosting the file, the NFT becomes “broken” — the blockchain still holds the token, but the associated image and metadata are lost. This is known as the “link rot” problem.

Storage TypeData LocationPermanenceCostDependencyTypical Use Case
On-chainBlockchain ledgerTruly permanentVery highNone (self-contained)Small files, generative art, rare collectibles
Off-chain (IPFS)Distributed networkHigh (if pinned)Low to moderatePinning service / nodeImages, large media, most major NFT collections
Off-chain (Centralized)Web serverVery lowCheapestServer ownerPrototypes, short-term projects

Hybrid Approaches: Best of Both Worlds?

Some NFTs use a hybrid model to balance cost and persistence. For example, the Squiggle by Snowfro is a fully on-chain generative art NFT where the algorithm is stored in the contract, but the resulting visual rendering is deterministic from the token ID. Another hybrid approach stores only a content hash (like a SHA-256 hash) on-chain, while the file itself lives off-chain. The hash acts as a fingerprint — anyone can verify that the off-chain file matches the on-chain commitment, preventing tampering.

ERC-1155 and metadata flexibility

The ERC-1155 multi-token standard also supports both on-chain and off-chain metadata. Developers can choose to embed metadata in the contract’s uri() function or return an external URL. Platforms like OpenSea require a metadata JSON schema that includes name, description, image, and attributes. This schema is typically stored off-chain, but some on-chain projects encode it in base64 within the tokenURI.

Tip for beginners: When minting an NFT, always check where the metadata is stored. If the project uses a centralized URL, consider the risk. If they use IPFS or Arweave, the asset is far more resilient.

Conclusion

NFTs stored on-chain provide unmatched permanence but at a prohibitive cost, making them suitable only for small digital objects like generative text or simple SVGs. Off-chain storage — especially via IPFS or Arweave — is the practical choice for images, videos, and large files, and it powers nearly every major NFT collection you see today. Understanding this distinction helps you evaluate an NFT’s long-term viability and choose the right storage method for your own projects. As blockchain technology evolves, new solutions like data sharding and rollups may reduce on-chain storage costs, but for now, the vast majority of NFTs will continue to rely on off-chain infrastructure.