State Compression Basics
8 examples to get you started with state compression and cNFTs - 6 basic and 2 intermediate.
Search across all documentation pages
8 examples to get you started with state compression and cNFTs - 6 basic and 2 intermediate.
npm install @solana/kit@7.0.0 @metaplex-foundation/mpl-bubblegum @metaplex-foundation/mpl-account-compressionDAS-enabled RPC required for proof reads. SPL Account Compression program: cmtDvXnzBMY46rZyrBGX7p7r4Xc78DGpXEC5rVjrvAf.
Full NFT mint accounts cost rent per item. Compression amortizes cost across millions of leaves.
// Full NFT: ~several accounts per item
// cNFT: one tree account + leaf hash updates per mintRelated: Cost & Trade-offs
Concurrent Merkle Trees allow multiple updates per slot without serializing entire tree rewrites.
const TREE_PROGRAM = "cmtDvXnzBMY46rZyrBGX7p7r4Xc78DGpXEC5rVjrvAf";
// Tree account stores root, canopy, and change logRelated: How Compression Works
Bubblegum mints and transfers compressed NFTs into trees.
const BUBBLEGUM_PROGRAM = "BGUMAp9Gq7iN3nEkgqX1FbwwdBonfLCEEgxoj36SYPk";Related: Compressed NFTs (Bubblegum)
Wallets do not decode merkle leaves manually.
const asset = await dasRpc("getAsset", { id: "CNFT_ASSET_ID" });
console.log(asset.compression?.leaf_id, asset.compression?.tree);compression object on DAS asset responseinterface often CompressedNftgetAccountInfo on asset id is not sufficientRelated: Reading Compressed Assets (DAS)
Transfers need merkle proof path from DAS.
const proof = await dasRpc("getAssetProof", { id: "CNFT_ASSET_ID" });
console.log(proof.root, proof.proof.length);root used at build time for debugging failuresRelated: Transferring cNFTs
Tree creator controls minting; delegates can be granted for custodial mint services.
# Tree created with tree authority signer
# Bubblegum mint CPIs update leaf under authority rulesRelated: Compressed NFTs (Bubblegum)
// 1. createTree (depth/maxBufferSize/canopy per capacity plan)
// 2. mintV1 in loop or batch transactions
// 3. monitor leaf index via DAS getAssetsByGroupRelated: Compression Best Practices
| Use cNFT | Use Core / Token Metadata |
|---|---|
| 10k+ similar items | 1/1 fine art |
| Low per-item cost priority | Maximum wallet simplicity |
| DAS-backed read stack | Heavy on-chain program composability per NFT |
Related: NFT Basics on Solana
Stack versions: This page was written for Agave 4.1.1, Solana CLI 3.0.10, Anchor 0.32.1, anchor-lang 0.32.1, Rust 1.91.1, @solana/kit 7.0.0, Surfpool 0.12.0, and LiteSVM 0.6.x.
Reviewed by Chris St. John·Last updated Jul 19, 2026