> ## Documentation Index
> Fetch the complete documentation index at: https://www.zkcompression.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Burn Compressed Accounts

> Guide to burn compressed accounts in Solana programs with full code examples.

Compressed accounts are permanently burned via CPI to the Light System Program.

Burning a compressed account

* consumes the existing account hash, and
* produces no output state.
* A burned account cannot be reinitialized.

> [!NOTE]
>
> Find [full code examples at the end](https://www.zkcompression.com/compressed-pdas/guides/how-to-burn-compressed-accounts.md#full-code-example) for Anchor and native Rust.

# Implementation Guide

This guide will cover the components of a Solana program that burns compressed accounts.\
Here is the complete flow to burn compressed accounts:

![](https://mintcdn.com/luminouslabs-cc5545c6/_CD81U5EBeZEhMtt/images/program-burn.png?fit=max\&auto=format\&n=_CD81U5EBeZEhMtt\&q=85\&s=9c7b0bbfe1dedddb5df78e0ff8ec61e9)

> [tab] Guide
>
> **Step 1**
>
> ### Program Setup
>
> > [accordion] Dependencies, Constants, Compressed Account
> >
> > **Dependencies**
> >
> > Add dependencies to your program.
> >
> > ```toml Anchor theme={null}
> > [dependencies]
> > light-sdk = "0.23.0"
> > anchor_lang = "0.31.1"
> > ```
> >
> > ```toml Native Rust theme={null}
> > [dependencies]
> > light-sdk = "0.23.0"
> > borsh = "0.10.4"
> > solana-program = "2.2"
> > ```
> >
> > * The `light-sdk` provides macros, wrappers and CPI interface to create and interact with compressed accounts.
> > * Add the serialization library (`borsh` for native Rust, or use `AnchorSerialize`).
> >
> > **Constants**
> >
> > Set program address and derive the CPI authority PDA to call the Light System program.
> >
> > ```rust theme={null}
> > declare_id!("rent4o4eAiMbxpkAM1HeXzks9YeGuz18SEgXEizVvPq");
> >
> > pub const LIGHT_CPI_SIGNER: CpiSigner =
> >     derive_light_cpi_signer!("rent4o4eAiMbxpkAM1HeXzks9YeGuz18SEgXEizVvPq");
> > ```
> >
> > **`CPISigner`** is the configuration struct for CPI's to the Light System Program.
> >
> > * CPIs to the Light System program must be signed with a PDA derived by your program with the seed `b"authority"`
> > * `derive_light_cpi_signer!` derives the CPI signer PDA for you at compile time.
> >
> > **Compressed Account**
> >
> > Define your compressed account struct.
> >
> > ```rust Anchor theme={null}
> > #[event] // declared as event so that it is part of the idl.
> > #[derive(
> >     Clone,
> >     Debug,
> >     Default,
> >     LightDiscriminator
> > )]
> > pub struct MyCompressedAccount {
> >     pub owner: Pubkey,
> >     pub message: String,
> > }
> > ```
> >
> > ```rust Native Rust theme={null}
> > #[derive(
> >     Debug,
> >     Default,
> >     Clone,
> >     BorshSerialize,
> >     BorshDeserialize,
> >     LightDiscriminator,
> > )]
> > pub struct MyCompressedAccount {
> >     pub owner: Pubkey,
> >     pub message: String,
> > }
> > ```
> >
> > You derive
> >
> > * the standard traits (`Clone`, `Debug`, `Default`),
> >
> > * `borsh` or `AnchorSerialize` to serialize account data, and
> >
> > * `LightDiscriminator` to implements a unique type ID (8 bytes) to distinguish account types. The default compressed account layout enforces a discriminator in its *own field*, not the first 8 bytes of the data field (The Anchor framework reserves the first 8 bytes of a *regular account's data field* for the discriminator.).
> >
> > > [!NOTE]
> > >
> > > The traits listed above are required for `LightAccount`. `LightAccount` wraps `MyCompressedAccount` in Step 3 to set the discriminator and create the compressed account's data.
>
> **Step 2**
>
> ### Instruction Data
>
> Define the instruction data with the following parameters:
>
> > [tab] Anchor
> >
> > ```rust theme={null}
> > pub fn burn_account<'info>(
> >     ctx: Context<'_, '_, '_, 'info, GenericAnchorAccounts<'info>>,
> >     proof: ValidityProof,
> >     account_meta: CompressedAccountMetaBurn,
> >     current_message: String,
> > ) -> Result<()>
> > ```
>
> > [tab] Native Rust
> >
> > ```rust theme={null}
> > pub struct BurnInstructionData {
> >     pub proof: ValidityProof,
> >     pub account_meta: CompressedAccountMetaBurn,
> >     pub current_account: MyCompressedAccount,
> > }
> > ```
>
> 1. **Validity Proof**
>
> * Define `proof` to include the proof that the account exists in the state tree.
>
> * Clients fetch a validity proof with `getValidityProof()` from an RPC provider that supports ZK Compression (Helius, Triton, ...).
>
> 2. **Specify input state**
>
> * Define `account_meta: CompressedAccountMetaBurn` to reference the existing account for the Light System Program to nullify permanently:
>   * `tree_info: PackedStateTreeInfo`: References the existing account hash in the state tree.
>
>   * `address`: The account's derived address.
>
> > [!NOTE]
> >
> > Burn does not specify an output state tree. `CompressedAccountMetaBurn` omits `output_state_tree_index` because no output state is created.
>
> 3. **Current account data**
>
> * Define fields to include the current account data passed by the client.
> * This depends on your program logic. This example includes `current_message` (or `current_account` in Native Rust).
>
> **Step 3**
>
> ### Burn Compressed Account
>
> Burn the compressed account permanently with `LightAccount::new_burn()`. No account can be reinitialized at this address in the future.
>
> > [!NOTE]
> >
> > `new_burn()`
> >
> > 1. hashes the current account data as input state and
> > 2. creates no output state to burn the account permanently.
>
> > [tab] Anchor
> >
> > ```rust theme={null}
> > let my_compressed_account = LightAccount::<MyCompressedAccount>::new_burn(
> >     &crate::ID,
> >     &account_meta,
> >     MyCompressedAccount {
> >         owner: ctx.accounts.signer.key(),
> >         message: current_message,
> >     },
> > )?;
> > ```
>
> > [tab] Native Rust
> >
> > ```rust theme={null}
> > let my_compressed_account = LightAccount::<MyCompressedAccount>::new_burn(
> >     &ID,
> >     &instruction_data.account_meta,
> >     instruction_data.current_account,
> > )?;
> > ```
>
> **Pass these parameters to `new_burn()`:**
>
> * `&program_id`: The program's ID that owns the compressed account.
> * `&account_meta`: The `CompressedAccountMetaBurn` from instruction data (*Step 2*) that identifies the existing account for the Light System Program to nullify permanently.
>   * Anchor: Pass `&account_meta` directly
>   * Native Rust: Pass `&instruction_data.account_meta`
> * Include the curent account data.
>   * Anchor: Build `MyCompressedAccount` with `owner` and `message`.
>   * Native Rust: Pass `instruction_data.current_account` directly.
>
> **The SDK creates:**
>
> * A `LightAccount` wrapper that marks the account as permanently burned with no output state.
>
> > [!NOTE]
> >
> > `new_burn()` hashes the input state. The Light System Program verifies the input hash and nullifies it in *Step 4*.
>
> **Step 4**
>
> ### Light System Program CPI
>
> The Light System Program CPI burns the compressed account permanently.
>
> > [!NOTE]
> >
> > The Light System Program
> >
> > * validates the account exists in state tree with the validity,
> > * nullifies the existing account hash, and
> > * creates no output state.
>
> > [tab] Anchor
> >
> > ```rust theme={null}
> > let light_cpi_accounts = CpiAccounts::new(
> >     ctx.accounts.signer.as_ref(),
> >     ctx.remaining_accounts,
> >     crate::LIGHT_CPI_SIGNER,
> > );
> >
> > LightSystemProgramCpi::new_cpi(LIGHT_CPI_SIGNER, proof)
> >     .with_light_account(my_compressed_account)?
> >     .invoke(light_cpi_accounts)?;
> > ```
> >
> > **Set up `CpiAccounts::new()`:**
> >
> > `CpiAccounts::new()` parses accounts for the CPI call to Light System Program.
> >
> > **Pass these parameters:**
> >
> > * `ctx.accounts.signer.as_ref()`: the transaction signer
> > * `ctx.remaining_accounts`: Slice with `[system_accounts, ...packed_tree_accounts]`. The client builds this with `PackedAccounts` and passes it to the instruction.
> > * `&LIGHT_CPI_SIGNER`: Your program's CPI signer PDA defined in Constants.
>
> > [tab] Native Rust
> >
> > ```rust theme={null}
> > let (signer, remaining_accounts) = accounts
> >     .split_first();
> >
> > let cpi_accounts = CpiAccounts::new(
> >     signer,
> >     remaining_accounts,
> >     LIGHT_CPI_SIGNER
> > );
> >
> > LightSystemProgramCpi::new_cpi(LIGHT_CPI_SIGNER, instruction_data.proof)
> >     .with_light_account(my_compressed_account)?
> >     .invoke(cpi_accounts)?;
> > ```
> >
> > **Set up `CpiAccounts::new()`:**
> >
> > `CpiAccounts::new()` parses accounts for the CPI call to Light System Program.
> >
> > **Pass these parameters:**
> >
> > * `signer`: account that signs and pays for the transaction
> > * `remaining_accounts`: Slice with `[system_accounts, ...packed_tree_accounts]`. The client builds this with `PackedAccounts`.
> >   * `split_first()` extracts the fee payer from the accounts array to separate it from the Light System Program accounts needed for the CPI.
> > * `&LIGHT_CPI_SIGNER`: Your program's CPI signer PDA defined in Constants.
>
> > [accordion] System Accounts List
> >
> > <table>
> >   <colgroup>
> >     <col />
> >
> >     <col />
> >
> >     <col />
> >   </colgroup>
> >
> >   <thead>
> >     <tr>
> >       <th />
> >
> >       <th />
> >
> >       <th />
> >     </tr>
> >   </thead>
> >
> >   <tbody>
> >     <tr>
> >       <td>1</td>
> >       <td>**Light System Program (SySTEM1eSU2p4BGQfQpimFEWWSC1XDFeun3Nqzz3rT7)**</td>
> >       <td>Verifies validity proofs, compressed account ownership checks, and CPIs the Account Compression Program to update tree accounts.</td>
> >     </tr>
> >
> >     <tr>
> >       <td>2</td>
> >       <td>**CPI Signer**</td>
> >
> >       <td>
> >         * PDA to sign CPI calls from your program to the Light System Program.\\
> >
> >         * Verified by the Light System Program during CPI.\\
> >
> >         * Derived from your program ID.
> >       </td>
> >     </tr>
> >
> >     <tr>
> >       <td>3</td>
> >       <td>**Registered Program PDA**</td>
> >       <td>Provides access control to the Account Compression Program.</td>
> >     </tr>
> >
> >     <tr>
> >       <td>4</td>
> >       <td>**Account Compression Authority (PDA derived from Light System Program ID with seed b 'cpi\_authority'.HZH7qSLcpAeDqCopVU4e5XkhT9j3JFsQiq8CmruY3aru)**</td>
> >       <td>Signs CPI calls from the Light System Program to the Account Compression Program.</td>
> >     </tr>
> >
> >     <tr>
> >       <td>5</td>
> >       <td>**Account Compression Program (compr6CUsB5m2jS4Y3831ztGSTnDpnKJTKS95d64XVq)**</td>
> >
> >       <td>
> >         * Writes to state and address tree accounts.\\
> >
> >         * Clients and the Account Compression Program do not interact directly — handled internally.
> >       </td>
> >     </tr>
> >
> >     <tr>
> >       <td>6</td>
> >       <td>**System Program (11111111111111111111111111111111)**</td>
> >       <td>Solana System Program used to transfer lamports.</td>
> >     </tr>
> >   </tbody>
> > </table>
>
> **Build the CPI instruction**:
>
> * `new_cpi()` initializes the CPI instruction with the `proof` to prove the account exists in the state tree *- defined in the Instruction Data (Step 2).*
> * `with_light_account` adds the `LightAccount` wrapper configured to burn the account *- defined in Step 3*.
> * `invoke(light_cpi_accounts)` calls the Light System Program with `CpiAccounts`.

> [tab] AI Prompt
>
> Build a program that permanently burns compressed accounts
>
> \---
> &#x20;     description: Build a program that permanently burns compressed accounts
> &#x20;     allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp\_\_deepwiki, mcp\_\_zkcompression
> &#x20;     \---
>
> &#x20;     \## Build a program that permanently burns compressed accounts
>
> &#x20;     Context:
> &#x20;     \- Guide: [https://zkcompression.com/compressed-pdas/guides/how-to-burn-compressed-accounts](https://zkcompression.com/compressed-pdas/guides/how-to-burn-compressed-accounts)
> &#x20;     \- Skills and resources index: [https://zkcompression.com/skill.md](https://zkcompression.com/skill.md)
> &#x20;     \- Crate: light-sdk (LightAccount, CpiAccounts, LightSystemProgramCpi, derive\_light\_cpi\_signer!)
> &#x20;     \- Anchor example: [https://github.com/Lightprotocol/program-examples/tree/main/basic-operations/anchor/burn](https://github.com/Lightprotocol/program-examples/tree/main/basic-operations/anchor/burn)
> &#x20;     \- Native Rust example: [https://github.com/Lightprotocol/program-examples/tree/main/basic-operations/native/programs/burn](https://github.com/Lightprotocol/program-examples/tree/main/basic-operations/native/programs/burn)
>
> &#x20;     Key SDK API: LightAccount::new\_burn()
>
> &#x20;     \### 1. Index project
> &#x20;     \- Grep \`declare\_id|#\[program]|entrypoint!|Pubkey|AccountInfo|burn|destroy|permanent\` across src/
> &#x20;     \- Glob \`\*\*/\*.rs\` and \`\*\*/Cargo.toml\` for project structure
> &#x20;     \- Identify: program ID, existing instructions, account structs, framework (Anchor or native)
> &#x20;     \- Read Cargo.toml — note existing dependencies and Solana SDK version
> &#x20;     \- Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel
>
> &#x20;     \### 2. Read references
> &#x20;     \- WebFetch the guide above — review both Anchor and Native Rust code samples
> &#x20;     \- WebFetch skill.md — check for a dedicated skill and resources matching this task
> &#x20;     \- TaskCreate one todo per phase below to track progress
>
> &#x20;     \### 3. Clarify intention
> &#x20;     \- AskUserQuestion: what is the goal? (new program from scratch, add account burn to existing program, migrate from regular accounts)
> &#x20;     \- AskUserQuestion: Anchor or Native Rust framework?
> &#x20;     \- AskUserQuestion: does the program already have compressed account instructions, or is this the first one?
> &#x20;     \- Summarize findings and wait for user confirmation before implementing
>
> &#x20;     \### 4. Create plan
> &#x20;     \- Based on steps 1–3, draft an implementation plan: which files to modify, what code to add, dependency changes
> &#x20;     \- Follow the guide's step order: Dependencies → Constants → Account Struct → Instruction Data → Burn Compressed Account → Light System Program CPI
> &#x20;     \- If anything is unclear or ambiguous, loop back to step 3 (AskUserQuestion)
> &#x20;     \- Present the plan to the user for approval before proceeding
>
> &#x20;     \### 5. Implement
> &#x20;     \- Add deps: Bash \`cargo add light-sdk\@0.23\` (add \`anchor\_lang\@0.31\` for Anchor or \`solana-program\@2.2\` + \`borsh\@0.10\` for Native Rust)
> &#x20;     \- Follow the guide and the approved plan
> &#x20;     \- Write/Edit to create or modify files
> &#x20;     \- TaskUpdate to mark each step done
>
> &#x20;     \### 6. Verify
> &#x20;     \- Bash \`cargo build-sbf\` or \`anchor build\`
> &#x20;     \- Bash \`cargo test-sbf\` or \`anchor test\` if tests exist
> &#x20;     \- TaskUpdate to mark complete
>
> &#x20;     \### Tools
> &#x20;     \- mcp\_\_zkcompression\_\_SearchLightProtocol("\<query>") for API details
> &#x20;     \- mcp\_\_deepwiki\_\_ask\_question("Lightprotocol/light-protocol", "\<q>") for architecture
> &#x20;     \- Task subagent with Grep/Read/WebFetch for parallel lookups
> &#x20;     \- TaskList to check remaining work
>
> ```text theme={null}
> ---
> description: Build a program that permanently burns compressed accounts
> allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
> ---
>
> ## Build a program that permanently burns compressed accounts
>
> Context:
> - Guide: https://zkcompression.com/compressed-pdas/guides/how-to-burn-compressed-accounts
> - Skills and resources index: https://zkcompression.com/skill.md
> - Crate: light-sdk (LightAccount, CpiAccounts, LightSystemProgramCpi, derive_light_cpi_signer!)
> - Anchor example: https://github.com/Lightprotocol/program-examples/tree/main/basic-operations/anchor/burn
> - Native Rust example: https://github.com/Lightprotocol/program-examples/tree/main/basic-operations/native/programs/burn
>
> Key SDK API: LightAccount::new_burn()
>
> ### 1. Index project
> - Grep `declare_id|#\[program\]|entrypoint!|Pubkey|AccountInfo|burn|destroy|permanent` across src/
> - Glob `**/*.rs` and `**/Cargo.toml` for project structure
> - Identify: program ID, existing instructions, account structs, framework (Anchor or native)
> - Read Cargo.toml — note existing dependencies and Solana SDK version
> - Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel
>
> ### 2. Read references
> - WebFetch the guide above — review both Anchor and Native Rust code samples
> - WebFetch skill.md — check for a dedicated skill and resources matching this task
> - TaskCreate one todo per phase below to track progress
>
> ### 3. Clarify intention
> - AskUserQuestion: what is the goal? (new program from scratch, add account burn to existing program, migrate from regular accounts)
> - AskUserQuestion: Anchor or Native Rust framework?
> - AskUserQuestion: does the program already have compressed account instructions, or is this the first one?
> - Summarize findings and wait for user confirmation before implementing
>
> ### 4. Create plan
> - Based on steps 1–3, draft an implementation plan: which files to modify, what code to add, dependency changes
> - Follow the guide's step order: Dependencies → Constants → Account Struct → Instruction Data → Burn Compressed Account → Light System Program CPI
> - If anything is unclear or ambiguous, loop back to step 3 (AskUserQuestion)
> - Present the plan to the user for approval before proceeding
>
> ### 5. Implement
> - Add deps: Bash `cargo add light-sdk@0.23` (add `anchor_lang@0.31` for Anchor or `solana-program@2.2` + `borsh@0.10` for Native Rust)
> - Follow the guide and the approved plan
> - Write/Edit to create or modify files
> - TaskUpdate to mark each step done
>
> ### 6. Verify
> - Bash `cargo build-sbf` or `anchor build`
> - Bash `cargo test-sbf` or `anchor test` if tests exist
> - TaskUpdate to mark complete
>
> ### Tools
> - mcp__zkcompression__SearchLightProtocol("<query>") for API details
> - mcp__deepwiki__ask_question("Lightprotocol/light-protocol", "<q>") for architecture
> - Task subagent with Grep/Read/WebFetch for parallel lookups
> - TaskList to check remaining work
> ```

# Full Code Example

The example programs below implement all steps from this guide.

> [accordion] Setup
>
> **Install Solana CLI:**
>
> ```bash theme={null}
> sh -c "$(curl -sSfL https://release.solana.com/v2.2.15/install)"
> ```
>
> **Install Anchor CLI:**
>
> ```bash theme={null}
> cargo install --git https://github.com/coral-xyz/anchor avm --force
> avm install latest
> avm use latest
> ```
>
> **Install the Light CLI:**
>
> > [tab] npm
> >
> > ```bash theme={null}
> > npm install -g @lightprotocol/zk-compression-cli
> > ```
>
> > [tab] yarn
> >
> > ```bash theme={null}
> > yarn global add @lightprotocol/zk-compression-cli
> > ```
>
> > [tab] pnpm
> >
> > ```bash theme={null}
> > pnpm add -g @lightprotocol/zk-compression-cli
> > ```
>
> **Verify installation:**
>
> ```bash theme={null}
> light --version
> ```

> [!WARNING]
>
> For help with debugging, see the [Error Cheatsheet](https://www.zkcompression.com/resources/error-cheatsheet.md).

> [tab] Anchor
>
> > [!NOTE]
> >
> > Find the source code [here](https://github.com/Lightprotocol/program-examples/tree/main/basic-operations/anchor/burn).
>
> ````rust theme={null}
> #![allow(unexpected_cfgs)]
> #![allow(deprecated)]
>
> use anchor_lang::{prelude::*, AnchorDeserialize, AnchorSerialize};
> use light_sdk::{
>     account::LightAccount,
>     address::v2::derive_address,
>     cpi::{v2::CpiAccounts, CpiSigner},
>     derive_light_cpi_signer,
>     instruction::{account_meta::CompressedAccountMetaBurn, PackedAddressTreeInfo, ValidityProof},
>     LightDiscriminator, PackedAddressTreeInfoExt,
> };
> use light_sdk::constants::ADDRESS_TREE_V2;
>
> declare_id!("BJhPWQnD31mdo6739Mac1gLuSsbbwTmpgjHsW6shf6WA");
>
> pub const LIGHT_CPI_SIGNER: CpiSigner =
>     derive_light_cpi_signer!("BJhPWQnD31mdo6739Mac1gLuSsbbwTmpgjHsW6shf6WA");
>
> #[program]
> pub mod burn {
>
>     use super::*;
>     use light_sdk::cpi::{
>         v2::LightSystemProgramCpi, InvokeLightSystemProgram, LightCpiInstruction,
>     };
>
>     /// Setup: Creates a compressed account
>     pub fn create_account<'info>(
>         ctx: Context<'_, '_, '_, 'info, GenericAnchorAccounts<'info>>,
>         proof: ValidityProof,
>         address_tree_info: PackedAddressTreeInfo,
>         output_state_tree_index: u8,
>         message: String,
>     ) -> Result<()> {
>         let light_cpi_accounts = CpiAccounts::new(
>             ctx.accounts.signer.as_ref(),
>             ctx.remaining_accounts,
>             crate::LIGHT_CPI_SIGNER,
>         );
>
>         let address_tree_pubkey = address_tree_info
>             .get_tree_pubkey(&light_cpi_accounts)
>             .map_err(|_| ErrorCode::AccountNotEnoughKeys)?;
>
>         if address_tree_pubkey.to_bytes() != ADDRESS_TREE_V2 {
>             msg!("Invalid address tree");
>             return Err(ProgramError::InvalidAccountData.into());
>         }
>
>         let (address, address_seed) = derive_address(
>             &[b"message", ctx.accounts.signer.key().as_ref()],
>             &address_tree_pubkey,
>             &crate::ID,
>         );
>
>         let mut my_compressed_account = LightAccount::<MyCompressedAccount>::new_init(
>             &crate::ID,
>             Some(address),
>             output_state_tree_index,
>         );
>
>         my_compressed_account.owner = ctx.accounts.signer.key();
>         my_compressed_account.message = message.clone();
>
>         msg!(
>             "Created compressed account with message: {}",
>             my_compressed_account.message
>         );
>
>         LightSystemProgramCpi::new_cpi(LIGHT_CPI_SIGNER, proof)
>             .with_light_account(my_compressed_account)?
>             .with_new_addresses(&[address_tree_info.into_new_address_params_assigned_packed(address_seed, Some(0))])
>             .invoke(light_cpi_accounts)?;
>
>         Ok(())
>     }
>
>     /// Burns a compressed account permanently
>     pub fn burn_account<'info>(
>         ctx: Context<'_, '_, '_, 'info, GenericAnchorAccounts<'info>>,
>         proof: ValidityProof,
>         account_meta: CompressedAccountMetaBurn,
>         current_message: String,
>     ) -> Result<()> {
>         let light_cpi_accounts = CpiAccounts::new(
>             ctx.accounts.signer.as_ref(),
>             ctx.remaining_accounts,
>             crate::LIGHT_CPI_SIGNER,
>         );
>
>         let my_compressed_account = LightAccount::<MyCompressedAccount>::new_burn(
>             &crate::ID,
>             &account_meta,
>             MyCompressedAccount {
>                 owner: ctx.accounts.signer.key(),
>                 message: current_message,
>             },
>         )?;
>
>         msg!("Burning compressed account permanently");
>
>         LightSystemProgramCpi::new_cpi(LIGHT_CPI_SIGNER, proof)
>             .with_light_account(my_compressed_account)?
>             .invoke(light_cpi_accounts)?;
>
>         Ok(())
>     }
> }
>
> #[derive(Accounts)]
> pub struct GenericAnchorAccounts<'info> {
>     #[account(mut)]
>     pub signer: Signer<'info>,
> }
>
> #[event]
> #[derive(Clone, Debug, Default, LightDiscriminator)]
> pub struct MyCompressedAccount {
>     pub owner: Pubkey,
>     pub message: String,
> }```
> ````

> [tab] Native Rust
>
> > [!NOTE]
> >
> > Find the source code [here](https://github.com/Lightprotocol/program-examples/tree/main/basic-operations/native/programs/burn).
>
> ```rust theme={null}
> #![allow(unexpected_cfgs)]
>
> #[cfg(any(test, feature = "test-helpers"))]
> pub mod test_helpers;
>
> use borsh::{BorshDeserialize, BorshSerialize};
> use light_macros::pubkey;
> use light_sdk::{
>     account::sha::LightAccount,
>     address::v2::derive_address,
>     cpi::{
>         v2::{CpiAccounts, LightSystemProgramCpi},
>         CpiSigner, InvokeLightSystemProgram, LightCpiInstruction,
>     },
>     derive_light_cpi_signer,
>     error::LightSdkError,
>     instruction::{account_meta::CompressedAccountMetaBurn, PackedAddressTreeInfo, ValidityProof},
>     LightDiscriminator,
> };
> use light_sdk::constants::ADDRESS_TREE_V2;
> use light_sdk::PackedAddressTreeInfoExt;
> use solana_program::{
>     account_info::AccountInfo, entrypoint, program_error::ProgramError, pubkey::Pubkey,
> };
>
> pub const ID: Pubkey = pubkey!("CFWrQ8za2yT1xH8yBjYvsDUCWnBH7vXtyVJwqoX5FcNg");
> pub const LIGHT_CPI_SIGNER: CpiSigner = derive_light_cpi_signer!("CFWrQ8za2yT1xH8yBjYvsDUCWnBH7vXtyVJwqoX5FcNg");
>
> #[cfg(not(feature = "no-entrypoint"))]
> entrypoint!(process_instruction);
>
> #[derive(Debug, BorshSerialize, BorshDeserialize)]
> pub enum InstructionType {
>     Create,
>     Burn,
> }
>
> #[derive(Debug, BorshSerialize, BorshDeserialize)]
> pub struct CreateInstructionData {
>     pub proof: ValidityProof,
>     pub address_tree_info: PackedAddressTreeInfo,
>     pub output_state_tree_index: u8,
>     pub message: String,
> }
>
> #[derive(Debug, BorshSerialize, BorshDeserialize)]
> pub struct BurnInstructionData {
>     pub proof: ValidityProof,
>     pub account_meta: CompressedAccountMetaBurn,
>     pub current_account: MyCompressedAccount,
> }
>
> #[derive(Debug, Default, Clone, BorshSerialize, BorshDeserialize, LightDiscriminator)]
> pub struct MyCompressedAccount {
>     pub owner: Pubkey,
>     pub message: String,
> }
>
> pub fn process_instruction(
>     _program_id: &Pubkey,
>     accounts: &[AccountInfo],
>     instruction_data: &[u8],
> ) -> Result<(), ProgramError> {
>     let (instruction_type, rest) = instruction_data
>         .split_first()
>         .ok_or(ProgramError::InvalidInstructionData)?;
>
>     match InstructionType::try_from_slice(&[*instruction_type])
>         .map_err(|_| ProgramError::InvalidInstructionData)?
>     {
>         InstructionType::Create => create(accounts, rest)?,
>         InstructionType::Burn => burn(accounts, rest)?,
>     }
>
>     Ok(())
> }
>
> fn create(accounts: &[AccountInfo], instruction_data: &[u8]) -> Result<(), LightSdkError> {
>     let instruction_data =
>         CreateInstructionData::try_from_slice(instruction_data).map_err(|_| LightSdkError::Borsh)?;
>
>     let signer = accounts.first().ok_or(ProgramError::NotEnoughAccountKeys)?;
>
>     let light_cpi_accounts = CpiAccounts::new(signer, &accounts[1..], LIGHT_CPI_SIGNER);
>
>     let address_tree_pubkey = instruction_data
>         .address_tree_info
>         .get_tree_pubkey(&light_cpi_accounts)
>         .map_err(|_| ProgramError::NotEnoughAccountKeys)?;
>
>     if address_tree_pubkey.to_bytes() != ADDRESS_TREE_V2 {
>         solana_program::msg!("Invalid address tree");
>         return Err(LightSdkError::ProgramError(ProgramError::InvalidAccountData));
>     }
>
>     let (address, address_seed) = derive_address(
>         &[b"message", signer.key.as_ref()],
>         &address_tree_pubkey,
>         &ID,
>     );
>
>     let new_address_params = instruction_data
>         .address_tree_info
>         .into_new_address_params_assigned_packed(address_seed, Some(0));
>
>     let mut my_compressed_account = LightAccount::<MyCompressedAccount>::new_init(
>         &ID,
>         Some(address),
>         instruction_data.output_state_tree_index,
>     );
>     my_compressed_account.owner = *signer.key;
>     my_compressed_account.message = instruction_data.message;
>
>     LightSystemProgramCpi::new_cpi(LIGHT_CPI_SIGNER, instruction_data.proof)
>         .with_light_account(my_compressed_account)?
>         .with_new_addresses(&[new_address_params])
>         .invoke(light_cpi_accounts)?;
>
>     Ok(())
> }
>
> fn burn(accounts: &[AccountInfo], instruction_data: &[u8]) -> Result<(), LightSdkError> {
>     let instruction_data =
>         BurnInstructionData::try_from_slice(instruction_data).map_err(|_| LightSdkError::Borsh)?;
>
>     let (signer, remaining_accounts) = accounts
>         .split_first()
>         .ok_or(ProgramError::InvalidAccountData)?;
>
>     let cpi_accounts = CpiAccounts::new(signer, remaining_accounts, LIGHT_CPI_SIGNER);
>
>     let my_compressed_account = LightAccount::<MyCompressedAccount>::new_burn(
>         &ID,  // Now the burn program owns the account since it created it
>         &instruction_data.account_meta,
>         instruction_data.current_account,
>     )?;
>
>     LightSystemProgramCpi::new_cpi(LIGHT_CPI_SIGNER, instruction_data.proof)
>         .with_light_account(my_compressed_account)?
>         .invoke(cpi_accounts)?;
>
>     Ok(())
> }
> ```

# Next Steps

> [card] [Build a client for your program](https://www.zkcompression.com/compressed-pdas/guides/client-guide.md)

> [card] [Learn how to create compressed accounts](https://www.zkcompression.com/compressed-pdas/guides/how-to-create-compressed-accounts.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.