> ## 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.

# Solana to Light Reference

> Side-by-side mapping of every Light Token instruction against its SPL/Solana equivalent. Covers RPC, TypeScript client, Rust client, program CPI, and Anchor macros.

<Accordion title="Agent skill">
  Install or view [dedicated agent skills](/ai-tools/overview#agent-skills).

  ```
  npx skills add Lightprotocol/skills
  ```

  Install orchestrator agent skill or view [skill.md](https://www.zkcompression.com/skill.md):

  ```bash theme={null}
  npx skills add https://zkcompression.com
  ```
</Accordion>

### Create an RPC connection

Helius exposes Solana and Photon RPC endpoints through a single URL.
It's a thin wrapper extending Solana's `Connection` class that allows you to query cold Light Token balances.

<Tabs>
  <Tab title="TypeScript">
    <Columns cols={2}>
      ```typescript title="Light" theme={null}
      import { createRpc, Rpc } from '@lightprotocol/stateless.js';

      const RPC_ENDPOINT = 'https://mainnet.helius-rpc.com?api-key=YOUR_KEY';
      const connection: Rpc = createRpc(RPC_ENDPOINT, RPC_ENDPOINT);
      ```

      ```typescript title="SPL" theme={null}
      import { Connection } from "@solana/web3.js";

      const connection = new Connection(RPC_ENDPOINT);
      ```
    </Columns>
  </Tab>

  <Tab title="Rust">
    <Columns cols={2}>
      ```rust title="Light" theme={null}
      use light_client::rpc::{LightClient, LightClientConfig, Rpc};

      let rpc = LightClient::new(
          LightClientConfig::new(rpc_url.to_string(), None, None)
      ).await?;
      ```

      ```rust title="SPL" theme={null}
      use solana_client::rpc_client::RpcClient;

      let client = RpcClient::new(rpc_url.to_string());
      ```
    </Columns>
  </Tab>
</Tabs>

<Info>
  The Light Token SDK calls RPC methods internally via interface functions like `transferInterface` and `getAtaInterface`. Call them directly for custom indexing, block explorers, or debugging.
  See [JSON RPC Methods](/api-reference/json-rpc-methods/overview).
</Info>

<Accordion title="Get balance">
  Fetch the parsed state of a light token account, including hot and cold balances.

  > [Guide](/light-token/payments/overview) |
  > [Example](https://github.com/Lightprotocol/examples-light-token/blob/main/toolkits/payments/verify/get-balance.ts)

  <Columns cols={2}>
    ```typescript theme={null}
    import {
      getAssociatedTokenAddressInterface,
      getAtaInterface,
    } from "@lightprotocol/compressed-token/unified";

    const ata = getAssociatedTokenAddressInterface(mint, owner);
    const account = await getAtaInterface(rpc, ata, owner, mint);

    console.log(account.parsed.amount);
    ```

    ```typescript title="SPL" theme={null}
    import { getAccount } from "@solana/spl-token";

    const account = await getAccount(connection, ata);

    console.log(account.amount);
    ```
  </Columns>
</Accordion>

<Accordion title="Transaction history">
  Fetch merged and deduplicated transaction history across on-chain and compressed transactions.

  > [Guide](/light-token/payments/overview) |
  > [Example](https://github.com/Lightprotocol/examples-light-token/blob/main/toolkits/payments/verify/get-history.ts)

  <Columns cols={2}>
    ```typescript theme={null}
    const result = await rpc.getSignaturesForOwnerInterface(owner);

    console.log(result.signatures); // Merged + deduplicated
    console.log(result.solana);     // On-chain txs only
    console.log(result.compressed); // Compressed txs only
    ```

    ```typescript title="SPL" theme={null}
    const signatures = await connection.getSignaturesForAddress(ata);
    ```
  </Columns>
</Accordion>

***

## Client

Both `@lightprotocol/compressed-token` (TypeScript) and `light_token_client` (Rust) are a superset of the SPL Token API. Every SPL operation has a 1:1 equivalent. The SDKs add unified balance queries (`getAtaInterface`), automatic load/decompress for cold state, wrap/unwrap for SPL and Token 2022 interop, and cross-program dispatch via `Interface` methods like `transferInterface` that auto-detect the token program.

### Create mint

Create a mint account with optional token metadata.

> [Guide](/light-token/cookbook/create-mint) |
> [Example (TS)](https://github.com/Lightprotocol/examples-light-token/blob/main/typescript-client/actions/create-mint.ts) |
> [Example (Rust)](https://github.com/Lightprotocol/examples-light-token/blob/main/rust-client/actions/create_mint.rs)

<Tabs>
  <Tab title="TypeScript">
    <Columns cols={2}>
      <CodeGroup>
        ```typescript Light Action theme={null}
        import { createMintInterface } from "@lightprotocol/compressed-token";

        const { mint } = await createMintInterface(
          rpc,
          payer,
          mintAuthority,
          freezeAuthority,
          decimals,
          mintKeypair
        );
        ```

        ```typescript Light Instruction theme={null}
        import { createMintInstruction } from "@lightprotocol/compressed-token";

        const ix = createMintInstruction(
          mintSigner.publicKey,
          decimals,
          payer.publicKey,
          freezeAuthority,
          payer.publicKey,
          validityProof,
          addressTreeInfo,
          stateTreeInfo,
          tokenMetadata
        );
        ```
      </CodeGroup>

      <CodeGroup>
        ```typescript SPL Action theme={null}
        import { createMint } from "@solana/spl-token";

        const mint = await createMint(
          connection,
          payer,
          mintAuthority,
          freezeAuthority,
          decimals
        );
        ```

        ```typescript SPL Instruction theme={null}
        import { createInitializeMint2Instruction } from "@solana/spl-token";

        const ix = createInitializeMint2Instruction(
          mint.publicKey,
          decimals,
          mintAuthority,
          freezeAuthority,
          TOKEN_PROGRAM_ID
        );
        ```
      </CodeGroup>
    </Columns>
  </Tab>

  <Tab title="Rust">
    <Columns cols={2}>
      <CodeGroup>
        ```rust Light Instruction theme={null}
        use light_token::instruction::CreateMint;

        let ix = CreateMint::new(
            params,
            mint_seed.pubkey(),
            payer.pubkey(),
            address_tree.tree,
            output_queue,
        )
        .instruction()?;
        ```

        ```rust Light Action theme={null}
        use light_token_client::actions::CreateMint;

        let (sig, mint) = CreateMint {
            decimals: 9,
            freeze_authority: Some(payer.pubkey()),
            token_metadata: None,
            seed: None,
        }
        .execute(&mut rpc, &payer, &mint_authority)
        .await?;
        ```
      </CodeGroup>

      ```rust title="SPL" theme={null}
      use spl_token::instruction::initialize_mint;

      let ix = initialize_mint(
          &spl_token::id(),
          &mint.pubkey(),
          &mint_authority,
          Some(&freeze_authority),
          decimals,
      )?;
      ```
    </Columns>
  </Tab>
</Tabs>

<Accordion title="AI prompt">
  <Tabs>
    <Tab title="TypeScript">
      <Prompt description="Add rent-free mint with token metadata" actions={["copy", "cursor"]}>
        {`---
                description: Add rent-free mint with token metadata
                allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
                ---

                ## Add rent-free mint with token metadata

                Context:
                - Guide: https://zkcompression.com/light-token/cookbook/create-mint
                - Skills and resources index: https://zkcompression.com/skill.md
                - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
                - Packages: @lightprotocol/compressed-token, @lightprotocol/stateless.js

                SPL equivalent: createMint() → Light Token: createMintInterface()

                ### 1. Index project
                - Grep \`@solana/spl-token|Connection|Keypair|createMint\` across src/
                - Glob \`**/*.ts\` for project structure
                - Identify: RPC setup, existing mint logic, entry point for mint creation
                - Task subagent (Grep/Read/WebFetch) if project has multiple packages to scan in parallel

                ### 2. Read references
                - WebFetch the guide above — follow the TypeScript Client tab
                - 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 feature, migrate existing SPL code, add alongside existing)
                - AskUserQuestion: does the project already have mint operations to extend, or is this greenfield?
                - 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
                - Verify existing connection/signer setup is compatible with the cookbook prerequisites
                - 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 if missing: Bash \`npm install @lightprotocol/compressed-token @lightprotocol/stateless.js\`
                - Follow the cookbook guide and the approved plan
                - Write/Edit to create or modify files
                - TaskUpdate to mark each step done

                ### 6. Verify
                - Bash \`tsc --noEmit\`
                - Bash run existing test suite if present
                - 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`}
      </Prompt>

      ```text theme={null}
      ---
      description: Add rent-free mint with token metadata
      allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
      ---

      ## Add rent-free mint with token metadata

      Context:
      - Guide: https://zkcompression.com/light-token/cookbook/create-mint
      - Skills and resources index: https://zkcompression.com/skill.md
      - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
      - Packages: @lightprotocol/compressed-token, @lightprotocol/stateless.js

      SPL equivalent: createMint() → Light Token: createMintInterface()

      ### 1. Index project
      - Grep `@solana/spl-token|Connection|Keypair|createMint` across src/
      - Glob `**/*.ts` for project structure
      - Identify: RPC setup, existing mint logic, entry point for mint creation
      - Task subagent (Grep/Read/WebFetch) if project has multiple packages to scan in parallel

      ### 2. Read references
      - WebFetch the guide above — follow the TypeScript Client tab
      - 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 feature, migrate existing SPL code, add alongside existing)
      - AskUserQuestion: does the project already have mint operations to extend, or is this greenfield?
      - 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
      - Verify existing connection/signer setup is compatible with the cookbook prerequisites
      - 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 if missing: Bash `npm install @lightprotocol/compressed-token @lightprotocol/stateless.js`
      - Follow the cookbook guide and the approved plan
      - Write/Edit to create or modify files
      - TaskUpdate to mark each step done

      ### 6. Verify
      - Bash `tsc --noEmit`
      - Bash run existing test suite if present
      - 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
      ```
    </Tab>

    <Tab title="Rust">
      <Prompt description="Create rent-free mint with token metadata" actions={["copy", "cursor"]}>
        {`---
                description: Create rent-free mint with token metadata
                allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
                ---

                ## Create rent-free mint with token metadata

                Context:
                - Guide: https://zkcompression.com/light-token/cookbook/create-mint
                - Skills and resources index: https://zkcompression.com/skill.md
                - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
                - Crates: light-token-client (actions), light-token (instructions), light-client (RPC)

                SPL equivalent: spl_token::instruction::initialize_mint → Light Token: CreateMint

                ### 1. Index project
                - Grep \`light_token::|light_token_client::|solana_sdk|Keypair|async|CreateMint|initialize_mint\` across src/
                - Glob \`**/*.rs\` for project structure
                - Identify: RPC setup, existing token ops, entry point for mint creation
                - Check Cargo.toml for existing light-* 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 — follow the Rust Client tab
                - 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 feature, migrate existing SPL code, add alongside existing)
                - AskUserQuestion: does the project already have mint operations to extend, or is this greenfield?
                - AskUserQuestion: action-level API (high-level, fewer lines) or instruction-level API (low-level, full control)?
                - 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
                - Verify existing Rpc/signer setup is compatible with the cookbook prerequisites (light_client::rpc::Rpc, solana_sdk::signature::Keypair)
                - 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 if missing: Bash \`cargo add light-token-client light-token light-client --features light-client/v2\`
                - Follow the cookbook guide and the approved plan
                - Write/Edit to create or modify files
                - TaskUpdate to mark each step done

                ### 6. Verify
                - Bash \`cargo check\`
                - Bash \`cargo 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`}
      </Prompt>

      ```text theme={null}
      ---
      description: Create rent-free mint with token metadata
      allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
      ---

      ## Create rent-free mint with token metadata

      Context:
      - Guide: https://zkcompression.com/light-token/cookbook/create-mint
      - Skills and resources index: https://zkcompression.com/skill.md
      - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
      - Crates: light-token-client (actions), light-token (instructions), light-client (RPC)

      SPL equivalent: spl_token::instruction::initialize_mint → Light Token: CreateMint

      ### 1. Index project
      - Grep `light_token::|light_token_client::|solana_sdk|Keypair|async|CreateMint|initialize_mint` across src/
      - Glob `**/*.rs` for project structure
      - Identify: RPC setup, existing token ops, entry point for mint creation
      - Check Cargo.toml for existing light-* 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 — follow the Rust Client tab
      - 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 feature, migrate existing SPL code, add alongside existing)
      - AskUserQuestion: does the project already have mint operations to extend, or is this greenfield?
      - AskUserQuestion: action-level API (high-level, fewer lines) or instruction-level API (low-level, full control)?
      - 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
      - Verify existing Rpc/signer setup is compatible with the cookbook prerequisites (light_client::rpc::Rpc, solana_sdk::signature::Keypair)
      - 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 if missing: Bash `cargo add light-token-client light-token light-client --features light-client/v2`
      - Follow the cookbook guide and the approved plan
      - Write/Edit to create or modify files
      - TaskUpdate to mark each step done

      ### 6. Verify
      - Bash `cargo check`
      - Bash `cargo 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
      ```
    </Tab>
  </Tabs>
</Accordion>

### Create associated token account

Associated light token accounts can hold balances of light, SPL, or Token 2022 mints.

> [Guide](/light-token/cookbook/create-ata) |
> [Example (TS)](https://github.com/Lightprotocol/examples-light-token/blob/main/typescript-client/actions/create-ata.ts) |
> [Example (Rust)](https://github.com/Lightprotocol/examples-light-token/blob/main/rust-client/actions/create_associated_token_account.rs)

<Tabs>
  <Tab title="TypeScript">
    <Columns cols={2}>
      <CodeGroup>
        ```typescript Light Action theme={null}
        import { getOrCreateAtaInterface } from "@lightprotocol/compressed-token/unified";

        const ata = await getOrCreateAtaInterface(
          rpc,
          payer,
          mint,
          owner
        );
        ```

        ```typescript Light Instruction theme={null}
        import { createAssociatedTokenAccountInterfaceInstruction } from "@lightprotocol/compressed-token";

        const ix = createAssociatedTokenAccountInterfaceInstruction(
          payer.publicKey,
          ata,
          owner.publicKey,
          mint
        );
        ```
      </CodeGroup>

      <CodeGroup>
        ```typescript SPL Action theme={null}
        import { getOrCreateAssociatedTokenAccount } from "@solana/spl-token";

        const ata = await getOrCreateAssociatedTokenAccount(
          connection,
          payer,
          mint,
          owner
        );
        ```

        ```typescript SPL Instruction theme={null}
        import { createAssociatedTokenAccountInstruction } from "@solana/spl-token";

        const ix = createAssociatedTokenAccountInstruction(
          payer.publicKey,
          ata,
          owner.publicKey,
          mint
        );
        ```
      </CodeGroup>
    </Columns>
  </Tab>

  <Tab title="Rust">
    <Columns cols={2}>
      <CodeGroup>
        ```rust Light Instruction theme={null}
        use light_token::instruction::CreateAssociatedTokenAccount;

        let ix = CreateAssociatedTokenAccount::new(
            payer.pubkey(),
            owner.pubkey(),
            mint,
        )
        .instruction()?;
        ```

        ```rust Light Action theme={null}
        use light_token_client::actions::CreateAta;

        let (sig, ata) = CreateAta {
            mint,
            owner: owner.pubkey(),
            idempotent: false,
        }
        .execute(&mut rpc, &payer)
        .await?;
        ```
      </CodeGroup>

      ```rust title="SPL" theme={null}
      use spl_associated_token_account::instruction::create_associated_token_account;

      let ix = create_associated_token_account(
          &payer.pubkey(),
          &owner.pubkey(),
          &mint,
          &spl_token::id(),
      );
      ```
    </Columns>
  </Tab>
</Tabs>

<Accordion title="AI prompt">
  <Tabs>
    <Tab title="TypeScript">
      <Prompt description="Create rent-free associated token account" actions={["copy", "cursor"]}>
        {`---
                description: Create rent-free associated token account
                allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
                ---

                ## Create rent-free associated token account

                Context:
                - Guide: https://zkcompression.com/light-token/cookbook/create-ata
                - Skills and resources index: https://zkcompression.com/skill.md
                - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
                - Packages: @lightprotocol/compressed-token, @lightprotocol/stateless.js

                SPL equivalent: createAssociatedTokenAccount() → Light Token: createAtaInterface()

                ### 1. Index project
                - Grep \`@solana/spl-token|Connection|Keypair|createAssociatedTokenAccount|createAtaInterface\` across src/
                - Glob \`**/*.ts\` for project structure
                - Identify: RPC setup, existing ATA logic, entry point for ATA creation
                - Task subagent (Grep/Read/WebFetch) if project has multiple packages to scan in parallel

                ### 2. Read references
                - WebFetch the guide above — follow the TypeScript Client tab
                - 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 feature, migrate existing SPL code, add alongside existing)
                - AskUserQuestion: does the project already have ATA operations to extend, or is this greenfield?
                - 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
                - Verify existing connection/signer setup is compatible with the cookbook prerequisites
                - 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 if missing: Bash \`npm install @lightprotocol/compressed-token @lightprotocol/stateless.js\`
                - Follow the cookbook guide and the approved plan
                - Write/Edit to create or modify files
                - TaskUpdate to mark each step done

                ### 6. Verify
                - Bash \`tsc --noEmit\`
                - Bash run existing test suite if present
                - 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`}
      </Prompt>

      ```text theme={null}
      ---
      description: Create rent-free associated token account
      allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
      ---

      ## Create rent-free associated token account

      Context:
      - Guide: https://zkcompression.com/light-token/cookbook/create-ata
      - Skills and resources index: https://zkcompression.com/skill.md
      - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
      - Packages: @lightprotocol/compressed-token, @lightprotocol/stateless.js

      SPL equivalent: createAssociatedTokenAccount() → Light Token: createAtaInterface()

      ### 1. Index project
      - Grep `@solana/spl-token|Connection|Keypair|createAssociatedTokenAccount|createAtaInterface` across src/
      - Glob `**/*.ts` for project structure
      - Identify: RPC setup, existing ATA logic, entry point for ATA creation
      - Task subagent (Grep/Read/WebFetch) if project has multiple packages to scan in parallel

      ### 2. Read references
      - WebFetch the guide above — follow the TypeScript Client tab
      - 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 feature, migrate existing SPL code, add alongside existing)
      - AskUserQuestion: does the project already have ATA operations to extend, or is this greenfield?
      - 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
      - Verify existing connection/signer setup is compatible with the cookbook prerequisites
      - 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 if missing: Bash `npm install @lightprotocol/compressed-token @lightprotocol/stateless.js`
      - Follow the cookbook guide and the approved plan
      - Write/Edit to create or modify files
      - TaskUpdate to mark each step done

      ### 6. Verify
      - Bash `tsc --noEmit`
      - Bash run existing test suite if present
      - 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
      ```
    </Tab>

    <Tab title="Rust">
      <Prompt description="Create rent-free associated token account" actions={["copy", "cursor"]}>
        {`---
                description: Create rent-free associated token account
                allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
                ---

                ## Create rent-free associated token account

                Context:
                - Guide: https://zkcompression.com/light-token/cookbook/create-ata
                - Skills and resources index: https://zkcompression.com/skill.md
                - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
                - Crates: light-token-client (actions), light-token (instructions), light-client (RPC)

                SPL equivalent: spl_associated_token_account::create → Light Token: CreateAta

                ### 1. Index project
                - Grep \`light_token::|light_token_client::|solana_sdk|Keypair|async|CreateAta|create_associated_token_account\` across src/
                - Glob \`**/*.rs\` for project structure
                - Identify: RPC setup, existing token ops, entry point for ATA creation
                - Check Cargo.toml for existing light-* 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 — follow the Rust Client tab
                - 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 feature, migrate existing SPL code, add alongside existing)
                - AskUserQuestion: does the project already have ATA operations to extend, or is this greenfield?
                - AskUserQuestion: action-level API (high-level, fewer lines) or instruction-level API (low-level, full control)?
                - 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
                - Verify existing Rpc/signer setup is compatible with the cookbook prerequisites (light_client::rpc::Rpc, solana_sdk::signature::Keypair)
                - 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 if missing: Bash \`cargo add light-token-client light-token light-client --features light-client/v2\`
                - Follow the cookbook guide and the approved plan
                - Write/Edit to create or modify files
                - TaskUpdate to mark each step done

                ### 6. Verify
                - Bash \`cargo check\`
                - Bash \`cargo 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`}
      </Prompt>

      ```text theme={null}
      ---
      description: Create rent-free associated token account
      allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
      ---

      ## Create rent-free associated token account

      Context:
      - Guide: https://zkcompression.com/light-token/cookbook/create-ata
      - Skills and resources index: https://zkcompression.com/skill.md
      - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
      - Crates: light-token-client (actions), light-token (instructions), light-client (RPC)

      SPL equivalent: spl_associated_token_account::create → Light Token: CreateAta

      ### 1. Index project
      - Grep `light_token::|light_token_client::|solana_sdk|Keypair|async|CreateAta|create_associated_token_account` across src/
      - Glob `**/*.rs` for project structure
      - Identify: RPC setup, existing token ops, entry point for ATA creation
      - Check Cargo.toml for existing light-* 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 — follow the Rust Client tab
      - 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 feature, migrate existing SPL code, add alongside existing)
      - AskUserQuestion: does the project already have ATA operations to extend, or is this greenfield?
      - AskUserQuestion: action-level API (high-level, fewer lines) or instruction-level API (low-level, full control)?
      - 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
      - Verify existing Rpc/signer setup is compatible with the cookbook prerequisites (light_client::rpc::Rpc, solana_sdk::signature::Keypair)
      - 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 if missing: Bash `cargo add light-token-client light-token light-client --features light-client/v2`
      - Follow the cookbook guide and the approved plan
      - Write/Edit to create or modify files
      - TaskUpdate to mark each step done

      ### 6. Verify
      - Bash `cargo check`
      - Bash `cargo 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
      ```
    </Tab>
  </Tabs>
</Accordion>

### Mint tokens

Mint Light, SPL and Token 2022 tokens to a destination account. The SDK auto-detects the token program based on the mint address you pass.
When no programId is passed, all three token programs are queried in parallel and returns the first successful result. The priority
order is SPL Token → Token 2022 → Light Token.

> [Guide](/light-token/cookbook/mint-to) |
> [Example (TS)](https://github.com/Lightprotocol/examples-light-token/blob/main/typescript-client/actions/mint-to.ts) |
> [Example (Rust)](https://github.com/Lightprotocol/examples-light-token/blob/main/rust-client/actions/mint_to.rs)

<Tabs>
  <Tab title="TypeScript">
    <Columns cols={2}>
      <CodeGroup>
        ```typescript Light Action theme={null}
        import { mintToInterface } from "@lightprotocol/compressed-token";

        const tx = await mintToInterface(
          rpc,
          payer,
          mint,
          destination,
          mintAuthority,
          amount
        );
        ```

        ```typescript Light Instruction theme={null}
        import { createMintToInterfaceInstruction } from "@lightprotocol/compressed-token";

        const ix = createMintToInterfaceInstruction(
          mintInterface,
          destination,
          authority.publicKey,
          payer.publicKey,
          amount
        );
        ```
      </CodeGroup>

      <CodeGroup>
        ```typescript SPL Action theme={null}
        import { mintTo } from "@solana/spl-token";

        const tx = await mintTo(
          connection,
          payer,
          mint,
          destination,
          mintAuthority,
          amount
        );
        ```

        ```typescript SPL Instruction theme={null}
        import { createMintToInstruction } from "@solana/spl-token";

        const ix = createMintToInstruction(
          mint,
          destination,
          mintAuthority.publicKey,
          amount
        );
        ```
      </CodeGroup>
    </Columns>
  </Tab>

  <Tab title="Rust">
    <Columns cols={2}>
      <CodeGroup>
        ```rust Light Instruction theme={null}
        use light_token::instruction::MintTo;

        let ix = MintTo {
            mint,
            destination,
            amount,
            authority: payer.pubkey(),
            fee_payer: payer.pubkey(),
        }
        .instruction()?;
        ```

        ```rust Light Action theme={null}
        use light_token_client::actions::MintTo;

        let sig = MintTo {
            mint,
            destination,
            amount,
        }
        .execute(&mut rpc, &payer, &authority)
        .await?;
        ```
      </CodeGroup>

      ```rust title="SPL" theme={null}
      use spl_token::instruction::mint_to;

      let ix = mint_to(
          &spl_token::id(),
          &mint,
          &destination,
          &mint_authority,
          &[],
          amount,
      )?;
      ```
    </Columns>
  </Tab>
</Tabs>

<Accordion title="AI prompt">
  <Tabs>
    <Tab title="TypeScript">
      <Prompt description="Mint tokens to Light Token account" actions={["copy", "cursor"]}>
        {`---
                description: Mint tokens to Light Token account
                allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
                ---

                ## Mint tokens to Light Token account

                Context:
                - Guide: https://zkcompression.com/light-token/cookbook/mint-to
                - Skills and resources index: https://zkcompression.com/skill.md
                - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
                - Packages: @lightprotocol/compressed-token, @lightprotocol/stateless.js

                SPL equivalent: mintTo() → Light Token: mintToInterface()

                ### 1. Index project
                - Grep \`@solana/spl-token|Connection|Keypair|mintTo|mintToInterface\` across src/
                - Glob \`**/*.ts\` for project structure
                - Identify: RPC setup, existing mint logic, entry point for minting
                - Task subagent (Grep/Read/WebFetch) if project has multiple packages to scan in parallel

                ### 2. Read references
                - WebFetch the guide above — follow the TypeScript Client tab
                - 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 feature, migrate existing SPL code, add alongside existing)
                - AskUserQuestion: does the project already have mint operations to extend, or is this greenfield?
                - 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
                - Verify existing connection/signer setup is compatible with the cookbook prerequisites
                - 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 if missing: Bash \`npm install @lightprotocol/compressed-token @lightprotocol/stateless.js\`
                - Follow the cookbook guide and the approved plan
                - Write/Edit to create or modify files
                - TaskUpdate to mark each step done

                ### 6. Verify
                - Bash \`tsc --noEmit\`
                - Bash run existing test suite if present
                - 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`}
      </Prompt>

      ```text theme={null}
      ---
      description: Mint tokens to Light Token account
      allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
      ---

      ## Mint tokens to Light Token account

      Context:
      - Guide: https://zkcompression.com/light-token/cookbook/mint-to
      - Skills and resources index: https://zkcompression.com/skill.md
      - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
      - Packages: @lightprotocol/compressed-token, @lightprotocol/stateless.js

      SPL equivalent: mintTo() → Light Token: mintToInterface()

      ### 1. Index project
      - Grep `@solana/spl-token|Connection|Keypair|mintTo|mintToInterface` across src/
      - Glob `**/*.ts` for project structure
      - Identify: RPC setup, existing mint logic, entry point for minting
      - Task subagent (Grep/Read/WebFetch) if project has multiple packages to scan in parallel

      ### 2. Read references
      - WebFetch the guide above — follow the TypeScript Client tab
      - 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 feature, migrate existing SPL code, add alongside existing)
      - AskUserQuestion: does the project already have mint operations to extend, or is this greenfield?
      - 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
      - Verify existing connection/signer setup is compatible with the cookbook prerequisites
      - 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 if missing: Bash `npm install @lightprotocol/compressed-token @lightprotocol/stateless.js`
      - Follow the cookbook guide and the approved plan
      - Write/Edit to create or modify files
      - TaskUpdate to mark each step done

      ### 6. Verify
      - Bash `tsc --noEmit`
      - Bash run existing test suite if present
      - 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
      ```
    </Tab>

    <Tab title="Rust">
      <Prompt description="Mint tokens to Light Token account" actions={["copy", "cursor"]}>
        {`---
                description: Mint tokens to Light Token account
                allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
                ---

                ## Mint tokens to Light Token account

                Context:
                - Guide: https://zkcompression.com/light-token/cookbook/mint-to
                - Skills and resources index: https://zkcompression.com/skill.md
                - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
                - Crates: light-token-client (actions), light-token (instructions), light-client (RPC)

                SPL equivalent: spl_token::instruction::mint_to → Light Token: MintTo

                ### 1. Index project
                - Grep \`light_token::|light_token_client::|solana_sdk|Keypair|async|MintTo|mint_to\` across src/
                - Glob \`**/*.rs\` for project structure
                - Identify: RPC setup, existing token ops, entry point for minting
                - Check Cargo.toml for existing light-* 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 — follow the Rust Client tab
                - 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 feature, migrate existing SPL code, add alongside existing)
                - AskUserQuestion: does the project already have mint operations to extend, or is this greenfield?
                - AskUserQuestion: action-level API (high-level, fewer lines) or instruction-level API (low-level, full control)?
                - 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
                - Verify existing Rpc/signer setup is compatible with the cookbook prerequisites (light_client::rpc::Rpc, solana_sdk::signature::Keypair)
                - 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 if missing: Bash \`cargo add light-token-client light-token light-client --features light-client/v2\`
                - Follow the cookbook guide and the approved plan
                - Write/Edit to create or modify files
                - TaskUpdate to mark each step done

                ### 6. Verify
                - Bash \`cargo check\`
                - Bash \`cargo 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`}
      </Prompt>

      ```text theme={null}
      ---
      description: Mint tokens to Light Token account
      allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
      ---

      ## Mint tokens to Light Token account

      Context:
      - Guide: https://zkcompression.com/light-token/cookbook/mint-to
      - Skills and resources index: https://zkcompression.com/skill.md
      - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
      - Crates: light-token-client (actions), light-token (instructions), light-client (RPC)

      SPL equivalent: spl_token::instruction::mint_to → Light Token: MintTo

      ### 1. Index project
      - Grep `light_token::|light_token_client::|solana_sdk|Keypair|async|MintTo|mint_to` across src/
      - Glob `**/*.rs` for project structure
      - Identify: RPC setup, existing token ops, entry point for minting
      - Check Cargo.toml for existing light-* 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 — follow the Rust Client tab
      - 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 feature, migrate existing SPL code, add alongside existing)
      - AskUserQuestion: does the project already have mint operations to extend, or is this greenfield?
      - AskUserQuestion: action-level API (high-level, fewer lines) or instruction-level API (low-level, full control)?
      - 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
      - Verify existing Rpc/signer setup is compatible with the cookbook prerequisites (light_client::rpc::Rpc, solana_sdk::signature::Keypair)
      - 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 if missing: Bash `cargo add light-token-client light-token light-client --features light-client/v2`
      - Follow the cookbook guide and the approved plan
      - Write/Edit to create or modify files
      - TaskUpdate to mark each step done

      ### 6. Verify
      - Bash `cargo check`
      - Bash `cargo 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
      ```
    </Tab>
  </Tabs>
</Accordion>

### Transfer tokens with Transferinterface

The interface detects account types and invokes the right programs.

<table>
  <tbody>
    <tr>
      <td style={{ width: "33%" }}>**Light Token -> Light Token Account**</td>

      <td>
        <ul>
          <li>Transfers tokens between Light Token accounts</li>
        </ul>
      </td>
    </tr>

    <tr>
      <td>**SPL token -> Light Token Account**</td>

      <td>
        <ul>
          <li>Transfers SPL tokens to Light Token accounts</li>
          <li>SPL tokens are locked in interface PDA</li>
          <li>Tokens are minted to Light Token account</li>
        </ul>
      </td>
    </tr>

    <tr>
      <td>**Light Token -> SPL Account**</td>

      <td>
        <ul>
          <li>Releases SPL tokens from interface PDA to SPL account</li>
          <li>Burns tokens in source Light Token account</li>
        </ul>
      </td>
    </tr>
  </tbody>
</table>

> [Guide](/light-token/cookbook/transfer-interface) |
> [Example (TS)](https://github.com/Lightprotocol/examples-light-token/blob/main/typescript-client/actions/transfer-interface.ts) |
> [Example (Rust)](https://github.com/Lightprotocol/examples-light-token/blob/main/rust-client/actions/transfer_interface.rs)

<Tabs>
  <Tab title="TypeScript">
    <Columns cols={2}>
      <CodeGroup>
        ```typescript Light Action theme={null}
        import { transferInterface } from "@lightprotocol/compressed-token/unified";

        const tx = await transferInterface(
          rpc,
          payer,
          sourceAta,
          mint,
          recipient,
          owner.publicKey,
          owner,
          amount
        );
        ```

        ```typescript Light Instruction theme={null}
        import { createLightTokenTransferInstruction } from "@lightprotocol/compressed-token";

        const ix = createLightTokenTransferInstruction(
          source,
          destination,
          owner.publicKey,
          amount
        );
        ```
      </CodeGroup>

      <CodeGroup>
        ```typescript SPL Action theme={null}
        import { transfer } from "@solana/spl-token";

        const tx = await transfer(
          connection,
          payer,
          sourceAta,
          destinationAta,
          owner,
          amount
        );
        ```

        ```typescript SPL Instruction theme={null}
        import { createTransferInstruction } from "@solana/spl-token";

        const ix = createTransferInstruction(
          sourceAta,
          destinationAta,
          owner.publicKey,
          amount
        );
        ```
      </CodeGroup>
    </Columns>
  </Tab>

  <Tab title="Rust">
    <Columns cols={2}>
      <CodeGroup>
        ```rust Light Instruction theme={null}
        use light_token::instruction::TransferInterface;

        let ix = TransferInterface {
            source,
            destination,
            amount,
            decimals,
            authority: payer.pubkey(),
            payer: payer.pubkey(),
            mint,
            spl_interface: None,
            source_owner: LIGHT_TOKEN_PROGRAM_ID,
            destination_owner: LIGHT_TOKEN_PROGRAM_ID,
        }
        .instruction()?;
        ```

        ```rust Light Action theme={null}
        use light_token_client::actions::TransferInterface;

        let sig = TransferInterface {
            source,
            mint,
            destination,
            amount,
            decimals,
            spl_token_program: None,
            restricted: false,
        }
        .execute(&mut rpc, &payer, &authority)
        .await?;
        ```
      </CodeGroup>

      ```rust title="SPL" theme={null}
      use spl_token::instruction::transfer;

      let ix = transfer(
          &spl_token::id(),
          &source,
          &destination,
          &authority,
          &[],
          amount,
      )?;
      ```
    </Columns>
  </Tab>
</Tabs>

For payment flows, `createTransferInterfaceInstructions` returns
`TransactionInstruction[][]` — handles loading cold state and
transferring in one call:

> [Guide](/light-token/payments/overview) |
> [Example (instruction)](https://github.com/Lightprotocol/examples-light-token/blob/main/toolkits/payments/send/basic-send-instruction.ts) |
> [Example (action)](https://github.com/Lightprotocol/examples-light-token/blob/main/toolkits/payments/send/basic-send-action.ts)

```typescript theme={null}
import { Transaction } from "@solana/web3.js";
import { createTransferInterfaceInstructions } from "@lightprotocol/compressed-token/unified";

// Returns TransactionInstruction[][].
// Each inner array is one transaction.
// Almost always returns just one.
const instructions = await createTransferInterfaceInstructions(
  rpc,
  payer.publicKey,
  mint,
  amount,
  owner.publicKey,
  recipient
);

for (const ixs of instructions) {
  const tx = new Transaction().add(...ixs);

  // sign and send ...
}
```

Your app logic may require you to create a single sign request for your user:

<Accordion title="Sign all transactions together">
  ```typescript theme={null}
  const transactions = instructions.map((ixs) => new Transaction().add(...ixs));

  // One approval for all
  const signed = await wallet.signAllTransactions(transactions);

  for (const tx of signed) {
    // send...
    await sendAndConfirmTransaction(rpc, tx);
  }
  ```
</Accordion>

While almost always you will have only one transfer transaction, you can
optimize sending in the rare cases where you have multiple transactions.
Parallelize the loads, confirm them, and then send the transfer instruction
after.

<Accordion title="Optimize sending (parallel conditional loads, then transfer)">
  ```typescript theme={null}
  import {
    createTransferInterfaceInstructions,
    sliceLast,
  } from "@lightprotocol/compressed-token/unified";

  const instructions = await createTransferInterfaceInstructions(
    rpc,
    payer.publicKey,
    mint,
    amount,
    owner.publicKey,
    recipient
  );
  const { rest: loadInstructions, last: transferInstructions } = sliceLast(instructions);
  // empty = nothing to load, will no-op.
  await Promise.all(
    loadInstructions.map((ixs) => {
      const tx = new Transaction().add(...ixs);
      tx.sign(payer, owner);
      return sendAndConfirmTransaction(rpc, tx);
    })
  );

  const transferTx = new Transaction().add(...transferInstructions);
  transferTx.sign(payer, owner);
  await sendAndConfirmTransaction(rpc, transferTx);
  ```
</Accordion>

<Accordion title="Load ATA">
  Load creates the ATA if needed and loads any compressed state into it. Light Token accounts auto-compress inactive accounts. Before any action, the SDK detects cold balances and adds instructions to load them.

  > [Guide](/light-token/cookbook/load-ata) |
  > [Example](https://github.com/Lightprotocol/examples-light-token/blob/main/typescript-client/actions/load-ata.ts) |
  > [Source](https://github.com/Lightprotocol/light-protocol/blob/main/js/compressed-token/src/v3/actions/load-ata.ts)

  ```typescript theme={null}
  import {
    loadAta,
    getAssociatedTokenAddressInterface,
  } from "@lightprotocol/compressed-token/unified";

  const ata = getAssociatedTokenAddressInterface(mint, recipient);

  const sig = await loadAta(rpc, ata, recipient, mint, payer);
  ```
</Accordion>

<Accordion title="AI prompt">
  <Tabs>
    <Tab title="TypeScript">
      <Prompt description="Transfer tokens between Light Token and SPL accounts" actions={["copy", "cursor"]}>
        {`---
                description: Transfer tokens between Light Token and SPL accounts
                allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
                ---

                ## Transfer tokens between Light Token and SPL accounts

                Context:
                - Guide: https://zkcompression.com/light-token/cookbook/transfer-interface
                - Skills and resources index: https://zkcompression.com/skill.md
                - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
                - Packages: @lightprotocol/compressed-token, @lightprotocol/stateless.js

                transferInterface() transfers tokens in a single call. The recipient parameter is a wallet public key.
                Pass the source token-account owner pubkey and the signing authority separately: owner-signed flows use (owner.publicKey, owner); delegated flows use (owner.publicKey, delegate). Do not use removed InterfaceOptions.owner.
                The SDK derives and creates the destination ATA internally. All transfers use transferChecked under the hood.
                - Light Token → Light Token: transfers between Light Token accounts
                - SPL → Light Token: locks SPL tokens in interface PDA, mints to Light Token account
                - Light Token → SPL: burns Light Token balance, releases SPL tokens from interface PDA

                Edge case: for explicit destination token accounts (PDA/program-owned), use transferToAccountInterface()
                or createTransferToAccountInterfaceInstructions(). Most integrations should use transferInterface().

                ### 1. Index project
                - Grep \`@solana/spl-token|Connection|Keypair|transfer|transferInterface\` across src/
                - Glob \`**/*.ts\` for project structure
                - Identify: RPC setup, existing transfer logic, entry point for transfers
                - Task subagent (Grep/Read/WebFetch) if project has multiple packages to scan in parallel

                ### 2. Read references
                - WebFetch the guide above — follow the TypeScript Client tab
                - 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 feature, migrate existing SPL code, add alongside existing)
                - AskUserQuestion: does the project already have transfer operations to extend, or is this greenfield?
                - 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
                - Verify existing connection/signer setup is compatible with the cookbook prerequisites
                - 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 if missing: Bash \`npm install @lightprotocol/compressed-token @lightprotocol/stateless.js\`
                - Follow the cookbook guide and the approved plan
                - Write/Edit to create or modify files
                - TaskUpdate to mark each step done

                ### 6. Verify
                - Bash \`tsc --noEmit\`
                - Bash run existing test suite if present
                - 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`}
      </Prompt>

      ```text theme={null}
      ---
      description: Transfer tokens between Light Token and SPL accounts
      allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
      ---

      ## Transfer tokens between Light Token and SPL accounts

      Context:
      - Guide: https://zkcompression.com/light-token/cookbook/transfer-interface
      - Skills and resources index: https://zkcompression.com/skill.md
      - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
      - Packages: @lightprotocol/compressed-token, @lightprotocol/stateless.js

      transferInterface() transfers tokens in a single call. The recipient parameter is a wallet public key.
      Pass the source token-account owner pubkey and the signing authority separately: owner-signed flows use (owner.publicKey, owner); delegated flows use (owner.publicKey, delegate). Do not use removed InterfaceOptions.owner.
      The SDK derives and creates the destination ATA internally. All transfers use transferChecked under the hood.
      - Light Token → Light Token: transfers between Light Token accounts
      - SPL → Light Token: locks SPL tokens in interface PDA, mints to Light Token account
      - Light Token → SPL: burns Light Token balance, releases SPL tokens from interface PDA

      Edge case: for explicit destination token accounts (PDA/program-owned), use transferToAccountInterface()
      or createTransferToAccountInterfaceInstructions(). Most integrations should use transferInterface().

      ### 1. Index project
      - Grep `@solana/spl-token|Connection|Keypair|transfer|transferInterface` across src/
      - Glob `**/*.ts` for project structure
      - Identify: RPC setup, existing transfer logic, entry point for transfers
      - Task subagent (Grep/Read/WebFetch) if project has multiple packages to scan in parallel

      ### 2. Read references
      - WebFetch the guide above — follow the TypeScript Client tab
      - 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 feature, migrate existing SPL code, add alongside existing)
      - AskUserQuestion: does the project already have transfer operations to extend, or is this greenfield?
      - 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
      - Verify existing connection/signer setup is compatible with the cookbook prerequisites
      - 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 if missing: Bash `npm install @lightprotocol/compressed-token @lightprotocol/stateless.js`
      - Follow the cookbook guide and the approved plan
      - Write/Edit to create or modify files
      - TaskUpdate to mark each step done

      ### 6. Verify
      - Bash `tsc --noEmit`
      - Bash run existing test suite if present
      - 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
      ```
    </Tab>

    <Tab title="Rust">
      <Prompt description="Transfer tokens between Light Token and SPL accounts" actions={["copy", "cursor"]}>
        {`---
                description: Transfer tokens between Light Token and SPL accounts
                allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
                ---

                ## Transfer tokens between Light Token and SPL accounts

                Context:
                - Guide: https://zkcompression.com/light-token/cookbook/transfer-interface
                - Skills and resources index: https://zkcompression.com/skill.md
                - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
                - Crates: light-token-client (actions), light-token (instructions), light-client (RPC)

                TransferInterface transfers tokens between token accounts (SPL, Token 2022, or Light Token) in a single call.
                - Light Token → Light Token: transfers between Light Token accounts
                - SPL → Light Token: locks SPL tokens in interface PDA, mints to Light Token account
                - Light Token → SPL: burns Light Token balance, releases SPL tokens from interface PDA

                SPL equivalent: spl_token::instruction::transfer → Light Token: TransferInterface

                ### 1. Index project
                - Grep \`light_token::|light_token_client::|solana_sdk|Keypair|async|TransferInterface|transfer\` across src/
                - Glob \`**/*.rs\` for project structure
                - Identify: RPC setup, existing token ops, entry point for transfers
                - Check Cargo.toml for existing light-* 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 — follow the Rust Client tab
                - 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 feature, migrate existing SPL code, add alongside existing)
                - AskUserQuestion: does the project already have transfer operations to extend, or is this greenfield?
                - AskUserQuestion: action-level API (high-level, fewer lines) or instruction-level API (low-level, full control)?
                - 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
                - Verify existing Rpc/signer setup is compatible with the cookbook prerequisites (light_client::rpc::Rpc, solana_sdk::signature::Keypair)
                - 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 if missing: Bash \`cargo add light-token-client light-token light-client --features light-client/v2\`
                - Follow the cookbook guide and the approved plan
                - Write/Edit to create or modify files
                - TaskUpdate to mark each step done

                ### 6. Verify
                - Bash \`cargo check\`
                - Bash \`cargo 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`}
      </Prompt>

      ```text theme={null}
      ---
      description: Transfer tokens between Light Token and SPL accounts
      allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
      ---

      ## Transfer tokens between Light Token and SPL accounts

      Context:
      - Guide: https://zkcompression.com/light-token/cookbook/transfer-interface
      - Skills and resources index: https://zkcompression.com/skill.md
      - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
      - Crates: light-token-client (actions), light-token (instructions), light-client (RPC)

      TransferInterface transfers tokens between token accounts (SPL, Token 2022, or Light Token) in a single call.
      - Light Token → Light Token: transfers between Light Token accounts
      - SPL → Light Token: locks SPL tokens in interface PDA, mints to Light Token account
      - Light Token → SPL: burns Light Token balance, releases SPL tokens from interface PDA

      SPL equivalent: spl_token::instruction::transfer → Light Token: TransferInterface

      ### 1. Index project
      - Grep `light_token::|light_token_client::|solana_sdk|Keypair|async|TransferInterface|transfer` across src/
      - Glob `**/*.rs` for project structure
      - Identify: RPC setup, existing token ops, entry point for transfers
      - Check Cargo.toml for existing light-* 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 — follow the Rust Client tab
      - 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 feature, migrate existing SPL code, add alongside existing)
      - AskUserQuestion: does the project already have transfer operations to extend, or is this greenfield?
      - AskUserQuestion: action-level API (high-level, fewer lines) or instruction-level API (low-level, full control)?
      - 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
      - Verify existing Rpc/signer setup is compatible with the cookbook prerequisites (light_client::rpc::Rpc, solana_sdk::signature::Keypair)
      - 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 if missing: Bash `cargo add light-token-client light-token light-client --features light-client/v2`
      - Follow the cookbook guide and the approved plan
      - Write/Edit to create or modify files
      - TaskUpdate to mark each step done

      ### 6. Verify
      - Bash `cargo check`
      - Bash `cargo 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
      ```
    </Tab>
  </Tabs>
</Accordion>

### Wrap and unwrap

**Wrap** moves tokens from an SPL/Token 2022 account to a Light Token associated token account
(hot balance). **Unwrap** moves tokens back to SPL. Use this to compose with applications that do not yet support light-token.

> [Guide](/light-token/cookbook/wrap-unwrap) |
> [Example (wrap)](https://github.com/Lightprotocol/examples-light-token/blob/main/typescript-client/actions/wrap.ts) |
> [Example (unwrap)](https://github.com/Lightprotocol/examples-light-token/blob/main/typescript-client/actions/unwrap.ts)

<Tabs>
  <Tab title="TypeScript">
    <CodeGroup>
      ```typescript Action theme={null}
      import { getAssociatedTokenAddressSync } from "@solana/spl-token";
      import {
        wrap,
        unwrap,
        getAssociatedTokenAddressInterface,
      } from "@lightprotocol/compressed-token/unified";

      const splAta = getAssociatedTokenAddressSync(mint, owner.publicKey);
      const tokenAta = getAssociatedTokenAddressInterface(mint, owner.publicKey);

      // Wrap: SPL → Light
      await wrap(rpc, payer, splAta, tokenAta, owner, mint, amount);

      // Unwrap: Light → SPL
      await unwrap(rpc, payer, splAta, owner, mint, amount);
      ```

      ```typescript Instruction theme={null}
      import { createWrapInstruction, createUnwrapInstruction } from "@lightprotocol/compressed-token";

      const wrapIx = createWrapInstruction(
        source, destination, owner.publicKey, mint, amount, splInterfaceInfo, decimals
      );

      const unwrapIx = createUnwrapInstruction(
        source, destination, owner.publicKey, mint, amount, splInterfaceInfo, decimals
      );
      ```
    </CodeGroup>
  </Tab>

  <Tab title="Rust">
    ```rust theme={null}
    use light_token_client::actions::wrap::Wrap;

    Wrap {
        rpc: &mut rpc,
        payer: &payer,
        spl_ata,
        light_ata,
        owner: &owner,
        mint,
        amount,
    }
    .execute()
    .await?;
    ```

    ```rust theme={null}
    use light_token_client::actions::unwrap::Unwrap;

    Unwrap {
        rpc: &mut rpc,
        payer: &payer,
        spl_ata,
        owner: &owner,
        mint,
        amount,
    }
    .execute()
    .await?;
    ```
  </Tab>
</Tabs>

<Accordion title="AI prompt">
  <Tabs>
    <Tab title="TypeScript">
      <Prompt description="Wrap and unwrap SPL tokens to Light Token" actions={["copy", "cursor"]}>
        {`---
                description: Wrap and unwrap SPL tokens to Light Token
                allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
                ---

                ## Wrap and unwrap SPL tokens to Light Token

                Context:
                - Guide: https://zkcompression.com/light-token/cookbook/wrap-unwrap
                - Skills and resources index: https://zkcompression.com/skill.md
                - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
                - Packages: @lightprotocol/compressed-token, @lightprotocol/stateless.js

                - Wrap: Move tokens from SPL or Token 2022 account → Light Token associated token account (hot balance)
                - Unwrap: Move tokens from Light Token associated token account (hot balance) → SPL or Token 2022 account

                ### 1. Index project
                - Grep \`@solana/spl-token|Connection|Keypair|wrap|unwrap|WrapTokens|UnwrapTokens\` across src/
                - Glob \`**/*.ts\` for project structure
                - Identify: RPC setup, existing wrap/unwrap logic, entry point for wrap/unwrap
                - Task subagent (Grep/Read/WebFetch) if project has multiple packages to scan in parallel

                ### 2. Read references
                - WebFetch the guide above — follow the TypeScript Client tab
                - 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 feature, migrate existing SPL code, add alongside existing)
                - AskUserQuestion: does the project already have wrap/unwrap operations to extend, or is this greenfield?
                - 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
                - Verify existing connection/signer setup is compatible with the cookbook prerequisites
                - 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 if missing: Bash \`npm install @lightprotocol/compressed-token @lightprotocol/stateless.js\`
                - Follow the cookbook guide and the approved plan
                - Write/Edit to create or modify files
                - TaskUpdate to mark each step done

                ### 6. Verify
                - Bash \`tsc --noEmit\`
                - Bash run existing test suite if present
                - 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`}
      </Prompt>

      ```text theme={null}
      ---
      description: Wrap and unwrap SPL tokens to Light Token
      allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
      ---

      ## Wrap and unwrap SPL tokens to Light Token

      Context:
      - Guide: https://zkcompression.com/light-token/cookbook/wrap-unwrap
      - Skills and resources index: https://zkcompression.com/skill.md
      - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
      - Packages: @lightprotocol/compressed-token, @lightprotocol/stateless.js

      - Wrap: Move tokens from SPL or Token 2022 account → Light Token associated token account (hot balance)
      - Unwrap: Move tokens from Light Token associated token account (hot balance) → SPL or Token 2022 account

      ### 1. Index project
      - Grep `@solana/spl-token|Connection|Keypair|wrap|unwrap|WrapTokens|UnwrapTokens` across src/
      - Glob `**/*.ts` for project structure
      - Identify: RPC setup, existing wrap/unwrap logic, entry point for wrap/unwrap
      - Task subagent (Grep/Read/WebFetch) if project has multiple packages to scan in parallel

      ### 2. Read references
      - WebFetch the guide above — follow the TypeScript Client tab
      - 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 feature, migrate existing SPL code, add alongside existing)
      - AskUserQuestion: does the project already have wrap/unwrap operations to extend, or is this greenfield?
      - 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
      - Verify existing connection/signer setup is compatible with the cookbook prerequisites
      - 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 if missing: Bash `npm install @lightprotocol/compressed-token @lightprotocol/stateless.js`
      - Follow the cookbook guide and the approved plan
      - Write/Edit to create or modify files
      - TaskUpdate to mark each step done

      ### 6. Verify
      - Bash `tsc --noEmit`
      - Bash run existing test suite if present
      - 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
      ```
    </Tab>

    <Tab title="Rust">
      <Prompt description="Wrap and unwrap SPL tokens to Light Token" actions={["copy", "cursor"]}>
        {`---
                description: Wrap and unwrap SPL tokens to Light Token
                allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
                ---

                ## Wrap and unwrap SPL tokens to Light Token

                Context:
                - Guide: https://zkcompression.com/light-token/cookbook/wrap-unwrap
                - Skills and resources index: https://zkcompression.com/skill.md
                - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
                - Crates: light-token-client (actions), light-token (instructions), light-client (RPC)

                - Wrap: move tokens from SPL or Token 2022 account → Light Token ATA (hot balance)
                - Unwrap: move tokens from Light Token ATA (hot balance) → SPL or Token 2022 account

                No direct SPL equivalent — Wrap/Unwrap are Light Token operations → Light Token: Wrap / Unwrap

                ### 1. Index project
                - Grep \`light_token::|light_token_client::|solana_sdk|Keypair|async|Wrap|Unwrap|wrap|unwrap\` across src/
                - Glob \`**/*.rs\` for project structure
                - Identify: RPC setup, existing token ops, entry point for wrap/unwrap
                - Check Cargo.toml for existing light-* 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 — follow the Rust Client tab
                - 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 feature, migrate existing SPL code, add alongside existing)
                - AskUserQuestion: does the project already have wrap/unwrap operations to extend, or is this greenfield?
                - AskUserQuestion: action-level API (high-level, fewer lines) or instruction-level API (low-level, full control)?
                - 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
                - Verify existing Rpc/signer setup is compatible with the cookbook prerequisites (light_client::rpc::Rpc, solana_sdk::signature::Keypair)
                - 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 if missing: Bash \`cargo add light-token-client light-token light-client --features light-client/v2\`
                - Follow the cookbook guide and the approved plan
                - Write/Edit to create or modify files
                - TaskUpdate to mark each step done

                ### 6. Verify
                - Bash \`cargo check\`
                - Bash \`cargo 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`}
      </Prompt>

      ```text theme={null}
      ---
      description: Wrap and unwrap SPL tokens to Light Token
      allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
      ---

      ## Wrap and unwrap SPL tokens to Light Token

      Context:
      - Guide: https://zkcompression.com/light-token/cookbook/wrap-unwrap
      - Skills and resources index: https://zkcompression.com/skill.md
      - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
      - Crates: light-token-client (actions), light-token (instructions), light-client (RPC)

      - Wrap: move tokens from SPL or Token 2022 account → Light Token ATA (hot balance)
      - Unwrap: move tokens from Light Token ATA (hot balance) → SPL or Token 2022 account

      No direct SPL equivalent — Wrap/Unwrap are Light Token operations → Light Token: Wrap / Unwrap

      ### 1. Index project
      - Grep `light_token::|light_token_client::|solana_sdk|Keypair|async|Wrap|Unwrap|wrap|unwrap` across src/
      - Glob `**/*.rs` for project structure
      - Identify: RPC setup, existing token ops, entry point for wrap/unwrap
      - Check Cargo.toml for existing light-* 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 — follow the Rust Client tab
      - 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 feature, migrate existing SPL code, add alongside existing)
      - AskUserQuestion: does the project already have wrap/unwrap operations to extend, or is this greenfield?
      - AskUserQuestion: action-level API (high-level, fewer lines) or instruction-level API (low-level, full control)?
      - 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
      - Verify existing Rpc/signer setup is compatible with the cookbook prerequisites (light_client::rpc::Rpc, solana_sdk::signature::Keypair)
      - 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 if missing: Bash `cargo add light-token-client light-token light-client --features light-client/v2`
      - Follow the cookbook guide and the approved plan
      - Write/Edit to create or modify files
      - TaskUpdate to mark each step done

      ### 6. Verify
      - Bash `cargo check`
      - Bash `cargo 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
      ```
    </Tab>
  </Tabs>
</Accordion>

### Approve delegate

Approve a delegate to spend tokens up to a specified amount.

> [Guide](/light-token/cookbook/approve-revoke) |
> [Example (TS)](https://github.com/Lightprotocol/examples-light-token/blob/main/typescript-client/actions/delegate-approve.ts) |
> [Example (Rust)](https://github.com/Lightprotocol/examples-light-token/blob/main/rust-client/actions/approve.rs)

<Tabs>
  <Tab title="TypeScript">
    <Columns cols={2}>
      ```typescript theme={null}
      import { approveInterface } from "@lightprotocol/compressed-token";

      const tx = await approveInterface(
        rpc,
        payer,
        tokenAccount,
        mint,
        delegate,
        amount,
        owner
      );
      ```

      ```typescript title="SPL" theme={null}
      import { approve } from "@solana/spl-token";

      const tx = await approve(
        connection,
        payer,
        source,
        delegate,
        owner,
        amount
      );
      ```
    </Columns>
  </Tab>

  <Tab title="Rust">
    <Columns cols={2}>
      <CodeGroup>
        ```rust Light Instruction theme={null}
        use light_token::instruction::Approve;

        let ix = Approve {
            token_account: ata,
            delegate: delegate.pubkey(),
            owner: payer.pubkey(),
            amount,
            fee_payer: payer.pubkey(),
        }
        .instruction()?;
        ```

        ```rust Light Action theme={null}
        use light_token_client::actions::Approve;

        let sig = Approve {
            token_account: ata,
            delegate: delegate.pubkey(),
            amount,
            owner: None,
        }
        .execute(&mut rpc, &payer)
        .await?;
        ```
      </CodeGroup>

      ```rust title="SPL" theme={null}
      use spl_token::instruction::approve;

      let ix = approve(
          &spl_token::id(),
          &source,
          &delegate,
          &owner,
          &[],
          amount,
      )?;
      ```
    </Columns>
  </Tab>
</Tabs>

<Accordion title="AI prompt">
  <Tabs>
    <Tab title="TypeScript">
      <Prompt description="Approve and revoke token delegates" actions={["copy", "cursor"]}>
        {`---
                description: Approve and revoke token delegates
                allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
                ---

                ## Approve and revoke token delegates

                Context:
                - Guide: https://zkcompression.com/light-token/cookbook/approve-revoke
                - Skills and resources index: https://zkcompression.com/skill.md
                - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
                - Packages: @lightprotocol/compressed-token, @lightprotocol/stateless.js

                SPL equivalent: approve() / revoke() → Light Token: approve() / revoke()

                ### 1. Index project
                - Grep \`@solana/spl-token|Connection|Keypair|approve|revoke|delegate\` across src/
                - Glob \`**/*.ts\` for project structure
                - Identify: RPC setup, existing delegation logic, entry point for delegation
                - Task subagent (Grep/Read/WebFetch) if project has multiple packages to scan in parallel

                ### 2. Read references
                - WebFetch the guide above — follow the TypeScript Client tab
                - 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 feature, migrate existing SPL code, add alongside existing)
                - AskUserQuestion: does the project already have delegate operations to extend, or is this greenfield?
                - 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
                - Verify existing connection/signer setup is compatible with the cookbook prerequisites
                - 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 if missing: Bash \`npm install @lightprotocol/compressed-token @lightprotocol/stateless.js\`
                - Follow the cookbook guide and the approved plan
                - Write/Edit to create or modify files
                - TaskUpdate to mark each step done

                ### 6. Verify
                - Bash \`tsc --noEmit\`
                - Bash run existing test suite if present
                - 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`}
      </Prompt>

      ```text theme={null}
      ---
      description: Approve and revoke token delegates
      allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
      ---

      ## Approve and revoke token delegates

      Context:
      - Guide: https://zkcompression.com/light-token/cookbook/approve-revoke
      - Skills and resources index: https://zkcompression.com/skill.md
      - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
      - Packages: @lightprotocol/compressed-token, @lightprotocol/stateless.js

      SPL equivalent: approve() / revoke() → Light Token: approve() / revoke()

      ### 1. Index project
      - Grep `@solana/spl-token|Connection|Keypair|approve|revoke|delegate` across src/
      - Glob `**/*.ts` for project structure
      - Identify: RPC setup, existing delegation logic, entry point for delegation
      - Task subagent (Grep/Read/WebFetch) if project has multiple packages to scan in parallel

      ### 2. Read references
      - WebFetch the guide above — follow the TypeScript Client tab
      - 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 feature, migrate existing SPL code, add alongside existing)
      - AskUserQuestion: does the project already have delegate operations to extend, or is this greenfield?
      - 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
      - Verify existing connection/signer setup is compatible with the cookbook prerequisites
      - 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 if missing: Bash `npm install @lightprotocol/compressed-token @lightprotocol/stateless.js`
      - Follow the cookbook guide and the approved plan
      - Write/Edit to create or modify files
      - TaskUpdate to mark each step done

      ### 6. Verify
      - Bash `tsc --noEmit`
      - Bash run existing test suite if present
      - 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
      ```
    </Tab>

    <Tab title="Rust">
      <Prompt description="Approve and revoke token delegates" actions={["copy", "cursor"]}>
        {`---
                description: Approve and revoke token delegates
                allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
                ---

                ## Approve and revoke token delegates

                Context:
                - Guide: https://zkcompression.com/light-token/cookbook/approve-revoke
                - Skills and resources index: https://zkcompression.com/skill.md
                - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
                - Crates: light-token-client (actions), light-token (instructions), light-client (RPC)

                SPL equivalent: spl_token::instruction::approve / revoke → Light Token: Approve / Revoke

                ### 1. Index project
                - Grep \`light_token::|light_token_client::|solana_sdk|Keypair|async|Approve|Revoke|delegate\` across src/
                - Glob \`**/*.rs\` for project structure
                - Identify: RPC setup, existing token ops, entry point for delegation
                - Check Cargo.toml for existing light-* 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 — follow the Rust Client tab
                - 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 feature, migrate existing SPL code, add alongside existing)
                - AskUserQuestion: does the project already have delegation operations to extend, or is this greenfield?
                - AskUserQuestion: action-level API (high-level, fewer lines) or instruction-level API (low-level, full control)?
                - 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
                - Verify existing Rpc/signer setup is compatible with the cookbook prerequisites (light_client::rpc::Rpc, solana_sdk::signature::Keypair)
                - 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 if missing: Bash \`cargo add light-token-client light-token light-client --features light-client/v2\`
                - Follow the cookbook guide and the approved plan
                - Write/Edit to create or modify files
                - TaskUpdate to mark each step done

                ### 6. Verify
                - Bash \`cargo check\`
                - Bash \`cargo 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`}
      </Prompt>

      ```text theme={null}
      ---
      description: Approve and revoke token delegates
      allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
      ---

      ## Approve and revoke token delegates

      Context:
      - Guide: https://zkcompression.com/light-token/cookbook/approve-revoke
      - Skills and resources index: https://zkcompression.com/skill.md
      - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
      - Crates: light-token-client (actions), light-token (instructions), light-client (RPC)

      SPL equivalent: spl_token::instruction::approve / revoke → Light Token: Approve / Revoke

      ### 1. Index project
      - Grep `light_token::|light_token_client::|solana_sdk|Keypair|async|Approve|Revoke|delegate` across src/
      - Glob `**/*.rs` for project structure
      - Identify: RPC setup, existing token ops, entry point for delegation
      - Check Cargo.toml for existing light-* 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 — follow the Rust Client tab
      - 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 feature, migrate existing SPL code, add alongside existing)
      - AskUserQuestion: does the project already have delegation operations to extend, or is this greenfield?
      - AskUserQuestion: action-level API (high-level, fewer lines) or instruction-level API (low-level, full control)?
      - 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
      - Verify existing Rpc/signer setup is compatible with the cookbook prerequisites (light_client::rpc::Rpc, solana_sdk::signature::Keypair)
      - 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 if missing: Bash `cargo add light-token-client light-token light-client --features light-client/v2`
      - Follow the cookbook guide and the approved plan
      - Write/Edit to create or modify files
      - TaskUpdate to mark each step done

      ### 6. Verify
      - Bash `cargo check`
      - Bash `cargo 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
      ```
    </Tab>
  </Tabs>
</Accordion>

### Delegated transfer

Transfer tokens as an approved delegate. The delegate is the transaction authority; the owner's signature is not required.

> [Guide](/light-token/payments/spend-permissions)

<Tabs>
  <Tab title="TypeScript">
    <Columns cols={2}>
      ```typescript title="Light" theme={null}
      import { transferInterface } from "@lightprotocol/compressed-token/unified";

      const tx = await transferInterface(
        rpc,
        payer,
        sourceAta,
        mint,
        recipient,
        owner.publicKey,
        delegate,
        amount
      );
      ```

      ```typescript title="SPL" theme={null}
      import { transfer } from "@solana/spl-token";

      // delegate signs instead of owner
      const tx = await transfer(
        connection,
        payer,
        sourceAta,
        destinationAta,
        delegate,
        amount
      );
      ```
    </Columns>
  </Tab>
</Tabs>

### Revoke delegate

Remove all delegate permissions.

> [Guide](/light-token/cookbook/approve-revoke) |
> [Example (TS)](https://github.com/Lightprotocol/examples-light-token/blob/main/typescript-client/actions/delegate-revoke.ts) |
> [Example (Rust)](https://github.com/Lightprotocol/examples-light-token/blob/main/rust-client/actions/revoke.rs)

<Tabs>
  <Tab title="TypeScript">
    <Columns cols={2}>
      ```typescript theme={null}
      import { revokeInterface } from "@lightprotocol/compressed-token";

      const tx = await revokeInterface(
        rpc,
        payer,
        tokenAccount,
        mint,
        owner
      );
      ```

      ```typescript title="SPL" theme={null}
      import { revoke } from "@solana/spl-token";

      const tx = await revoke(
        connection,
        payer,
        source,
        owner
      );
      ```
    </Columns>
  </Tab>

  <Tab title="Rust">
    <Columns cols={2}>
      <CodeGroup>
        ```rust Light Instruction theme={null}
        use light_token::instruction::Revoke;

        let ix = Revoke {
            token_account: ata,
            owner: payer.pubkey(),
            fee_payer: payer.pubkey(),
        }
        .instruction()?;
        ```

        ```rust Light Action theme={null}
        use light_token_client::actions::Revoke;

        let sig = Revoke {
            token_account: ata,
            owner: None,
        }
        .execute(&mut rpc, &payer)
        .await?;
        ```
      </CodeGroup>

      ```rust title="SPL" theme={null}
      use spl_token::instruction::revoke;

      let ix = revoke(
          &spl_token::id(),
          &source,
          &owner,
          &[],
      )?;
      ```
    </Columns>
  </Tab>
</Tabs>

<Accordion title="AI prompt">
  <Tabs>
    <Tab title="TypeScript">
      <Prompt description="Approve and revoke token delegates" actions={["copy", "cursor"]}>
        {`---
                description: Approve and revoke token delegates
                allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
                ---

                ## Approve and revoke token delegates

                Context:
                - Guide: https://zkcompression.com/light-token/cookbook/approve-revoke
                - Skills and resources index: https://zkcompression.com/skill.md
                - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
                - Packages: @lightprotocol/compressed-token, @lightprotocol/stateless.js

                SPL equivalent: approve() / revoke() → Light Token: approve() / revoke()

                ### 1. Index project
                - Grep \`@solana/spl-token|Connection|Keypair|approve|revoke|delegate\` across src/
                - Glob \`**/*.ts\` for project structure
                - Identify: RPC setup, existing delegation logic, entry point for delegation
                - Task subagent (Grep/Read/WebFetch) if project has multiple packages to scan in parallel

                ### 2. Read references
                - WebFetch the guide above — follow the TypeScript Client tab
                - 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 feature, migrate existing SPL code, add alongside existing)
                - AskUserQuestion: does the project already have delegate operations to extend, or is this greenfield?
                - 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
                - Verify existing connection/signer setup is compatible with the cookbook prerequisites
                - 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 if missing: Bash \`npm install @lightprotocol/compressed-token @lightprotocol/stateless.js\`
                - Follow the cookbook guide and the approved plan
                - Write/Edit to create or modify files
                - TaskUpdate to mark each step done

                ### 6. Verify
                - Bash \`tsc --noEmit\`
                - Bash run existing test suite if present
                - 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`}
      </Prompt>

      ```text theme={null}
      ---
      description: Approve and revoke token delegates
      allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
      ---

      ## Approve and revoke token delegates

      Context:
      - Guide: https://zkcompression.com/light-token/cookbook/approve-revoke
      - Skills and resources index: https://zkcompression.com/skill.md
      - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
      - Packages: @lightprotocol/compressed-token, @lightprotocol/stateless.js

      SPL equivalent: approve() / revoke() → Light Token: approve() / revoke()

      ### 1. Index project
      - Grep `@solana/spl-token|Connection|Keypair|approve|revoke|delegate` across src/
      - Glob `**/*.ts` for project structure
      - Identify: RPC setup, existing delegation logic, entry point for delegation
      - Task subagent (Grep/Read/WebFetch) if project has multiple packages to scan in parallel

      ### 2. Read references
      - WebFetch the guide above — follow the TypeScript Client tab
      - 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 feature, migrate existing SPL code, add alongside existing)
      - AskUserQuestion: does the project already have delegate operations to extend, or is this greenfield?
      - 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
      - Verify existing connection/signer setup is compatible with the cookbook prerequisites
      - 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 if missing: Bash `npm install @lightprotocol/compressed-token @lightprotocol/stateless.js`
      - Follow the cookbook guide and the approved plan
      - Write/Edit to create or modify files
      - TaskUpdate to mark each step done

      ### 6. Verify
      - Bash `tsc --noEmit`
      - Bash run existing test suite if present
      - 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
      ```
    </Tab>

    <Tab title="Rust">
      <Prompt description="Approve and revoke token delegates" actions={["copy", "cursor"]}>
        {`---
                description: Approve and revoke token delegates
                allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
                ---

                ## Approve and revoke token delegates

                Context:
                - Guide: https://zkcompression.com/light-token/cookbook/approve-revoke
                - Skills and resources index: https://zkcompression.com/skill.md
                - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
                - Crates: light-token-client (actions), light-token (instructions), light-client (RPC)

                SPL equivalent: spl_token::instruction::approve / revoke → Light Token: Approve / Revoke

                ### 1. Index project
                - Grep \`light_token::|light_token_client::|solana_sdk|Keypair|async|Approve|Revoke|delegate\` across src/
                - Glob \`**/*.rs\` for project structure
                - Identify: RPC setup, existing token ops, entry point for delegation
                - Check Cargo.toml for existing light-* 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 — follow the Rust Client tab
                - 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 feature, migrate existing SPL code, add alongside existing)
                - AskUserQuestion: does the project already have delegation operations to extend, or is this greenfield?
                - AskUserQuestion: action-level API (high-level, fewer lines) or instruction-level API (low-level, full control)?
                - 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
                - Verify existing Rpc/signer setup is compatible with the cookbook prerequisites (light_client::rpc::Rpc, solana_sdk::signature::Keypair)
                - 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 if missing: Bash \`cargo add light-token-client light-token light-client --features light-client/v2\`
                - Follow the cookbook guide and the approved plan
                - Write/Edit to create or modify files
                - TaskUpdate to mark each step done

                ### 6. Verify
                - Bash \`cargo check\`
                - Bash \`cargo 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`}
      </Prompt>

      ```text theme={null}
      ---
      description: Approve and revoke token delegates
      allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
      ---

      ## Approve and revoke token delegates

      Context:
      - Guide: https://zkcompression.com/light-token/cookbook/approve-revoke
      - Skills and resources index: https://zkcompression.com/skill.md
      - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
      - Crates: light-token-client (actions), light-token (instructions), light-client (RPC)

      SPL equivalent: spl_token::instruction::approve / revoke → Light Token: Approve / Revoke

      ### 1. Index project
      - Grep `light_token::|light_token_client::|solana_sdk|Keypair|async|Approve|Revoke|delegate` across src/
      - Glob `**/*.rs` for project structure
      - Identify: RPC setup, existing token ops, entry point for delegation
      - Check Cargo.toml for existing light-* 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 — follow the Rust Client tab
      - 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 feature, migrate existing SPL code, add alongside existing)
      - AskUserQuestion: does the project already have delegation operations to extend, or is this greenfield?
      - AskUserQuestion: action-level API (high-level, fewer lines) or instruction-level API (low-level, full control)?
      - 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
      - Verify existing Rpc/signer setup is compatible with the cookbook prerequisites (light_client::rpc::Rpc, solana_sdk::signature::Keypair)
      - 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 if missing: Bash `cargo add light-token-client light-token light-client --features light-client/v2`
      - Follow the cookbook guide and the approved plan
      - Write/Edit to create or modify files
      - TaskUpdate to mark each step done

      ### 6. Verify
      - Bash `cargo check`
      - Bash `cargo 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
      ```
    </Tab>
  </Tabs>
</Accordion>

### Create token account

> [Guide](/light-token/cookbook/create-token-account) |
> [Example](https://github.com/Lightprotocol/examples-light-token/blob/main/rust-client/instructions/create_token_account.rs)

<Columns cols={2}>
  ```rust theme={null}
  use light_token::instruction::CreateTokenAccount;

  let ix = CreateTokenAccount::new(
      payer.pubkey(),
      account.pubkey(),
      mint,
      owner,
  )
  .instruction()?;
  ```

  ```rust title="SPL" theme={null}
  use spl_token::instruction::initialize_account;

  let ix = initialize_account(
      &spl_token::id(),
      &account,
      &mint,
      &owner,
  )?;
  ```
</Columns>

<Accordion title="AI prompt">
  <Prompt description="Create Light Token account" actions={["copy", "cursor"]}>
    {`---
        description: Create Light Token account
        allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
        ---

        ## Create Light Token account

        Context:
        - Guide: https://zkcompression.com/light-token/cookbook/create-token-account
        - Skills and resources index: https://zkcompression.com/skill.md
        - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
        - Crates: light-token-client (actions), light-token (instructions), light-client (RPC)

        SPL equivalent: spl_token::instruction::initialize_account → Light Token: CreateTokenAccount

        ### 1. Index project
        - Grep \`light_token::|light_token_client::|solana_sdk|Keypair|async|CreateTokenAccount|initialize_account\` across src/
        - Glob \`**/*.rs\` for project structure
        - Identify: RPC setup, existing token ops, entry point for token account creation
        - Check Cargo.toml for existing light-* 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 — follow the Rust Client tab
        - 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 feature, migrate existing SPL code, add alongside existing)
        - AskUserQuestion: does the project already have token account operations to extend, or is this greenfield?
        - AskUserQuestion: action-level API (high-level, fewer lines) or instruction-level API (low-level, full control)?
        - 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
        - Verify existing Rpc/signer setup is compatible with the cookbook prerequisites (light_client::rpc::Rpc, solana_sdk::signature::Keypair)
        - 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 if missing: Bash \`cargo add light-token-client light-token light-client --features light-client/v2\`
        - Follow the cookbook guide and the approved plan
        - Write/Edit to create or modify files
        - TaskUpdate to mark each step done

        ### 6. Verify
        - Bash \`cargo check\`
        - Bash \`cargo 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`}
  </Prompt>

  ```text theme={null}
  ---
  description: Create Light Token account
  allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
  ---

  ## Create Light Token account

  Context:
  - Guide: https://zkcompression.com/light-token/cookbook/create-token-account
  - Skills and resources index: https://zkcompression.com/skill.md
  - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
  - Crates: light-token-client (actions), light-token (instructions), light-client (RPC)

  SPL equivalent: spl_token::instruction::initialize_account → Light Token: CreateTokenAccount

  ### 1. Index project
  - Grep `light_token::|light_token_client::|solana_sdk|Keypair|async|CreateTokenAccount|initialize_account` across src/
  - Glob `**/*.rs` for project structure
  - Identify: RPC setup, existing token ops, entry point for token account creation
  - Check Cargo.toml for existing light-* 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 — follow the Rust Client tab
  - 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 feature, migrate existing SPL code, add alongside existing)
  - AskUserQuestion: does the project already have token account operations to extend, or is this greenfield?
  - AskUserQuestion: action-level API (high-level, fewer lines) or instruction-level API (low-level, full control)?
  - 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
  - Verify existing Rpc/signer setup is compatible with the cookbook prerequisites (light_client::rpc::Rpc, solana_sdk::signature::Keypair)
  - 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 if missing: Bash `cargo add light-token-client light-token light-client --features light-client/v2`
  - Follow the cookbook guide and the approved plan
  - Write/Edit to create or modify files
  - TaskUpdate to mark each step done

  ### 6. Verify
  - Bash `cargo check`
  - Bash `cargo 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
  ```
</Accordion>

### Burn

Permanently destroy tokens and reduce mint supply.

> [Guide](/light-token/cookbook/burn) |
> [Example](https://github.com/Lightprotocol/examples-light-token/blob/main/rust-client/instructions/burn.rs)

<Columns cols={2}>
  ```rust theme={null}
  use light_token::instruction::Burn;

  let ix = Burn {
      source,
      mint,
      amount,
      authority: payer.pubkey(),
      max_top_up: None,
      fee_payer: None,
  }
  .instruction()?;
  ```

  ```rust title="SPL" theme={null}
  use spl_token::instruction::burn;

  let ix = burn(
      &spl_token::id(),
      &source,
      &mint,
      &authority,
      &[],
      amount,
  )?;
  ```
</Columns>

<Accordion title="AI prompt">
  <Prompt description="Burn Light Tokens" actions={["copy", "cursor"]}>
    {`---
        description: Burn Light Tokens
        allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
        ---

        ## Burn Light Tokens

        Context:
        - Guide: https://zkcompression.com/light-token/cookbook/burn
        - Skills and resources index: https://zkcompression.com/skill.md
        - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
        - Crates: light-token-client (actions), light-token (instructions), light-client (RPC)

        SPL equivalent: spl_token::instruction::burn → Light Token: Burn

        ### 1. Index project
        - Grep \`light_token::|light_token_client::|solana_sdk|Keypair|async|Burn|burn\` across src/
        - Glob \`**/*.rs\` for project structure
        - Identify: RPC setup, existing token ops, entry point for burn
        - Check Cargo.toml for existing light-* 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 — follow the Rust Client tab
        - 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 feature, migrate existing SPL code, add alongside existing)
        - AskUserQuestion: does the project already have burn operations to extend, or is this greenfield?
        - AskUserQuestion: action-level API (high-level, fewer lines) or instruction-level API (low-level, full control)?
        - 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
        - Verify existing Rpc/signer setup is compatible with the cookbook prerequisites (light_client::rpc::Rpc, solana_sdk::signature::Keypair)
        - 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 if missing: Bash \`cargo add light-token-client light-token light-client --features light-client/v2\`
        - Follow the cookbook guide and the approved plan
        - Write/Edit to create or modify files
        - TaskUpdate to mark each step done

        ### 6. Verify
        - Bash \`cargo check\`
        - Bash \`cargo 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`}
  </Prompt>

  ```text theme={null}
  ---
  description: Burn Light Tokens
  allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
  ---

  ## Burn Light Tokens

  Context:
  - Guide: https://zkcompression.com/light-token/cookbook/burn
  - Skills and resources index: https://zkcompression.com/skill.md
  - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
  - Crates: light-token-client (actions), light-token (instructions), light-client (RPC)

  SPL equivalent: spl_token::instruction::burn → Light Token: Burn

  ### 1. Index project
  - Grep `light_token::|light_token_client::|solana_sdk|Keypair|async|Burn|burn` across src/
  - Glob `**/*.rs` for project structure
  - Identify: RPC setup, existing token ops, entry point for burn
  - Check Cargo.toml for existing light-* 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 — follow the Rust Client tab
  - 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 feature, migrate existing SPL code, add alongside existing)
  - AskUserQuestion: does the project already have burn operations to extend, or is this greenfield?
  - AskUserQuestion: action-level API (high-level, fewer lines) or instruction-level API (low-level, full control)?
  - 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
  - Verify existing Rpc/signer setup is compatible with the cookbook prerequisites (light_client::rpc::Rpc, solana_sdk::signature::Keypair)
  - 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 if missing: Bash `cargo add light-token-client light-token light-client --features light-client/v2`
  - Follow the cookbook guide and the approved plan
  - Write/Edit to create or modify files
  - TaskUpdate to mark each step done

  ### 6. Verify
  - Bash `cargo check`
  - Bash `cargo 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
  ```
</Accordion>

### Freeze and thaw

Freeze prevents all transfers, burns, or closes. Only the freeze authority can freeze or thaw.

> [Guide](/light-token/cookbook/freeze-thaw) |
> [Example (freeze)](https://github.com/Lightprotocol/examples-light-token/blob/main/rust-client/instructions/freeze.rs) |
> [Example (thaw)](https://github.com/Lightprotocol/examples-light-token/blob/main/rust-client/instructions/thaw.rs)

<Columns cols={2}>
  <div>
    ```rust theme={null}
    use light_token::instruction::Freeze;

    let ix = Freeze {
        token_account: ata,
        mint,
        freeze_authority: payer.pubkey(),
    }
    .instruction()?;
    ```

    ```rust theme={null}
    use light_token::instruction::Thaw;

    let ix = Thaw {
        token_account: ata,
        mint,
        freeze_authority: payer.pubkey(),
    }
    .instruction()?;
    ```
  </div>

  ```rust title="SPL" theme={null}
  use spl_token::instruction::{freeze_account, thaw_account};

  let ix = freeze_account(
      &spl_token::id(),
      &account,
      &mint,
      &freeze_authority,
      &[],
  )?;

  let ix = thaw_account(
      &spl_token::id(),
      &account,
      &mint,
      &freeze_authority,
      &[],
  )?;
  ```
</Columns>

<Accordion title="AI prompt">
  <Prompt description="Freeze and thaw Light Token accounts" actions={["copy", "cursor"]}>
    {`---
        description: Freeze and thaw Light Token accounts
        allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
        ---

        ## Freeze and thaw Light Token accounts

        Context:
        - Guide: https://zkcompression.com/light-token/cookbook/freeze-thaw
        - Skills and resources index: https://zkcompression.com/skill.md
        - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
        - Crates: light-token-client (actions), light-token (instructions), light-client (RPC)

        - Freeze: prevents all transfers or token burns from a specific Light Token account
        - Thaw: re-enables transfers on a frozen Light Token account
        - Only the freeze authority (set at mint creation) can freeze or thaw accounts

        SPL equivalent: spl_token::instruction::freeze_account / thaw_account → Light Token: Freeze / Thaw

        ### 1. Index project
        - Grep \`light_token::|light_token_client::|solana_sdk|Keypair|async|Freeze|Thaw|freeze_account|thaw_account\` across src/
        - Glob \`**/*.rs\` for project structure
        - Identify: RPC setup, existing token ops, entry point for freeze/thaw
        - Check Cargo.toml for existing light-* 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 — follow the Rust Client tab
        - 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 feature, migrate existing SPL code, add alongside existing)
        - AskUserQuestion: does the project already have freeze/thaw operations to extend, or is this greenfield?
        - AskUserQuestion: action-level API (high-level, fewer lines) or instruction-level API (low-level, full control)?
        - 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
        - Verify existing Rpc/signer setup is compatible with the cookbook prerequisites (light_client::rpc::Rpc, solana_sdk::signature::Keypair)
        - 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 if missing: Bash \`cargo add light-token-client light-token light-client --features light-client/v2\`
        - Follow the cookbook guide and the approved plan
        - Write/Edit to create or modify files
        - TaskUpdate to mark each step done

        ### 6. Verify
        - Bash \`cargo check\`
        - Bash \`cargo 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`}
  </Prompt>

  ```text theme={null}
  ---
  description: Freeze and thaw Light Token accounts
  allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
  ---

  ## Freeze and thaw Light Token accounts

  Context:
  - Guide: https://zkcompression.com/light-token/cookbook/freeze-thaw
  - Skills and resources index: https://zkcompression.com/skill.md
  - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
  - Crates: light-token-client (actions), light-token (instructions), light-client (RPC)

  - Freeze: prevents all transfers or token burns from a specific Light Token account
  - Thaw: re-enables transfers on a frozen Light Token account
  - Only the freeze authority (set at mint creation) can freeze or thaw accounts

  SPL equivalent: spl_token::instruction::freeze_account / thaw_account → Light Token: Freeze / Thaw

  ### 1. Index project
  - Grep `light_token::|light_token_client::|solana_sdk|Keypair|async|Freeze|Thaw|freeze_account|thaw_account` across src/
  - Glob `**/*.rs` for project structure
  - Identify: RPC setup, existing token ops, entry point for freeze/thaw
  - Check Cargo.toml for existing light-* 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 — follow the Rust Client tab
  - 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 feature, migrate existing SPL code, add alongside existing)
  - AskUserQuestion: does the project already have freeze/thaw operations to extend, or is this greenfield?
  - AskUserQuestion: action-level API (high-level, fewer lines) or instruction-level API (low-level, full control)?
  - 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
  - Verify existing Rpc/signer setup is compatible with the cookbook prerequisites (light_client::rpc::Rpc, solana_sdk::signature::Keypair)
  - 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 if missing: Bash `cargo add light-token-client light-token light-client --features light-client/v2`
  - Follow the cookbook guide and the approved plan
  - Write/Edit to create or modify files
  - TaskUpdate to mark each step done

  ### 6. Verify
  - Bash `cargo check`
  - Bash `cargo 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
  ```
</Accordion>

### Close token account

Close an empty token account and reclaim lamports.

> [Guide](/light-token/cookbook/close-token-account) |
> [Example](https://github.com/Lightprotocol/examples-light-token/blob/main/rust-client/instructions/close.rs)

<Columns cols={2}>
  ```rust theme={null}
  use light_token::instruction::{CloseAccount, LIGHT_TOKEN_PROGRAM_ID};

  let ix = CloseAccount::new(
      LIGHT_TOKEN_PROGRAM_ID,
      account,
      destination,
      owner,
  )
  .instruction()?;
  ```

  ```rust title="SPL" theme={null}
  use spl_token::instruction::close_account;

  let ix = close_account(
      &spl_token::id(),
      &account,
      &destination,
      &owner,
      &[],
  )?;
  ```
</Columns>

<Accordion title="AI prompt">
  <Prompt description="Close Light Token account" actions={["copy", "cursor"]}>
    {`---
        description: Close Light Token account
        allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
        ---

        ## Close Light Token account

        Context:
        - Guide: https://zkcompression.com/light-token/cookbook/close-token-account
        - Skills and resources index: https://zkcompression.com/skill.md
        - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
        - Crates: light-token-client (actions), light-token (instructions), light-client (RPC)

        SPL equivalent: spl_token::instruction::close_account → Light Token: CloseAccount

        ### 1. Index project
        - Grep \`light_token::|light_token_client::|solana_sdk|Keypair|async|CloseAccount|close_account\` across src/
        - Glob \`**/*.rs\` for project structure
        - Identify: RPC setup, existing token ops, entry point for close account
        - Check Cargo.toml for existing light-* 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 — follow the Rust Client tab
        - 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 feature, migrate existing SPL code, add alongside existing)
        - AskUserQuestion: does the project already have close operations to extend, or is this greenfield?
        - AskUserQuestion: action-level API (high-level, fewer lines) or instruction-level API (low-level, full control)?
        - 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
        - Verify existing Rpc/signer setup is compatible with the cookbook prerequisites (light_client::rpc::Rpc, solana_sdk::signature::Keypair)
        - 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 if missing: Bash \`cargo add light-token-client light-token light-client --features light-client/v2\`
        - Follow the cookbook guide and the approved plan
        - Write/Edit to create or modify files
        - TaskUpdate to mark each step done

        ### 6. Verify
        - Bash \`cargo check\`
        - Bash \`cargo 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`}
  </Prompt>

  ```text theme={null}
  ---
  description: Close Light Token account
  allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
  ---

  ## Close Light Token account

  Context:
  - Guide: https://zkcompression.com/light-token/cookbook/close-token-account
  - Skills and resources index: https://zkcompression.com/skill.md
  - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
  - Crates: light-token-client (actions), light-token (instructions), light-client (RPC)

  SPL equivalent: spl_token::instruction::close_account → Light Token: CloseAccount

  ### 1. Index project
  - Grep `light_token::|light_token_client::|solana_sdk|Keypair|async|CloseAccount|close_account` across src/
  - Glob `**/*.rs` for project structure
  - Identify: RPC setup, existing token ops, entry point for close account
  - Check Cargo.toml for existing light-* 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 — follow the Rust Client tab
  - 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 feature, migrate existing SPL code, add alongside existing)
  - AskUserQuestion: does the project already have close operations to extend, or is this greenfield?
  - AskUserQuestion: action-level API (high-level, fewer lines) or instruction-level API (low-level, full control)?
  - 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
  - Verify existing Rpc/signer setup is compatible with the cookbook prerequisites (light_client::rpc::Rpc, solana_sdk::signature::Keypair)
  - 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 if missing: Bash `cargo add light-token-client light-token light-client --features light-client/v2`
  - Follow the cookbook guide and the approved plan
  - Write/Edit to create or modify files
  - TaskUpdate to mark each step done

  ### 6. Verify
  - Bash `cargo check`
  - Bash `cargo 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
  ```
</Accordion>

***

## Program CPI

`light_token::instruction::*Cpi` structs map 1:1 to `spl_token::instruction::*`. Use `.invoke()` for external signers or `.invoke_signed()` for PDA signers. Add `.rent_free()` to sponsor rent-exemption on account creation.

### CreateMintCpi

Create a rent-free mint account via CPI.

> [Guide](/light-token/cookbook/create-mint) |
> [Example](https://github.com/Lightprotocol/examples-light-token/blob/main/programs/anchor/basic-instructions/create-mint/src/lib.rs) |
> [Source](https://docs.rs/light-token)

<Columns cols={2}>
  ```rust theme={null}
  use light_token::instruction::CreateMintCpi;

  CreateMintCpi {
      mint_seed: mint_seed.clone(),
      authority: authority.clone(),
      payer: payer.clone(),
      address_tree: address_tree.clone(),
      output_queue: output_queue.clone(),
      compressible_config: compressible_config.clone(),
      mint: mint.clone(),
      rent_sponsor: rent_sponsor.clone(),
      system_accounts,
      cpi_context: None,
      cpi_context_account: None,
      params,
  }
  .invoke()?
  ```

  ```rust title="SPL" theme={null}
  use spl_token::instruction::initialize_mint;

  let ix = initialize_mint(
      &spl_token::id(),
      &mint.pubkey(),
      &mint_authority,
      Some(&freeze_authority),
      decimals,
  )?;

  invoke(&ix, &[mint, rent_sysvar])?;
  ```
</Columns>

<Accordion title="AI prompt">
  <Prompt description="Add create-mint CPI to an Anchor program" actions={["copy", "cursor"]}>
    {`---
        description: Add create-mint CPI to an Anchor program
        allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
        ---

        ## Add create-mint CPI to an Anchor program

        Context:
        - Guide: https://zkcompression.com/light-token/cookbook/create-mint
        - Skills and resources index: https://zkcompression.com/skill.md
        - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
        - Crate: light-token (CreateMintCpi, CreateMintParams, SystemAccountInfos)
        - Example: https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-instructions/create-mint

        Key CPI struct: \`light_token::instruction::CreateMintCpi\`

        ### 1. Index project
        - Grep \`declare_id|#\[program\]|anchor_lang|Account<|Pubkey|invoke|mint|decimals|authority|metadata\` across src/
        - Glob \`**/*.rs\` and \`**/Cargo.toml\` for project structure
        - Identify: program ID, existing instructions, account structs, mint seeds
        - Read Cargo.toml — note existing dependencies and framework version
        - Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel

        ### 2. Read references
        - WebFetch the guide above — review the CPI tab under Program: token metadata config, mint params, system accounts, invoke patterns
        - 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? (add create-mint to existing program, new program from scratch, migrate from SPL create_mint)
        - AskUserQuestion: should the mint seed be an external keypair or a PDA? (determines invoke vs invoke_signed)
        - AskUserQuestion: do you need token metadata (name, symbol, uri)?
        - 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: Configure Token Metadata → Configure Mint Params → System Accounts → Build CPI and invoke
        - 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 if missing: Bash \`cargo add light-token anchor-lang@0.31\`
        - Follow the guide and the approved plan
        - Write/Edit to create or modify files
        - TaskUpdate to mark each step done

        ### 6. Verify
        - Bash \`anchor build\`
        - Bash \`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`}
  </Prompt>

  ```text theme={null}
  ---
  description: Add create-mint CPI to an Anchor program
  allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
  ---

  ## Add create-mint CPI to an Anchor program

  Context:
  - Guide: https://zkcompression.com/light-token/cookbook/create-mint
  - Skills and resources index: https://zkcompression.com/skill.md
  - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
  - Crate: light-token (CreateMintCpi, CreateMintParams, SystemAccountInfos)
  - Example: https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-instructions/create-mint

  Key CPI struct: `light_token::instruction::CreateMintCpi`

  ### 1. Index project
  - Grep `declare_id|#\[program\]|anchor_lang|Account<|Pubkey|invoke|mint|decimals|authority|metadata` across src/
  - Glob `**/*.rs` and `**/Cargo.toml` for project structure
  - Identify: program ID, existing instructions, account structs, mint seeds
  - Read Cargo.toml — note existing dependencies and framework version
  - Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel

  ### 2. Read references
  - WebFetch the guide above — review the CPI tab under Program: token metadata config, mint params, system accounts, invoke patterns
  - 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? (add create-mint to existing program, new program from scratch, migrate from SPL create_mint)
  - AskUserQuestion: should the mint seed be an external keypair or a PDA? (determines invoke vs invoke_signed)
  - AskUserQuestion: do you need token metadata (name, symbol, uri)?
  - 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: Configure Token Metadata → Configure Mint Params → System Accounts → Build CPI and invoke
  - 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 if missing: Bash `cargo add light-token anchor-lang@0.31`
  - Follow the guide and the approved plan
  - Write/Edit to create or modify files
  - TaskUpdate to mark each step done

  ### 6. Verify
  - Bash `anchor build`
  - Bash `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
  ```
