Introducing a new way to review your PRs.

Read the announcement

solana-foundation / program-examples

A repository of Solana program examples

View on GitHub

19 documents · Updated Nov 23, 2026

docs / compressed-assets

Compressed asset programs

The compressed asset examples show how Solana state compression supports lower-cost digital assets while keeping ownership changes under on-chain program control. The current examples use Rust LiteSVM tests to build transactions, call example programs, and check the resulting Merkle tree roots. For the full NFT lifecycle, see Compressed NFT lifecycle operations. For custody design, see Compressed asset vault design.

Compression model

Solana state compression represents many asset records as leaves in a Merkle tree. The tree root summarizes the current state, and a proof lets a program check one leaf without storing the full asset record in a normal account.

Compressed asset records

A compressed NFT, or cNFT, is a non-fungible asset whose owner and metadata are represented by a leaf in a compressed tree. Bubblegum applies the cNFT action, while the SPL Account Compression program checks and records the tree state. A collection can group cNFTs, but the compressed tree remains the place that records each asset leaf. compression/…/mint.rs• L78-105 compression/…/test_cutils.rs• L123-202

The leaf is tied to the tree, its nonce, its owner and delegate, and hashes for its metadata and creators. A state-changing request therefore needs the current root, leaf values, index, and proof for the same asset. compression/…/test_cnft_burn.rs• L118-138 compression/…/test_cnft_vault.rs• L118-138

References: compression/…/mint.rs• L78-105 compression/…/test_cutils.rs• L123-202 compression/…/test_cnft_burn.rs• L118-138 compression/…/test_cnft_vault.rs• L118-138

Client-to-chain state flow

The current examples model the client as a transaction builder in the Rust tests. The test creates the tree and any collection, assembles the required asset values and proof accounts, sends the instruction, and checks that the on-chain root changes to the expected value.

State update flow

This diagram shows how a compressed-asset operation becomes a verified tree update.

flowchart LR
    A[Test setup] --> B[Tree and collection state]
    B --> C[Leaf values and Merkle proof]
    C --> D[Transaction instruction]
    D --> E[Example Solana program]
    E --> F[Bubblegum or compression program]
    F --> G[New compressed tree root]

The current examples do not include the earlier TypeScript DAS read path. They build the asset state and proof in LiteSVM tests, then use the same account and proof shape that an external client must provide. This keeps the tests focused on the on-chain state transition. compression/…/test_cnft_burn.rs• L207-243 compression/…/test_cnft_vault.rs• L215-251 compression/…/test_cutils.rs• L260-312

References: compression/…/test_cnft_burn.rs• L207-243 compression/…/test_cnft_vault.rs• L215-251 compression/…/test_cutils.rs• L260-312

Program examples

The examples cover three product boundaries: custom cNFT actions, program-controlled custody, and owner-controlled retirement. Each example wraps a standard compressed-asset action with its own entry point, then checks the new tree root.

Compressed NFT creation and verification

The utility program demonstrates how an application can add custom logic around cNFT creation and proof verification. Its mint action sends metadata and collection information to Bubblegum, while its verify action derives the leaf hash and asks the compression program to confirm that the supplied owner and leaf data match the root. compression/…/README.md• L3-17 compression/…/mint.rs• L78-105 compression/…/verify.rs• L33-84

The test creates a tree and collection, mints to a test wallet, and then proves that the wrong owner fails while the actual owner succeeds. The result shows the role split between the application instruction and the shared compression checks. compression/…/test_cutils.rs• L260-312

References: compression/…/README.md• L3-17 compression/…/mint.rs• L78-105 compression/…/verify.rs• L33-84 compression/…/test_cutils.rs• L260-312

Compressed NFT custody

The vault program demonstrates custody through a program-derived address, or PDA. A cNFT is minted to the vault PDA, and a withdrawal instruction changes the leaf owner to a recipient through Bubblegum. The example supports both one-asset and two-asset withdrawals. compression/…/README.md• L1-13 compression/…/test_cnft_vault.rs• L207-307

The PDA gives the program control of the asset during the transfer. The example is a custody pattern rather than a complete vault policy: its README warns that any caller can withdraw an asset. A production vault must add its own authorization and asset rules. compression/…/README.md• L20-23 compression/…/test_cnft_vault.rs• L215-307

References: compression/…/README.md• L1-13 compression/…/README.md• L20-23 compression/…/test_cnft_vault.rs• L207-307

Compressed NFT retirement

The burn program demonstrates owner-controlled retirement of a cNFT. The test creates a tree, mints one asset, supplies its current leaf values and proof, and confirms that the tree root changes to the empty-leaf state after the burn. compression/…/README.md• L1-9 compression/…/test_cnft_burn.rs• L207-243

This is the smallest lifecycle example because it adds no custody policy or application asset record. The owner signs the request, and the downstream compressed-asset programs apply the state change. compression/…/test_cnft_burn.rs• L217-243

References: compression/…/README.md• L1-9 compression/…/test_cnft_burn.rs• L207-243

System boundaries

The examples separate application intent from compressed-tree verification. The example program receives a structured request and the accounts needed for the downstream action, while Bubblegum and SPL Account Compression enforce the tree and proof rules.

Authority relationships

The tree authority binds an action to one Merkle tree. The leaf owner or delegate authorizes an asset action, while a vault PDA acts as the owner when the program holds custody. These authorities have different jobs and must be mapped to the correct account in each request. compression/…/mint.rs• L12-66 compression/…/test_cnft_vault.rs• L223-233

The shared programs remain the final state boundary. The application layer chooses whether the request means mint, verify, withdraw, or burn, but the resulting state is accepted only when the compressed leaf and proof agree with the current tree. compression/…/verify.rs• L33-84 compression/…/test_cnft_burn.rs• L217-243

References: compression/…/mint.rs• L12-66 compression/…/verify.rs• L33-84 compression/…/test_cnft_vault.rs• L223-233 compression/…/test_cnft_burn.rs• L217-243

Test environment

The Rust tests run the example program with LiteSVM and load the Bubblegum, SPL Account Compression, SPL Noop, and, for the utility example, Token Metadata programs. Each Anchor test command makes the required program fixtures available before it starts the local state transition test. compression/…/Anchor.toml• L18-19 compression/…/Anchor.toml• L18-19 compression/…/Anchor.toml• L18-19 compression/…/test_cnft_burn.rs• L64-73 compression/…/test_cnft_vault.rs• L64-73 compression/…/test_cutils.rs• L60-70