Compressed NFT lifecycle operations
The compressed NFT lifecycle example shows how an application finds a compressed asset, reads the asset state and its Merkle proof, then asks an on-chain program to burn it. The flow connects an indexing RPC service with Bubblegum and Solana state compression so that a lifecycle change uses current proof data and the asset owner’s authority. See Compressed asset programs for the wider compression model and Compressed asset vault design for a custody-focused example.
Lifecycle scope
The example covers the path from a newly minted compressed NFT to its burn request. It uses a normal on-chain NFT collection as context, but the collection is separate from the compressed asset’s stored state.
Asset preparation
The setup creates a Merkle tree, creates a regular NFT collection, and mints a compressed NFT into that tree. The mint is assigned to the payer wallet, which later acts as the owner that requests the burn. This setup gives the later read step a known tree, collection, owner, and asset. compression/…/createAndMint.ts• L32-49 compression/…/createAndMint.ts• L59-77 compression/…/createAndMint.ts• L80-107 compression/…/createAndMint.ts• L109-149
The tree and collection serve different roles in the flow. The tree holds compressed NFT state in a Merkle structure, while the collection groups the asset for discovery and gives it collection metadata. compression/…/compression.ts• L39-83 compression/…/compression.ts• L121-253
References: compression/…/createAndMint.ts• L32-49 compression/…/createAndMint.ts• L59-77 compression/…/createAndMint.ts• L80-107 compression/…/createAndMint.ts• L109-149 compression/…/compression.ts• L39-83
Execution context
The example runs on devnet with the configured wallet. Its test command prepares local copies of the Bubblegum and compression program dependencies when needed, then runs the lifecycle checks. This keeps the burn example connected to the programs that verify the proof and change the compressed tree. compression/…/Anchor.toml• L1-19
References: compression/…/Anchor.toml• L1-19
Asset location
The client locates the target by asking a Digital Asset Standard (DAS) read service for assets in the collection. It then keeps the asset IDs whose recorded owner matches the wallet that will sign the burn. This separates asset search from on-chain mutation because the chain program receives an asset identity only after an indexer has found it. compression/…/fetchNFTsByCollection.ts• L15-35 compression/…/fetchNFTsByCollection.ts• L37-74
The read service must support compressed asset indexing. The local connection wrapper exposes collection and owner searches as well as direct asset and proof reads, and it rejects empty results so the client does not continue with missing state. compression/…/WrapperConnection.ts• L125-177 compression/…/WrapperConnection.ts• L181-243
References: compression/…/fetchNFTsByCollection.ts• L15-74 compression/…/WrapperConnection.ts• L125-177 compression/…/WrapperConnection.ts• L181-243 compression/…/types.ts• L124-169
Proof-backed lifecycle change
The burn is a proof-backed state change. The client reads the asset and its proof, converts the encoded values into instruction inputs, and submits the request through the example program rather than changing the tree directly.
Asset state
The direct asset read supplies the compressed record that the burn needs. Its compression data identifies the tree and leaf position and includes the data and creator hashes. Its ownership data identifies the wallet that must authorize the action. compression/…/types.ts• L42-59 compression/…/types.ts• L124-139
The proof read supplies the current Merkle root and the path from the leaf to that root. The client maps each proof node to a read-only account and decodes the root and hashes into the byte values expected by the on-chain instruction. compression/…/readApi.ts• L10-45 compression/…/utils.ts• L10-28
References: compression/…/types.ts• L42-59 compression/…/types.ts• L92-99 compression/…/readApi.ts• L10-45 compression/…/utils.ts• L10-28
Burn request
The client submits the asset’s root, hashes, nonce, and leaf index with the proof accounts. It also supplies the tree, its Bubblegum authority, the owner signer, and the compression-related program accounts. These inputs let the downstream Bubblegum program verify the leaf and apply the burn to the compressed tree. compression/…/cnft-burn.ts• L39-67
The example program acts as a narrow bridge to Bubblegum. It builds the Bubblegum burn instruction, appends the proof nodes, and invokes it with the owner as signer. The tree authority is derived from the Merkle tree under Bubblegum, which binds the request to the tree named in the asset state. compression/…/lib.rs• L46-67 compression/…/lib.rs• L69-124 compression/…/lib.rs• L128-149
This diagram shows how indexed asset data becomes a proof-backed lifecycle update.
flowchart LR
A[Collection and owner] --> B[DAS asset search]
B --> C[Asset ID]
C --> D[Asset state read]
C --> E[Merkle proof read]
D --> F[Root, hashes, leaf data]
E --> G[Proof accounts]
F --> H[Burn request]
G --> H
H --> I[Example program]
I --> J[Bubblegum burn]
J --> K[Compressed tree state]
References: compression/…/cnft-burn.ts• L39-67 compression/…/lib.rs• L46-124 compression/…/lib.rs• L128-149
Lifecycle boundaries
The client owns discovery and proof collection, while the on-chain programs own authorization and state change. This boundary keeps the indexer as a source of current asset information and keeps the burn valid only when the supplied proof and signer match the tree state.
Read and write roles
The DAS read path describes an asset for the client. The Solana write path does not trust an asset ID alone; it receives the state values and proof accounts needed by Bubblegum. The owner signer and the tree authority connect the requested action to the asset’s owner and tree. compression/…/cnft-burn.ts• L40-65 compression/…/lib.rs• L69-100
The sample keeps the lifecycle action focused on burning. It does not define a general asset service or a custody vault. For authority and custody patterns, continue to Compressed asset vault design. compression/…/README.md• L1-8
References: compression/…/cnft-burn.ts• L39-67 compression/…/lib.rs• L69-100 compression/…/README.md• L1-8
Change checklist
When these files or sections are changed, remember to consider these:
- Changes to the asset search fields must preserve the link between collection membership, owner matching, and the asset ID used for later reads.
- Changes to compression metadata must keep the tree, leaf index, root, data hash, and creator hash aligned across the read response and burn arguments.
- Changes to proof handling must preserve proof-node order and the account list passed to the downstream compression instruction.
- Changes to the on-chain account order or signer rules must stay aligned with the Bubblegum burn contract and the client account mapping.
- Changes to the RPC or test environment must retain devnet access, the configured signer, DAS support, and the program dependencies needed by the burn check.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| RPC service does not support DAS | Asset or proof reads return no usable compressed state. | Use an endpoint that supports getAsset, getAssetProof, and collection asset search. |
| Asset owner does not match the signing wallet | The client can select the wrong asset or the burn cannot pass owner authorization. | Filter discovered assets by owner and pass that owner as the signer. |
| Proof is empty or stale | Bubblegum cannot verify the leaf against the supplied root. | Fetch the proof for the selected asset immediately before building the burn request. |
| Compression hashes or leaf index come from a different asset | The proof-backed burn request does not describe the selected leaf. | Read asset state and proof with the same asset ID and use its compression fields together. |
| Proof accounts or program accounts are incomplete | The CPI fails before the compressed tree changes. | Pass all proof nodes after the fixed accounts and provide Bubblegum, compression, log wrapper, and system accounts. |
| Devnet, wallet, or local program fixtures are unavailable | The example cannot run its proof-backed burn check. | Use the configured devnet wallet and let the test setup fetch the required program fixtures. |
Key files
| File | Why to read it |
|---|---|
| compression/…/cnft-burn.ts | Shows the complete client flow from asset selection to proof-backed burn submission. |
| compression/…/lib.rs | Defines the on-chain lifecycle boundary and the Bubblegum CPI. |
| compression/…/fetchNFTsByCollection.ts | Shows how collection and owner data locate a compressed asset. |
| compression/…/readApi.ts | Shows the direct asset and proof reads used before the state change. |
| compression/…/WrapperConnection.ts | Explains the DAS read surface used for compressed asset discovery and proofs. |
| compression/…/compression.ts | Provides the setup context for the Merkle tree, collection, and compressed mint. |
| compression/…/utils.ts | Shows proof validation and conversion into instruction accounts. |
| compression/…/Anchor.toml | Defines the devnet execution context and the program fixtures used by the lifecycle checks. |