</Accordion>

### CreateAssociatedAccountCpi

Create a rent-free associated token account via CPI.

> [Guide](/light-token/cookbook/create-ata) |
> [Example](https://github.com/Lightprotocol/examples-light-token/blob/main/programs/anchor/basic-instructions/create-associated-token-account/src/lib.rs) |
> [Source](https://docs.rs/light-token)

<Columns cols={2}>
  ```rust theme={null}
  use light_token::instruction::CreateAssociatedAccountCpi;

  CreateAssociatedAccountCpi {
      payer: payer.clone(),
      owner: owner.clone(),
      mint: mint.clone(),
      ata: associated_token_account.clone(),
      bump,
  }
  .rent_free(
      compressible_config.clone(),
      rent_sponsor.clone(),
      system_program.clone(),
  )
  .invoke()?
  ```

  ```rust title="SPL" theme={null}
  use spl_associated_token_account::instruction::create_associated_token_account;

  let ix = create_associated_token_account(
      &payer.pubkey(),
      &owner.pubkey(),
      &mint,
      &spl_token::id(),
  );

  invoke(&ix, &[payer, owner, mint])?;
  ```
</Columns>

<Accordion title="AI prompt">
  <Prompt description="Add create-ATA CPI to an Anchor program" actions={["copy", "cursor"]}>
    {`---
        description: Add create-ATA CPI to an Anchor program
        allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
        ---

        ## Add create-ATA CPI to an Anchor program

        Context:
        - Guide: https://zkcompression.com/light-token/cookbook/create-ata
        - Skills and resources index: https://zkcompression.com/skill.md
        - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
        - Crate: light-token (CreateAssociatedAccountCpi)
        - Example: https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-instructions/create-associated-token-account

        Key CPI struct: \`light_token::instruction::CreateAssociatedAccountCpi\`

        ### 1. Index project
        - Grep \`declare_id|#\[program\]|anchor_lang|Account<|Pubkey|invoke|ata|associated|owner|mint\` across src/
        - Glob \`**/*.rs\` and \`**/Cargo.toml\` for project structure
        - Identify: program ID, existing instructions, account structs, ATA derivation
        - Read Cargo.toml — note existing dependencies and framework version
        - Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel

        ### 2. Read references
        - WebFetch the guide above — review the CPI tab under Program: ATA creation with .rent_free() chain
        - 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? (add create-ATA to existing program, new program from scratch, migrate from SPL create_associated_token_account)
        - AskUserQuestion: should the payer be an external signer or a PDA? (determines invoke vs invoke_signed)
        - 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: Build CreateAssociatedAccountCpi → .rent_free() → .invoke() or .invoke_signed()
        - 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 if missing: Bash \`cargo add light-token anchor-lang@0.31\`
        - Follow the guide and the approved plan
        - Write/Edit to create or modify files
        - TaskUpdate to mark each step done

        ### 6. Verify
        - Bash \`anchor build\`
        - Bash \`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`}
  </Prompt>

  ```text theme={null}
  ---
  description: Add create-ATA CPI to an Anchor program
  allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
  ---

  ## Add create-ATA CPI to an Anchor program

  Context:
  - Guide: https://zkcompression.com/light-token/cookbook/create-ata
  - Skills and resources index: https://zkcompression.com/skill.md
  - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
  - Crate: light-token (CreateAssociatedAccountCpi)
  - Example: https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-instructions/create-associated-token-account

  Key CPI struct: `light_token::instruction::CreateAssociatedAccountCpi`

  ### 1. Index project
  - Grep `declare_id|#\[program\]|anchor_lang|Account<|Pubkey|invoke|ata|associated|owner|mint` across src/
  - Glob `**/*.rs` and `**/Cargo.toml` for project structure
  - Identify: program ID, existing instructions, account structs, ATA derivation
  - Read Cargo.toml — note existing dependencies and framework version
  - Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel

  ### 2. Read references
  - WebFetch the guide above — review the CPI tab under Program: ATA creation with .rent_free() chain
  - 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? (add create-ATA to existing program, new program from scratch, migrate from SPL create_associated_token_account)
  - AskUserQuestion: should the payer be an external signer or a PDA? (determines invoke vs invoke_signed)
  - 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: Build CreateAssociatedAccountCpi → .rent_free() → .invoke() or .invoke_signed()
  - 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 if missing: Bash `cargo add light-token anchor-lang@0.31`
  - Follow the guide and the approved plan
  - Write/Edit to create or modify files
  - TaskUpdate to mark each step done

  ### 6. Verify
  - Bash `anchor build`
  - Bash `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
  ```
</Accordion>

### CreateTokenAccountCpi

Create a rent-free token account via CPI.

> [Guide](/light-token/cookbook/create-token-account) |
> [Example](https://github.com/Lightprotocol/examples-light-token/blob/main/programs/anchor/basic-instructions/create-token-account/src/lib.rs) |
> [Source](https://docs.rs/light-token)

<Columns cols={2}>
  ```rust theme={null}
  use light_token::instruction::CreateTokenAccountCpi;

  CreateTokenAccountCpi {
      payer: payer.clone(),
      account: account.clone(),
      mint: mint.clone(),
      owner,
  }
  .rent_free(
      compressible_config.clone(),
      rent_sponsor.clone(),
      system_program.clone(),
      token_program.key,
  )
  .invoke()?
  ```

  ```rust title="SPL" theme={null}
  use spl_token::instruction::initialize_account;

  let ix = initialize_account(
      &spl_token::id(),
      &account,
      &mint,
      &owner,
  )?;

  invoke(&ix, &[account, mint, owner])?;
  ```
</Columns>

<Accordion title="AI prompt">
  <Prompt description="Add create-token-account CPI to an Anchor program" actions={["copy", "cursor"]}>
    {`---
        description: Add create-token-account CPI to an Anchor program
        allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
        ---

        ## Add create-token-account CPI to an Anchor program

        Context:
        - Guide: https://zkcompression.com/light-token/cookbook/create-token-account
        - Skills and resources index: https://zkcompression.com/skill.md
        - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
        - Crate: light-token (CreateTokenAccountCpi)
        - Example: https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-instructions/create-token-account

        Key CPI struct: \`light_token::instruction::CreateTokenAccountCpi\`

        ### 1. Index project
        - Grep \`declare_id|#\[program\]|anchor_lang|Account<|Pubkey|invoke|token_account|vault|owner|mint\` across src/
        - Glob \`**/*.rs\` and \`**/Cargo.toml\` for project structure
        - Identify: program ID, existing instructions, account structs, vault/token account patterns
        - Read Cargo.toml — note existing dependencies and framework version
        - Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel

        ### 2. Read references
        - WebFetch the guide above — review the CPI tab under Program: token account creation with .rent_free() chain
        - 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? (add create-token-account to existing program, new program from scratch, migrate from SPL token account init)
        - AskUserQuestion: should the payer be an external signer or a PDA? (determines invoke vs invoke_signed)
        - 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: Build CreateTokenAccountCpi → .rent_free() → .invoke() or .invoke_signed()
        - 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 if missing: Bash \`cargo add light-token anchor-lang@0.31\`
        - Follow the guide and the approved plan
        - Write/Edit to create or modify files
        - TaskUpdate to mark each step done

        ### 6. Verify
        - Bash \`anchor build\`
        - Bash \`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`}
  </Prompt>

  ```text theme={null}
  ---
  description: Add create-token-account CPI to an Anchor program
  allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
  ---

  ## Add create-token-account CPI to an Anchor program

  Context:
  - Guide: https://zkcompression.com/light-token/cookbook/create-token-account
  - Skills and resources index: https://zkcompression.com/skill.md
  - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
  - Crate: light-token (CreateTokenAccountCpi)
  - Example: https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-instructions/create-token-account

  Key CPI struct: `light_token::instruction::CreateTokenAccountCpi`

  ### 1. Index project
  - Grep `declare_id|#\[program\]|anchor_lang|Account<|Pubkey|invoke|token_account|vault|owner|mint` across src/
  - Glob `**/*.rs` and `**/Cargo.toml` for project structure
  - Identify: program ID, existing instructions, account structs, vault/token account patterns
  - Read Cargo.toml — note existing dependencies and framework version
  - Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel

  ### 2. Read references
  - WebFetch the guide above — review the CPI tab under Program: token account creation with .rent_free() chain
  - 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? (add create-token-account to existing program, new program from scratch, migrate from SPL token account init)
  - AskUserQuestion: should the payer be an external signer or a PDA? (determines invoke vs invoke_signed)
  - 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: Build CreateTokenAccountCpi → .rent_free() → .invoke() or .invoke_signed()
  - 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 if missing: Bash `cargo add light-token anchor-lang@0.31`
  - Follow the guide and the approved plan
  - Write/Edit to create or modify files
  - TaskUpdate to mark each step done

  ### 6. Verify
  - Bash `anchor build`
  - Bash `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
  ```
</Accordion>

### MintToCpi

Mint tokens to a destination account via CPI.

> [Guide](/light-token/cookbook/mint-to) |
> [Example](https://github.com/Lightprotocol/examples-light-token/blob/main/programs/anchor/basic-instructions/mint-to/src/lib.rs) |
> [Source](https://docs.rs/light-token)

<Columns cols={2}>
  ```rust theme={null}
  use light_token::instruction::MintToCpi;

  MintToCpi {
      mint: mint.clone(),
      destination: destination.clone(),
      authority: authority.clone(),
      amount,
      fee_payer: None,
      max_top_up: None,
  }
  .invoke()?
  ```

  ```rust title="SPL" theme={null}
  use spl_token::instruction::mint_to;

  let ix = mint_to(
      &spl_token::id(),
      &mint,
      &destination,
      &mint_authority,
      &[],
      amount,
  )?;

  invoke(&ix, &[mint, destination, authority])?;
  ```
</Columns>

<Accordion title="AI prompt">
  <Prompt description="Add mint-to CPI to an Anchor program" actions={["copy", "cursor"]}>
    {`---
        description: Add mint-to CPI to an Anchor program
        allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
        ---

        ## Add mint-to CPI to an Anchor program

        Context:
        - Guide: https://zkcompression.com/light-token/cookbook/mint-to
        - Skills and resources index: https://zkcompression.com/skill.md
        - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
        - Crate: light-token (MintToCpi)
        - Example: https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-instructions/mint-to

        Key CPI struct: \`light_token::instruction::MintToCpi\`

        ### 1. Index project
        - Grep \`declare_id|#\[program\]|anchor_lang|Account<|Pubkey|invoke|mint|supply|amount\` across src/
        - Glob \`**/*.rs\` and \`**/Cargo.toml\` for project structure
        - Identify: program ID, existing instructions, account structs, mint accounts
        - Read Cargo.toml — note existing dependencies and framework version
        - Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel

        ### 2. Read references
        - WebFetch the guide above — review the Program tab CPI 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? (add mint-to to existing program, new program from scratch, migrate from SPL mint_to)
        - AskUserQuestion: should the authority be an external signer or a PDA? (determines invoke vs invoke_signed)
        - 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: Build MintToCpi struct → call .invoke() or .invoke_signed()
        - 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 if missing: Bash \`cargo add light-token anchor-lang@0.31\`
        - Follow the guide and the approved plan
        - Write/Edit to create or modify files
        - TaskUpdate to mark each step done

        ### 6. Verify
        - Bash \`anchor build\`
        - Bash \`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`}
  </Prompt>

  ```text theme={null}
  ---
  description: Add mint-to CPI to an Anchor program
  allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
  ---

  ## Add mint-to CPI to an Anchor program

  Context:
  - Guide: https://zkcompression.com/light-token/cookbook/mint-to
  - Skills and resources index: https://zkcompression.com/skill.md
  - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
  - Crate: light-token (MintToCpi)
  - Example: https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-instructions/mint-to

  Key CPI struct: `light_token::instruction::MintToCpi`

  ### 1. Index project
  - Grep `declare_id|#\[program\]|anchor_lang|Account<|Pubkey|invoke|mint|supply|amount` across src/
  - Glob `**/*.rs` and `**/Cargo.toml` for project structure
  - Identify: program ID, existing instructions, account structs, mint accounts
  - Read Cargo.toml — note existing dependencies and framework version
  - Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel

  ### 2. Read references
  - WebFetch the guide above — review the Program tab CPI 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? (add mint-to to existing program, new program from scratch, migrate from SPL mint_to)
  - AskUserQuestion: should the authority be an external signer or a PDA? (determines invoke vs invoke_signed)
  - 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: Build MintToCpi struct → call .invoke() or .invoke_signed()
  - 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 if missing: Bash `cargo add light-token anchor-lang@0.31`
  - Follow the guide and the approved plan
  - Write/Edit to create or modify files
  - TaskUpdate to mark each step done

  ### 6. Verify
  - Bash `anchor build`
  - Bash `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
  ```
</Accordion>

### Transfer

Transfer with decimal validation via CPI.

> [Guide](/light-token/cookbook/transfer-interface) |
> [Example](https://github.com/Lightprotocol/examples-light-token/blob/main/programs/anchor/basic-instructions/transfer-checked/src/lib.rs) |
> [Source](https://docs.rs/light-token)

<Columns cols={2}>
  ```rust theme={null}
  use light_token::instruction::TransferCheckedCpi;

  TransferCheckedCpi {
      source: source.clone(),
      destination: destination.clone(),
      mint: mint.clone(),
      authority: authority.clone(),
      amount,
      decimals,
  }
  .invoke()?
  ```

  ```rust title="SPL" theme={null}
  use spl_token::instruction::transfer_checked;

  let ix = transfer_checked(
      &spl_token::id(),
      &source,
      &mint,
      &destination,
      &authority,
      &[],
      amount,
      decimals,
  )?;

  invoke(&ix, &[source, mint, destination, authority])?;
  ```
</Columns>

<Accordion title="AI prompt">
  <Prompt description="Add transfer-checked CPI to an Anchor program" actions={["copy", "cursor"]}>
    {`---
        description: Add transfer-checked CPI to an Anchor program
        allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
        ---

        ## Add transfer-checked CPI to an Anchor program

        Context:
        - Guide: https://zkcompression.com/light-token/cookbook/transfer-checked
        - Skills and resources index: https://zkcompression.com/skill.md
        - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
        - Crate: light-token (TransferCheckedCpi)
        - Example: https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-instructions/transfer-checked

        Key CPI struct: \`light_token::instruction::TransferCheckedCpi\`

        Note: TransferInterface uses TransferChecked under the hood for Light-to-Light transfers.
        Use TransferChecked/TransferCheckedCpi directly only when you need Light-to-Light without interface routing.

        ### 1. Index project
        - Grep \`declare_id|#\[program\]|anchor_lang|Account<|Pubkey|invoke|transfer|decimals|amount\` across src/
        - Glob \`**/*.rs\` and \`**/Cargo.toml\` for project structure
        - Identify: program ID, existing instructions, account structs, token accounts
        - Read Cargo.toml — note existing dependencies and framework version
        - Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel

        ### 2. Read references
        - WebFetch the guide above — review the Program tab CPI 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? (add transfer-checked to existing program, new program from scratch, migrate from SPL transfer_checked)
        - AskUserQuestion: should the authority be an external signer or a PDA? (determines invoke vs invoke_signed)
        - 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: Build TransferCheckedCpi struct → call .invoke() or .invoke_signed()
        - 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 if missing: Bash \`cargo add light-token anchor-lang@0.31\`
        - Follow the guide and the approved plan
        - Write/Edit to create or modify files
        - TaskUpdate to mark each step done

        ### 6. Verify
        - Bash \`anchor build\`
        - Bash \`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`}
  </Prompt>

  ```text theme={null}
  ---
  description: Add transfer-checked CPI to an Anchor program
  allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
  ---

  ## Add transfer-checked CPI to an Anchor program

  Context:
  - Guide: https://zkcompression.com/light-token/cookbook/transfer-checked
  - Skills and resources index: https://zkcompression.com/skill.md
  - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
  - Crate: light-token (TransferCheckedCpi)
  - Example: https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-instructions/transfer-checked

  Key CPI struct: `light_token::instruction::TransferCheckedCpi`

  Note: TransferInterface uses TransferChecked under the hood for Light-to-Light transfers.
  Use TransferChecked/TransferCheckedCpi directly only when you need Light-to-Light without interface routing.

  ### 1. Index project
  - Grep `declare_id|#\[program\]|anchor_lang|Account<|Pubkey|invoke|transfer|decimals|amount` across src/
  - Glob `**/*.rs` and `**/Cargo.toml` for project structure
  - Identify: program ID, existing instructions, account structs, token accounts
  - Read Cargo.toml — note existing dependencies and framework version
  - Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel

  ### 2. Read references
  - WebFetch the guide above — review the Program tab CPI 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? (add transfer-checked to existing program, new program from scratch, migrate from SPL transfer_checked)
  - AskUserQuestion: should the authority be an external signer or a PDA? (determines invoke vs invoke_signed)
  - 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: Build TransferCheckedCpi struct → call .invoke() or .invoke_signed()
  - 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 if missing: Bash `cargo add light-token anchor-lang@0.31`
  - Follow the guide and the approved plan
  - Write/Edit to create or modify files
  - TaskUpdate to mark each step done

  ### 6. Verify
  - Bash `anchor build`
  - Bash `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
  ```
</Accordion>

### TransferInterfaceCpi

Transfer tokens across SPL, Token 2022, and Light Token accounts via CPI. The interface auto-detects the token type and routes to the correct program.

> [Guide](/light-token/cookbook/transfer-interface) |
> [Example](https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-instructions/transfer-interface) |
> [Source](https://docs.rs/light-token)

<Columns cols={2}>
  ```rust title="Light" theme={null}
  use light_token::instruction::TransferInterfaceCpi;

  TransferInterfaceCpi::new(
      amount,
      decimals,
      source.clone(),
      destination.clone(),
      authority.clone(),
      payer.clone(),
      light_token_authority.clone(),
      system_program.clone(),
  )
  .invoke()?;
  ```

  ```rust title="SPL" theme={null}
  use spl_token::instruction::transfer_checked;

  let ix = transfer_checked(
      &spl_token::id(),
      &source,
      &mint,
      &destination,
      &authority,
      &[],
      amount,
      decimals,
  )?;

  invoke(&ix, &[source, mint, destination, authority])?;
  ```
</Columns>

<Accordion title="AI prompt">
  <Prompt description="Add transfer-interface CPI to an Anchor program" actions={["copy", "cursor"]}>
    {`---
        description: Add transfer-interface CPI to an Anchor program
        allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
        ---

        ## Add transfer-interface CPI to an Anchor program

        Context:
        - Guide: https://zkcompression.com/light-token/cookbook/transfer-interface
        - Skills and resources index: https://zkcompression.com/skill.md
        - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
        - Crate: light-token (TransferInterfaceCpi)
        - Example: https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-instructions/transfer-interface

        Key CPI struct: \`light_token::instruction::TransferInterfaceCpi\`

        ### 1. Index project
        - Grep \`declare_id|#\[program\]|anchor_lang|Account<|Pubkey|invoke|transfer|decimals|interface\` across src/
        - Glob \`**/*.rs\` and \`**/Cargo.toml\` for project structure
        - Identify: program ID, existing instructions, account structs, token accounts
        - Read Cargo.toml — note existing dependencies and framework version
        - Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel

        ### 2. Read references
        - WebFetch the guide above — review the Program tab CPI 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? (add transfer-interface to existing program, new program from scratch, migrate from SPL transfer)
        - AskUserQuestion: should the authority be an external signer or a PDA? (determines invoke vs invoke_signed)
        - AskUserQuestion: which token types will be transferred? (SPL, Token 2022, Light Token, or all via interface)
        - 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: Build TransferInterfaceCpi → call .invoke() or .invoke_signed()
        - 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 if missing: Bash \`cargo add light-token anchor-lang@0.31\`
        - Follow the guide and the approved plan
        - Write/Edit to create or modify files
        - TaskUpdate to mark each step done

        ### 6. Verify
        - Bash \`anchor build\`
        - Bash \`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`}
  </Prompt>

  ```text theme={null}
  ---
  description: Add transfer-interface CPI to an Anchor program
  allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
  ---

  ## Add transfer-interface CPI to an Anchor program

  Context:
  - Guide: https://zkcompression.com/light-token/cookbook/transfer-interface
  - Skills and resources index: https://zkcompression.com/skill.md
  - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
  - Crate: light-token (TransferInterfaceCpi)
  - Example: https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-instructions/transfer-interface

  Key CPI struct: `light_token::instruction::TransferInterfaceCpi`

  ### 1. Index project
  - Grep `declare_id|#\[program\]|anchor_lang|Account<|Pubkey|invoke|transfer|decimals|interface` across src/
  - Glob `**/*.rs` and `**/Cargo.toml` for project structure
  - Identify: program ID, existing instructions, account structs, token accounts
  - Read Cargo.toml — note existing dependencies and framework version
  - Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel

  ### 2. Read references
  - WebFetch the guide above — review the Program tab CPI 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? (add transfer-interface to existing program, new program from scratch, migrate from SPL transfer)
  - AskUserQuestion: should the authority be an external signer or a PDA? (determines invoke vs invoke_signed)
  - AskUserQuestion: which token types will be transferred? (SPL, Token 2022, Light Token, or all via interface)
  - 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: Build TransferInterfaceCpi → call .invoke() or .invoke_signed()
  - 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 if missing: Bash `cargo add light-token anchor-lang@0.31`
  - Follow the guide and the approved plan
  - Write/Edit to create or modify files
  - TaskUpdate to mark each step done

  ### 6. Verify
  - Bash `anchor build`
  - Bash `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
  ```
</Accordion>

### BurnCpi

Burn tokens via CPI.

> [Guide](/light-token/cookbook/burn) |
> [Example](https://github.com/Lightprotocol/examples-light-token/blob/main/programs/anchor/basic-instructions/burn/src/lib.rs) |
> [Source](https://docs.rs/light-token)

<Columns cols={2}>
  ```rust theme={null}
  use light_token::instruction::BurnCpi;

  BurnCpi {
      source: source.clone(),
      mint: mint.clone(),
      authority: authority.clone(),
      amount,
  }
  .invoke()?
  ```

  ```rust title="SPL" theme={null}
  use spl_token::instruction::burn;

  let ix = burn(
      &spl_token::id(),
      &source,
      &mint,
      &authority,
      &[],
      amount,
  )?;

  invoke(&ix, &[source, mint, authority])?;
  ```
</Columns>

<Accordion title="AI prompt">
  <Prompt description="Add burn CPI to an Anchor program" actions={["copy", "cursor"]}>
    {`---
        description: Add burn CPI to an Anchor program
        allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
        ---

        ## Add burn CPI to an Anchor program

        Context:
        - Guide: https://zkcompression.com/light-token/cookbook/burn
        - Skills and resources index: https://zkcompression.com/skill.md
        - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
        - Crate: light-token (BurnCpi)
        - Example: https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-instructions/burn

        Key CPI struct: \`light_token::instruction::BurnCpi\`

        ### 1. Index project
        - Grep \`declare_id|#\[program\]|anchor_lang|Account<|Pubkey|invoke|burn|destroy|supply\` across src/
        - Glob \`**/*.rs\` and \`**/Cargo.toml\` for project structure
        - Identify: program ID, existing instructions, account structs, token accounts
        - Read Cargo.toml — note existing dependencies and framework version
        - Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel

        ### 2. Read references
        - WebFetch the guide above — review the Program tab CPI 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? (add burn to existing program, new program from scratch, migrate from SPL burn)
        - AskUserQuestion: should the authority be an external signer or a PDA? (determines invoke vs invoke_signed)
        - 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: Build BurnCpi struct → call .invoke() or .invoke_signed()
        - 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 if missing: Bash \`cargo add light-token anchor-lang@0.31\`
        - Follow the guide and the approved plan
        - Write/Edit to create or modify files
        - TaskUpdate to mark each step done

        ### 6. Verify
        - Bash \`anchor build\`
        - Bash \`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`}
  </Prompt>

  ```text theme={null}
  ---
  description: Add burn CPI to an Anchor program
  allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
  ---

  ## Add burn CPI to an Anchor program

  Context:
  - Guide: https://zkcompression.com/light-token/cookbook/burn
  - Skills and resources index: https://zkcompression.com/skill.md
  - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
  - Crate: light-token (BurnCpi)
  - Example: https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-instructions/burn

  Key CPI struct: `light_token::instruction::BurnCpi`

  ### 1. Index project
  - Grep `declare_id|#\[program\]|anchor_lang|Account<|Pubkey|invoke|burn|destroy|supply` across src/
  - Glob `**/*.rs` and `**/Cargo.toml` for project structure
  - Identify: program ID, existing instructions, account structs, token accounts
  - Read Cargo.toml — note existing dependencies and framework version
  - Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel

  ### 2. Read references
  - WebFetch the guide above — review the Program tab CPI 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? (add burn to existing program, new program from scratch, migrate from SPL burn)
  - AskUserQuestion: should the authority be an external signer or a PDA? (determines invoke vs invoke_signed)
  - 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: Build BurnCpi struct → call .invoke() or .invoke_signed()
  - 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 if missing: Bash `cargo add light-token anchor-lang@0.31`
  - Follow the guide and the approved plan
  - Write/Edit to create or modify files
  - TaskUpdate to mark each step done

  ### 6. Verify
  - Bash `anchor build`
  - Bash `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
  ```
</Accordion>

### FreezeCpi and ThawCpi

Freeze or thaw a token account via CPI.

> [Guide](/light-token/cookbook/freeze-thaw) |
> [Example (freeze)](https://github.com/Lightprotocol/examples-light-token/blob/main/programs/anchor/basic-instructions/freeze/src/lib.rs) |
> [Example (thaw)](https://github.com/Lightprotocol/examples-light-token/blob/main/programs/anchor/basic-instructions/thaw/src/lib.rs) |
> [Source](https://docs.rs/light-token)

<Columns cols={2}>
  <div>
    ```rust theme={null}
    use light_token::instruction::FreezeCpi;

    FreezeCpi {
        token_account: token_account.clone(),
        mint: mint.clone(),
        freeze_authority: freeze_authority.clone(),
    }
    .invoke()?
    ```

    ```rust theme={null}
    use light_token::instruction::ThawCpi;

    ThawCpi {
        token_account: token_account.clone(),
        mint: mint.clone(),
        freeze_authority: freeze_authority.clone(),
    }
    .invoke()?
    ```
  </div>

  ```rust title="SPL" theme={null}
  use spl_token::instruction::{freeze_account, thaw_account};

  let ix = freeze_account(
      &spl_token::id(), &account, &mint, &freeze_authority, &[],
  )?;
  invoke(&ix, &[account, mint, freeze_authority])?;

  let ix = thaw_account(
      &spl_token::id(), &account, &mint, &freeze_authority, &[],
  )?;
  invoke(&ix, &[account, mint, freeze_authority])?;
  ```
</Columns>

<Accordion title="AI prompt">
  <Prompt description="Add freeze and thaw CPI to an Anchor program" actions={["copy", "cursor"]}>
    {`---
        description: Add freeze and thaw CPI to an Anchor program
        allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
        ---

        ## Add freeze and thaw CPI to an Anchor program

        Context:
        - Guide: https://zkcompression.com/light-token/cookbook/freeze-thaw
        - Skills and resources index: https://zkcompression.com/skill.md
        - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
        - Crate: light-token (FreezeCpi, ThawCpi)
        - Example: https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-instructions/freeze

        Key CPI structs: \`light_token::instruction::FreezeCpi\`, \`light_token::instruction::ThawCpi\`

        ### 1. Index project
        - Grep \`declare_id|#\[program\]|anchor_lang|Account<|Pubkey|invoke|freeze|thaw|authority\` across src/
        - Glob \`**/*.rs\` and \`**/Cargo.toml\` for project structure
        - Identify: program ID, existing instructions, account structs, freeze authority
        - Read Cargo.toml — note existing dependencies and framework version
        - Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel

        ### 2. Read references
        - WebFetch the guide above — review both Freeze and Thaw CPI 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? (add freeze/thaw to existing program, new program from scratch, migrate from SPL freeze/thaw)
        - AskUserQuestion: should the freeze authority be an external signer or a PDA? (determines invoke vs invoke_signed)
        - AskUserQuestion: do you need both freeze and thaw, or just 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: Build FreezeCpi/ThawCpi structs → call .invoke() or .invoke_signed()
        - 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 if missing: Bash \`cargo add light-token anchor-lang@0.31\`
        - Follow the guide and the approved plan
        - Write/Edit to create or modify files
        - TaskUpdate to mark each step done

        ### 6. Verify
        - Bash \`anchor build\`
        - Bash \`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`}
  </Prompt>

  ```text theme={null}
  ---
  description: Add freeze and thaw CPI to an Anchor program
  allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
  ---

  ## Add freeze and thaw CPI to an Anchor program

  Context:
  - Guide: https://zkcompression.com/light-token/cookbook/freeze-thaw
  - Skills and resources index: https://zkcompression.com/skill.md
  - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
  - Crate: light-token (FreezeCpi, ThawCpi)
  - Example: https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-instructions/freeze

  Key CPI structs: `light_token::instruction::FreezeCpi`, `light_token::instruction::ThawCpi`

  ### 1. Index project
  - Grep `declare_id|#\[program\]|anchor_lang|Account<|Pubkey|invoke|freeze|thaw|authority` across src/
  - Glob `**/*.rs` and `**/Cargo.toml` for project structure
  - Identify: program ID, existing instructions, account structs, freeze authority
  - Read Cargo.toml — note existing dependencies and framework version
  - Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel

  ### 2. Read references
  - WebFetch the guide above — review both Freeze and Thaw CPI 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? (add freeze/thaw to existing program, new program from scratch, migrate from SPL freeze/thaw)
  - AskUserQuestion: should the freeze authority be an external signer or a PDA? (determines invoke vs invoke_signed)
  - AskUserQuestion: do you need both freeze and thaw, or just 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: Build FreezeCpi/ThawCpi structs → call .invoke() or .invoke_signed()
  - 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 if missing: Bash `cargo add light-token anchor-lang@0.31`
  - Follow the guide and the approved plan
  - Write/Edit to create or modify files
  - TaskUpdate to mark each step done

  ### 6. Verify
  - Bash `anchor build`
  - Bash `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
  ```
</Accordion>

### ApproveCpi and RevokeCpi

Approve a delegate or revoke permissions via CPI.

> [Guide](/light-token/cookbook/approve-revoke) |
> [Example (approve)](https://github.com/Lightprotocol/examples-light-token/blob/main/programs/anchor/basic-instructions/approve/src/lib.rs) |
> [Example (revoke)](https://github.com/Lightprotocol/examples-light-token/blob/main/programs/anchor/basic-instructions/revoke/src/lib.rs) |
> [Source](https://docs.rs/light-token)

<Columns cols={2}>
  <div>
    ```rust theme={null}
    use light_token::instruction::ApproveCpi;

    ApproveCpi {
        token_account: token_account.clone(),
        delegate: delegate.clone(),
        owner: owner.clone(),
        amount,
    }
    .invoke()?
    ```

    ```rust theme={null}
    use light_token::instruction::RevokeCpi;

    RevokeCpi {
        token_account: token_account.clone(),
        owner: owner.clone(),
    }
    .invoke()?
    ```
  </div>

  ```rust title="SPL" theme={null}
  use spl_token::instruction::{approve, revoke};

  let ix = approve(
      &spl_token::id(), &source, &delegate, &owner, &[], amount,
  )?;
  invoke(&ix, &[source, delegate, owner])?;

  let ix = revoke(
      &spl_token::id(), &source, &owner, &[],
  )?;
  invoke(&ix, &[source, owner])?;
  ```
</Columns>

<Accordion title="AI prompt">
  <Prompt description="Add approve and revoke CPI to an Anchor program" actions={["copy", "cursor"]}>
    {`---
        description: Add approve and revoke CPI to an Anchor program
        allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
        ---

        ## Add approve and revoke CPI to an Anchor program

        Context:
        - Guide: https://zkcompression.com/light-token/cookbook/approve-revoke
        - Skills and resources index: https://zkcompression.com/skill.md
        - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
        - Crate: light-token (ApproveCpi, RevokeCpi)
        - Example: https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-instructions/approve

        Key CPI structs: \`light_token::instruction::ApproveCpi\`, \`light_token::instruction::RevokeCpi\`

        ### 1. Index project
        - Grep \`declare_id|#\[program\]|anchor_lang|Account<|Pubkey|invoke|approve|revoke|delegate\` across src/
        - Glob \`**/*.rs\` and \`**/Cargo.toml\` for project structure
        - Identify: program ID, existing instructions, account structs, delegate accounts
        - Read Cargo.toml — note existing dependencies and framework version
        - Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel

        ### 2. Read references
        - WebFetch the guide above — review both Approve and Revoke CPI 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? (add approve/revoke to existing program, new program from scratch, migrate from SPL approve/revoke)
        - AskUserQuestion: should the owner be an external signer or a PDA? (determines invoke vs invoke_signed)
        - AskUserQuestion: do you need both approve and revoke, or just 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: Build ApproveCpi/RevokeCpi structs → call .invoke() or .invoke_signed()
        - 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 if missing: Bash \`cargo add light-token anchor-lang@0.31\`
        - Follow the guide and the approved plan
        - Write/Edit to create or modify files
        - TaskUpdate to mark each step done

        ### 6. Verify
        - Bash \`anchor build\`
        - Bash \`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`}
  </Prompt>

  ```text theme={null}
  ---
  description: Add approve and revoke CPI to an Anchor program
  allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
  ---

  ## Add approve and revoke CPI to an Anchor program

  Context:
  - Guide: https://zkcompression.com/light-token/cookbook/approve-revoke
  - Skills and resources index: https://zkcompression.com/skill.md
  - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
  - Crate: light-token (ApproveCpi, RevokeCpi)
  - Example: https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-instructions/approve

  Key CPI structs: `light_token::instruction::ApproveCpi`, `light_token::instruction::RevokeCpi`

  ### 1. Index project
  - Grep `declare_id|#\[program\]|anchor_lang|Account<|Pubkey|invoke|approve|revoke|delegate` across src/
  - Glob `**/*.rs` and `**/Cargo.toml` for project structure
  - Identify: program ID, existing instructions, account structs, delegate accounts
  - Read Cargo.toml — note existing dependencies and framework version
  - Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel

  ### 2. Read references
  - WebFetch the guide above — review both Approve and Revoke CPI 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? (add approve/revoke to existing program, new program from scratch, migrate from SPL approve/revoke)
  - AskUserQuestion: should the owner be an external signer or a PDA? (determines invoke vs invoke_signed)
  - AskUserQuestion: do you need both approve and revoke, or just 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: Build ApproveCpi/RevokeCpi structs → call .invoke() or .invoke_signed()
  - 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 if missing: Bash `cargo add light-token anchor-lang@0.31`
  - Follow the guide and the approved plan
  - Write/Edit to create or modify files
  - TaskUpdate to mark each step done

  ### 6. Verify
  - Bash `anchor build`
  - Bash `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
  ```
</Accordion>

### CloseAccountCpi

Close a token account and reclaim lamports via CPI.

> [Guide](/light-token/cookbook/close-token-account) |
> [Example](https://github.com/Lightprotocol/examples-light-token/blob/main/programs/anchor/basic-instructions/close/src/lib.rs) |
> [Source](https://docs.rs/light-token)

<Columns cols={2}>
  ```rust theme={null}
  use light_token::instruction::CloseAccountCpi;

  CloseAccountCpi {
      account: account.clone(),
      destination: destination.clone(),
      authority: authority.clone(),
  }
  .invoke()?
  ```

  ```rust title="SPL" theme={null}
  use spl_token::instruction::close_account;

  let ix = close_account(
      &spl_token::id(), &account, &destination, &owner, &[],
  )?;
  invoke(&ix, &[account, destination, owner])?;
  ```
</Columns>

<Accordion title="AI prompt">
  <Prompt description="Add close-account CPI to an Anchor program" actions={["copy", "cursor"]}>
    {`---
        description: Add close-account CPI to an Anchor program
        allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
        ---

        ## Add close-account CPI to an Anchor program

        Context:
        - Guide: https://zkcompression.com/light-token/cookbook/close-token-account
        - Skills and resources index: https://zkcompression.com/skill.md
        - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
        - Crate: light-token (CloseAccountCpi)
        - Example: https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-instructions/close

        Key CPI struct: \`light_token::instruction::CloseAccountCpi\`

        ### 1. Index project
        - Grep \`declare_id|#\[program\]|anchor_lang|Account<|Pubkey|invoke|close|destination|rent\` across src/
        - Glob \`**/*.rs\` and \`**/Cargo.toml\` for project structure
        - Identify: program ID, existing instructions, account structs, token accounts
        - Read Cargo.toml — note existing dependencies and framework version
        - Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel

        ### 2. Read references
        - WebFetch the guide above — review the Program tab CPI 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? (add close-account to existing program, new program from scratch, migrate from SPL close_account)
        - AskUserQuestion: should the owner be an external signer or a PDA? (determines invoke vs invoke_signed)
        - 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: Build CloseAccountCpi struct → call .invoke() or .invoke_signed()
        - 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 if missing: Bash \`cargo add light-token anchor-lang@0.31\`
        - Follow the guide and the approved plan
        - Write/Edit to create or modify files
        - TaskUpdate to mark each step done

        ### 6. Verify
        - Bash \`anchor build\`
        - Bash \`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`}
  </Prompt>

  ```text theme={null}
  ---
  description: Add close-account CPI to an Anchor program
  allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
  ---

  ## Add close-account CPI to an Anchor program

  Context:
  - Guide: https://zkcompression.com/light-token/cookbook/close-token-account
  - Skills and resources index: https://zkcompression.com/skill.md
  - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
  - Crate: light-token (CloseAccountCpi)
  - Example: https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-instructions/close

  Key CPI struct: `light_token::instruction::CloseAccountCpi`

  ### 1. Index project
  - Grep `declare_id|#\[program\]|anchor_lang|Account<|Pubkey|invoke|close|destination|rent` across src/
  - Glob `**/*.rs` and `**/Cargo.toml` for project structure
  - Identify: program ID, existing instructions, account structs, token accounts
  - Read Cargo.toml — note existing dependencies and framework version
  - Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel

  ### 2. Read references
  - WebFetch the guide above — review the Program tab CPI 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? (add close-account to existing program, new program from scratch, migrate from SPL close_account)
  - AskUserQuestion: should the owner be an external signer or a PDA? (determines invoke vs invoke_signed)
  - 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: Build CloseAccountCpi struct → call .invoke() or .invoke_signed()
  - 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 if missing: Bash `cargo add light-token anchor-lang@0.31`
  - Follow the guide and the approved plan
  - Write/Edit to create or modify files
  - TaskUpdate to mark each step done

  ### 6. Verify
  - Bash `anchor build`
  - Bash `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
  ```
</Accordion>

***

## Anchor macros

`#[light_account(...)]` replaces `#[account(...)]` for rent-free account initialization. Add `#[light_program]` above `#[program]` to enable compression.

### Create mint

> [Guide](/light-token/cookbook/create-mint) |
> [Example](https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-macros/create-mint) |
> [Source](https://docs.rs/light-token)

<Columns cols={2}>
  ```rust theme={null}
  #[light_account(init,
      mint::signer = mint_signer,
      mint::authority = fee_payer,
      mint::decimals = 9,
      mint::seeds = &[MINT_SIGNER_SEED, self.authority.to_account_info().key.as_ref()],
      mint::bump = params.mint_signer_bump
  )]
  pub mint: UncheckedAccount<'info>,
  ```

  ```rust title="Anchor" theme={null}
  #[account(
      init,
      payer = fee_payer,
      mint::decimals = 9,
      mint::authority = fee_payer,
  )]
  pub mint: InterfaceAccount<'info, Mint>,
  ```
</Columns>

<Accordion title="AI prompt">
  <Prompt description="Create a rent-free mint with Anchor macros" actions={["copy", "cursor"]}>
    {`---
        description: Create a rent-free mint with Anchor macros
        allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
        ---

        ## Create a rent-free mint with Anchor macros

        Context:
        - Guide: https://zkcompression.com/light-token/cookbook/create-mint
        - Skills and resources index: https://zkcompression.com/skill.md
        - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
        - Crates: light-sdk, light-sdk-macros, light-compressible, anchor-lang
        - Example: https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-macros/create-mint

        Key macros: \`#[light_program]\`, \`LightAccounts\`, \`#[light_account(init, mint::...)]\`

        ### 1. Index project
        - Grep \`#\[program\]|anchor_lang|Account<|Accounts|seeds|init|payer|mint\` across src/
        - Glob \`**/*.rs\` and \`**/Cargo.toml\` for project structure
        - Identify: existing program module, account structs, mint patterns, PDA seeds
        - Read Cargo.toml — note existing dependencies and framework version
        - Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel

        ### 2. Read references
        - WebFetch the guide above — review the Anchor Macros tab under Program
        - 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 rent-free mint to existing program, migrate from SPL create_mint)
        - AskUserQuestion: do you need token metadata (name, symbol, uri)?
        - Summarize findings and wait for user confirmation before implementing

        ### 4. Create plan
        - Based on steps 1–3, draft an implementation plan
        - Follow the guide's step order: Dependencies → Program Module (#[light_program]) → Accounts Struct (#[light_account(init, mint::...)])
        - 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 if missing: Bash \`cargo add light-sdk@0.23 --features anchor,v2,cpi-context\` and \`cargo add light-sdk-macros@0.23 light-compressible@0.6 anchor-lang@0.31\`
        - Follow the guide and the approved plan
        - Write/Edit to create or modify files
        - TaskUpdate to mark each step done

        ### 6. Verify
        - Bash \`anchor build\`
        - Bash \`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`}
  </Prompt>

  ```text theme={null}
  ---
  description: Create a rent-free mint with Anchor macros
  allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
  ---

  ## Create a rent-free mint with Anchor macros

  Context:
  - Guide: https://zkcompression.com/light-token/cookbook/create-mint
  - Skills and resources index: https://zkcompression.com/skill.md
  - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
  - Crates: light-sdk, light-sdk-macros, light-compressible, anchor-lang
  - Example: https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-macros/create-mint

  Key macros: `#[light_program]`, `LightAccounts`, `#[light_account(init, mint::...)]`

  ### 1. Index project
  - Grep `#\[program\]|anchor_lang|Account<|Accounts|seeds|init|payer|mint` across src/
  - Glob `**/*.rs` and `**/Cargo.toml` for project structure
  - Identify: existing program module, account structs, mint patterns, PDA seeds
  - Read Cargo.toml — note existing dependencies and framework version
  - Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel

  ### 2. Read references
  - WebFetch the guide above — review the Anchor Macros tab under Program
  - 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 rent-free mint to existing program, migrate from SPL create_mint)
  - AskUserQuestion: do you need token metadata (name, symbol, uri)?
  - Summarize findings and wait for user confirmation before implementing

  ### 4. Create plan
  - Based on steps 1–3, draft an implementation plan
  - Follow the guide's step order: Dependencies → Program Module (#[light_program]) → Accounts Struct (#[light_account(init, mint::...)])
  - 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 if missing: Bash `cargo add light-sdk@0.23 --features anchor,v2,cpi-context` and `cargo add light-sdk-macros@0.23 light-compressible@0.6 anchor-lang@0.31`
  - Follow the guide and the approved plan
  - Write/Edit to create or modify files
  - TaskUpdate to mark each step done

  ### 6. Verify
  - Bash `anchor build`
  - Bash `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
  ```
</Accordion>

### Create mint with metadata

Metadata fields are declared inline instead of requiring a separate CPI.

> [Guide](/light-token/cookbook/create-mint) |
> [Example](https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-macros/create-mint) |
> [Source](https://docs.rs/light-token)

<Columns cols={2}>
  ```rust theme={null}
  #[light_account(init,
      mint::signer = mint_signer,
      mint::authority = fee_payer,
      mint::decimals = 9,
      mint::seeds = &[MINT_SIGNER_SEED, self.authority.to_account_info().key.as_ref()],
      mint::bump = params.mint_signer_bump,
      mint::name = params.name.clone(),
      mint::symbol = params.symbol.clone(),
      mint::uri = params.uri.clone(),
      mint::update_authority = authority
  )]
  pub mint: UncheckedAccount<'info>,
  ```

  ```rust title="Anchor" theme={null}
  #[account(
      init,
      payer = fee_payer,
      mint::decimals = 9,
      mint::authority = fee_payer,
      extensions::metadata_pointer::authority = fee_payer,
      extensions::metadata_pointer::metadata_address = mint_account,
  )]
  pub mint_account: InterfaceAccount<'info, Mint>,

  // Metadata requires a separate CPI:
  token_metadata_initialize(
      cpi_ctx,
      params.name,
      params.symbol,
      params.uri,
  )?;
  ```
</Columns>

<Accordion title="AI prompt">
  <Prompt description="Create a rent-free mint with Anchor macros" actions={["copy", "cursor"]}>
    {`---
        description: Create a rent-free mint with Anchor macros
        allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
        ---

        ## Create a rent-free mint with Anchor macros

        Context:
        - Guide: https://zkcompression.com/light-token/cookbook/create-mint
        - Skills and resources index: https://zkcompression.com/skill.md
        - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
        - Crates: light-sdk, light-sdk-macros, light-compressible, anchor-lang
        - Example: https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-macros/create-mint

        Key macros: \`#[light_program]\`, \`LightAccounts\`, \`#[light_account(init, mint::...)]\`

        ### 1. Index project
        - Grep \`#\[program\]|anchor_lang|Account<|Accounts|seeds|init|payer|mint\` across src/
        - Glob \`**/*.rs\` and \`**/Cargo.toml\` for project structure
        - Identify: existing program module, account structs, mint patterns, PDA seeds
        - Read Cargo.toml — note existing dependencies and framework version
        - Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel

        ### 2. Read references
        - WebFetch the guide above — review the Anchor Macros tab under Program
        - 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 rent-free mint to existing program, migrate from SPL create_mint)
        - AskUserQuestion: do you need token metadata (name, symbol, uri)?
        - Summarize findings and wait for user confirmation before implementing

        ### 4. Create plan
        - Based on steps 1–3, draft an implementation plan
        - Follow the guide's step order: Dependencies → Program Module (#[light_program]) → Accounts Struct (#[light_account(init, mint::...)])
        - 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 if missing: Bash \`cargo add light-sdk@0.23 --features anchor,v2,cpi-context\` and \`cargo add light-sdk-macros@0.23 light-compressible@0.6 anchor-lang@0.31\`
        - Follow the guide and the approved plan
        - Write/Edit to create or modify files
        - TaskUpdate to mark each step done

        ### 6. Verify
        - Bash \`anchor build\`
        - Bash \`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`}
  </Prompt>

  ```text theme={null}
  ---
  description: Create a rent-free mint with Anchor macros
  allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
  ---

  ## Create a rent-free mint with Anchor macros

  Context:
  - Guide: https://zkcompression.com/light-token/cookbook/create-mint
  - Skills and resources index: https://zkcompression.com/skill.md
  - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
  - Crates: light-sdk, light-sdk-macros, light-compressible, anchor-lang
  - Example: https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-macros/create-mint

  Key macros: `#[light_program]`, `LightAccounts`, `#[light_account(init, mint::...)]`

  ### 1. Index project
  - Grep `#\[program\]|anchor_lang|Account<|Accounts|seeds|init|payer|mint` across src/
  - Glob `**/*.rs` and `**/Cargo.toml` for project structure
  - Identify: existing program module, account structs, mint patterns, PDA seeds
  - Read Cargo.toml — note existing dependencies and framework version
  - Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel

  ### 2. Read references
  - WebFetch the guide above — review the Anchor Macros tab under Program
  - 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 rent-free mint to existing program, migrate from SPL create_mint)
  - AskUserQuestion: do you need token metadata (name, symbol, uri)?
  - Summarize findings and wait for user confirmation before implementing

  ### 4. Create plan
  - Based on steps 1–3, draft an implementation plan
  - Follow the guide's step order: Dependencies → Program Module (#[light_program]) → Accounts Struct (#[light_account(init, mint::...)])
  - 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 if missing: Bash `cargo add light-sdk@0.23 --features anchor,v2,cpi-context` and `cargo add light-sdk-macros@0.23 light-compressible@0.6 anchor-lang@0.31`
  - Follow the guide and the approved plan
  - Write/Edit to create or modify files
  - TaskUpdate to mark each step done

  ### 6. Verify
  - Bash `anchor build`
  - Bash `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
  ```
</Accordion>

### Create associated token account

> [Guide](/light-token/cookbook/create-ata) |
> [Example](https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-macros/create-associated-token-account) |
> [Source](https://docs.rs/light-token)

<Columns cols={2}>
  ```rust theme={null}
  #[light_account(
      init,
      associated_token::authority = ata_owner,
      associated_token::mint = ata_mint,
      associated_token::bump = params.ata_bump
  )]
  pub ata: UncheckedAccount<'info>,
  ```

  ```rust title="Anchor" theme={null}
  #[account(
      init,
      payer = fee_payer,
      associated_token::mint = mint,
      associated_token::authority = owner,
  )]
  pub ata: Account<'info, TokenAccount>,
  ```
</Columns>

<Accordion title="AI prompt">
  <Prompt description="Create a rent-free ATA with Anchor macros" actions={["copy", "cursor"]}>
    {`---
        description: Create a rent-free ATA with Anchor macros
        allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
        ---

        ## Create a rent-free ATA with Anchor macros

        Context:
        - Guide: https://zkcompression.com/light-token/cookbook/create-ata
        - Skills and resources index: https://zkcompression.com/skill.md
        - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
        - Crates: light-sdk, light-sdk-macros, light-compressible, anchor-lang
        - Example: https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-macros/create-associated-token-account

        Key macros: \`#[light_program]\`, \`LightAccounts\`, \`#[light_account(init, associated_token::...)]\`

        ### 1. Index project
        - Grep \`#\[program\]|anchor_lang|Account<|Accounts|seeds|init|payer|ata|associated\` across src/
        - Glob \`**/*.rs\` and \`**/Cargo.toml\` for project structure
        - Identify: existing program module, account structs, ATA patterns
        - Read Cargo.toml — note existing dependencies and framework version
        - Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel

        ### 2. Read references
        - WebFetch the guide above — review the Anchor Macros tab under Program
        - 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 rent-free ATA to existing program, migrate from SPL create_associated_token_account)
        - Summarize findings and wait for user confirmation before implementing

        ### 4. Create plan
        - Based on steps 1–3, draft an implementation plan
        - Follow the guide's step order: Dependencies → Program Module (#[light_program]) → Accounts Struct (#[light_account(init, associated_token::...)])
        - 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 if missing: Bash \`cargo add light-sdk@0.23 --features anchor,v2,cpi-context\` and \`cargo add light-sdk-macros@0.23 light-compressible@0.6 anchor-lang@0.31\`
        - Follow the guide and the approved plan
        - Write/Edit to create or modify files
        - TaskUpdate to mark each step done

        ### 6. Verify
        - Bash \`anchor build\`
        - Bash \`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`}
  </Prompt>

  ```text theme={null}
  ---
  description: Create a rent-free ATA with Anchor macros
  allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
  ---

  ## Create a rent-free ATA with Anchor macros

  Context:
  - Guide: https://zkcompression.com/light-token/cookbook/create-ata
  - Skills and resources index: https://zkcompression.com/skill.md
  - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
  - Crates: light-sdk, light-sdk-macros, light-compressible, anchor-lang
  - Example: https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-macros/create-associated-token-account

  Key macros: `#[light_program]`, `LightAccounts`, `#[light_account(init, associated_token::...)]`

  ### 1. Index project
  - Grep `#\[program\]|anchor_lang|Account<|Accounts|seeds|init|payer|ata|associated` across src/
  - Glob `**/*.rs` and `**/Cargo.toml` for project structure
  - Identify: existing program module, account structs, ATA patterns
  - Read Cargo.toml — note existing dependencies and framework version
  - Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel

  ### 2. Read references
  - WebFetch the guide above — review the Anchor Macros tab under Program
  - 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 rent-free ATA to existing program, migrate from SPL create_associated_token_account)
  - Summarize findings and wait for user confirmation before implementing

  ### 4. Create plan
  - Based on steps 1–3, draft an implementation plan
  - Follow the guide's step order: Dependencies → Program Module (#[light_program]) → Accounts Struct (#[light_account(init, associated_token::...)])
  - 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 if missing: Bash `cargo add light-sdk@0.23 --features anchor,v2,cpi-context` and `cargo add light-sdk-macros@0.23 light-compressible@0.6 anchor-lang@0.31`
  - Follow the guide and the approved plan
  - Write/Edit to create or modify files
  - TaskUpdate to mark each step done

  ### 6. Verify
  - Bash `anchor build`
  - Bash `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
  ```
</Accordion>

### Create token account (vault)

> [Guide](/light-token/cookbook/create-token-account) |
> [Example](https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-macros/create-token-account) |
> [Source](https://docs.rs/light-token)

<Columns cols={2}>
  ```rust theme={null}
  #[account(
      mut,
      seeds = [VAULT_SEED, mint.key().as_ref()],
      bump,
  )]
  #[light_account(init,
      token::authority = [VAULT_SEED, self.mint.key()],
      token::mint = mint,
      token::owner = vault_authority,
      token::bump = params.vault_bump
  )]
  pub vault: UncheckedAccount<'info>,
  ```

  ```rust title="Anchor" theme={null}
  #[account(
      init,
      payer = fee_payer,
      token::mint = mint,
      token::authority = authority,
  )]
  pub vault: Account<'info, TokenAccount>,
  ```
</Columns>

<Accordion title="AI prompt">
  <Prompt description="Create a rent-free token account with Anchor macros" actions={["copy", "cursor"]}>
    {`---
        description: Create a rent-free token account with Anchor macros
        allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
        ---

        ## Create a rent-free token account with Anchor macros

        Context:
        - Guide: https://zkcompression.com/light-token/cookbook/create-token-account
        - Skills and resources index: https://zkcompression.com/skill.md
        - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
        - Crates: light-sdk, light-sdk-macros, light-compressible, anchor-lang
        - Example: https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-macros/create-token-account

        Key macros: \`#[light_program]\`, \`LightAccounts\`, \`#[light_account(init, token::...)]\`

        ### 1. Index project
        - Grep \`#\[program\]|anchor_lang|Account<|Accounts|seeds|init|payer|vault|token_account\` across src/
        - Glob \`**/*.rs\` and \`**/Cargo.toml\` for project structure
        - Identify: existing program module, account structs, vault/token account patterns
        - Read Cargo.toml — note existing dependencies and framework version
        - Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel

        ### 2. Read references
        - WebFetch the guide above — review the Anchor Macros tab under Program
        - 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 rent-free token account to existing program, migrate from SPL token account init)
        - Summarize findings and wait for user confirmation before implementing

        ### 4. Create plan
        - Based on steps 1–3, draft an implementation plan
        - Follow the guide's step order: Dependencies → Program Module (#[light_program]) → Accounts Struct (#[light_account(init, token::...)])
        - 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 if missing: Bash \`cargo add light-sdk@0.23 --features anchor,v2,cpi-context\` and \`cargo add light-sdk-macros@0.23 light-compressible@0.6 anchor-lang@0.31\`
        - Follow the guide and the approved plan
        - Write/Edit to create or modify files
        - TaskUpdate to mark each step done

        ### 6. Verify
        - Bash \`anchor build\`
        - Bash \`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`}
  </Prompt>

  ```text theme={null}
  ---
  description: Create a rent-free token account with Anchor macros
  allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
  ---

  ## Create a rent-free token account with Anchor macros

  Context:
  - Guide: https://zkcompression.com/light-token/cookbook/create-token-account
  - Skills and resources index: https://zkcompression.com/skill.md
  - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
  - Crates: light-sdk, light-sdk-macros, light-compressible, anchor-lang
  - Example: https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-macros/create-token-account

  Key macros: `#[light_program]`, `LightAccounts`, `#[light_account(init, token::...)]`

  ### 1. Index project
  - Grep `#\[program\]|anchor_lang|Account<|Accounts|seeds|init|payer|vault|token_account` across src/
  - Glob `**/*.rs` and `**/Cargo.toml` for project structure
  - Identify: existing program module, account structs, vault/token account patterns
  - Read Cargo.toml — note existing dependencies and framework version
  - Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel

  ### 2. Read references
  - WebFetch the guide above — review the Anchor Macros tab under Program
  - 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 rent-free token account to existing program, migrate from SPL token account init)
  - Summarize findings and wait for user confirmation before implementing

  ### 4. Create plan
  - Based on steps 1–3, draft an implementation plan
  - Follow the guide's step order: Dependencies → Program Module (#[light_program]) → Accounts Struct (#[light_account(init, token::...)])
  - 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 if missing: Bash `cargo add light-sdk@0.23 --features anchor,v2,cpi-context` and `cargo add light-sdk-macros@0.23 light-compressible@0.6 anchor-lang@0.31`
  - Follow the guide and the approved plan
  - Write/Edit to create or modify files
  - TaskUpdate to mark each step done

  ### 6. Verify
  - Bash `anchor build`
  - Bash `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
  ```
</Accordion>

### Light-PDA init

Add `#[light_program]` above `#[program]`, derive `LightAccount` on state structs with a `compression_info` field, and derive `LightAccounts` on the accounts struct.

> [Guide](/pda/light-pda/overview) |
> [Example](https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-macros/counter) |
> [Source](https://docs.rs/light-account)

<Columns cols={2}>
  ```rust theme={null}
  use light_account::{
      CompressionInfo, LightAccount, LightAccounts,
      CreateAccountsProof, derive_light_cpi_signer,
      light_program, CpiSigner, LightDiscriminator,
  };

  #[light_program]
  #[program]
  pub mod my_program {
      // instruction logic unchanged
  }

  #[derive(LightAccount, LightDiscriminator)]
  pub struct MyState {
      pub compression_info: CompressionInfo,
      pub authority: Pubkey,
      pub data: u64,
  }

  #[derive(LightAccounts)]
  pub struct Initialize<'info> {
      #[light_account(init)]
      pub state: UncheckedAccount<'info>,
      #[account(mut)]
      pub pda_rent_sponsor: AccountInfo<'info>,
      // ...
  }
  ```

  ```rust title="Anchor" theme={null}
  #[program]
  pub mod my_program {
      // instruction logic unchanged
  }

  #[account]
  pub struct MyState {
      pub authority: Pubkey,
      pub data: u64,
  }

  #[derive(Accounts)]
  pub struct Initialize<'info> {
      #[account(
          init,
          payer = payer,
          space = 8 + MyState::INIT_SPACE,
      )]
      pub state: Account<'info, MyState>,
      #[account(mut)]
      pub payer: Signer<'info>,
      pub system_program: Program<'info, System>,
  }
  ```
</Columns>

<Accordion title="AI prompt">
  <Prompt description="Add rent-free PDAs to an Anchor program" actions={["copy", "cursor"]}>
    {`---
        description: Add rent-free PDAs to an Anchor program
        allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
        ---

        ## Add rent-free PDAs to an Anchor program

        Context:
        - Guide: https://zkcompression.com/pda/light-pda/overview
        - Skills and resources index: https://zkcompression.com/skill.md
        - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
        - Crates: light-account (features: anchor), light-sdk (features: anchor, v2, cpi-context)
        - Counter example: https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-macros/counter

        Key macros/APIs: #[light_program], LightAccount, LightAccounts, #[light_account(init)], CompressionInfo, CreateAccountsProof

        ### 1. Index project
        - Grep \`#\[program\]|anchor_lang|Account<|Accounts|InitSpace|seeds|init|payer\` across src/
        - Glob \`**/*.rs\` and \`**/Cargo.toml\` for project structure
        - Identify: existing program module, account structs, PDA seeds, token accounts, init instructions
        - Read Cargo.toml — note existing dependencies and framework version
        - Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel

        ### 2. Read references
        - WebFetch the guide above
        - 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, migrate existing program to rent-free, add rent-free accounts to specific instructions)
        - Summarize findings and wait for user confirmation before implementing

        ### 4. Create plan
        - Based on steps 1–3, draft an implementation plan
        - Follow the guide's step order: Dependencies → State Struct → Program Module → Accounts Struct
        - Identify which existing structs need changes (CompressionInfo field, LightAccount derive, etc.)
        - 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 if missing: Bash \`cargo add light-account@0.23 --features anchor\` and \`cargo add light-sdk@0.23 --features anchor,v2,cpi-context\`
        - Follow the guide and the approved plan
        - Write/Edit to create or modify files
        - TaskUpdate to mark each step done

        ### 6. Verify
        - Bash \`anchor build\`
        - Bash \`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`}
  </Prompt>

  ```text theme={null}
  ---
  description: Add rent-free PDAs to an Anchor program
  allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
  ---

  ## Add rent-free PDAs to an Anchor program

  Context:
  - Guide: https://zkcompression.com/pda/light-pda/overview
  - Skills and resources index: https://zkcompression.com/skill.md
  - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
  - Crates: light-account (features: anchor), light-sdk (features: anchor, v2, cpi-context)
  - Counter example: https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-macros/counter

  Key macros/APIs: #[light_program], LightAccount, LightAccounts, #[light_account(init)], CompressionInfo, CreateAccountsProof

  ### 1. Index project
  - Grep `#\[program\]|anchor_lang|Account<|Accounts|InitSpace|seeds|init|payer` across src/
  - Glob `**/*.rs` and `**/Cargo.toml` for project structure
  - Identify: existing program module, account structs, PDA seeds, token accounts, init instructions
  - Read Cargo.toml — note existing dependencies and framework version
  - Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel

  ### 2. Read references
  - WebFetch the guide above
  - 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, migrate existing program to rent-free, add rent-free accounts to specific instructions)
  - Summarize findings and wait for user confirmation before implementing

  ### 4. Create plan
  - Based on steps 1–3, draft an implementation plan
  - Follow the guide's step order: Dependencies → State Struct → Program Module → Accounts Struct
  - Identify which existing structs need changes (CompressionInfo field, LightAccount derive, etc.)
  - 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 if missing: Bash `cargo add light-account@0.23 --features anchor` and `cargo add light-sdk@0.23 --features anchor,v2,cpi-context`
  - Follow the guide and the approved plan
  - Write/Edit to create or modify files
  - TaskUpdate to mark each step done

  ### 6. Verify
  - Bash `anchor build`
  - Bash `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
  ```
</Accordion>
