| Light Token -> Light Token Account |
|
| SPL token -> Light Token Account |
|
| Light Token -> SPL Account |
|
Agent skill
Agent skill
Install the agent skill:See the AI tools guide for dedicated skills.
Report incorrect code
Copy
Ask AI
npx skills add https://zkcompression.com
- TypeScript Client
- Rust Client
- Program
The
transferInterface function transfers tokens between token accounts (SPL, Token 2022, or Light) in a single call.Compare to SPL:Find the source code
here.
- Guide
- AI Prompt
Transfer Interface
Installation
Installation
- npm
- yarn
- pnpm
Install packages in your working directory:Install the CLI globally:
Report incorrect code
Copy
Ask AI
npm install @lightprotocol/stateless.js@beta \
@lightprotocol/compressed-token@beta
Report incorrect code
Copy
Ask AI
npm install -g @lightprotocol/zk-compression-cli@beta
Install packages in your working directory:Install the CLI globally:
Report incorrect code
Copy
Ask AI
yarn add @lightprotocol/stateless.js@beta \
@lightprotocol/compressed-token@beta
Report incorrect code
Copy
Ask AI
yarn global add @lightprotocol/zk-compression-cli@beta
Install packages in your working directory:Install the CLI globally:
Report incorrect code
Copy
Ask AI
pnpm add @lightprotocol/stateless.js@beta \
@lightprotocol/compressed-token@beta
Report incorrect code
Copy
Ask AI
pnpm add -g @lightprotocol/zk-compression-cli@beta
- Localnet
- Devnet
Report incorrect code
Copy
Ask AI
# start local test-validator in a separate terminal
light test-validator
In the code examples, use
createRpc() without arguments for localnet.Get an API key from Helius and add to
.env:.env
Report incorrect code
Copy
Ask AI
API_KEY=<your-helius-api-key>
In the code examples, use
createRpc(RPC_URL) with the devnet URL.- Action
- Instruction
Report incorrect code
Copy
Ask AI
import "dotenv/config";
import { Keypair } from "@solana/web3.js";
import { createRpc } from "@lightprotocol/stateless.js";
import {
createMintInterface,
createAtaInterface,
mintToInterface,
transferInterface,
getAssociatedTokenAddressInterface,
} from "@lightprotocol/compressed-token";
import { homedir } from "os";
import { readFileSync } from "fs";
// devnet:
const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`;
const rpc = createRpc(RPC_URL);
// localnet:
// const rpc = createRpc();
const payer = Keypair.fromSecretKey(
new Uint8Array(
JSON.parse(readFileSync(`${homedir()}/.config/solana/id.json`, "utf8"))
)
);
(async function () {
const { mint } = await createMintInterface(rpc, payer, payer, null, 9);
const sender = Keypair.generate();
await createAtaInterface(rpc, payer, mint, sender.publicKey);
const senderAta = getAssociatedTokenAddressInterface(mint, sender.publicKey);
await mintToInterface(rpc, payer, mint, senderAta, payer, 1_000_000_000);
const recipient = Keypair.generate();
// destination is a wallet pubkey; the action creates the recipient ATA.
const tx = await transferInterface(rpc, payer, senderAta, mint, recipient.publicKey, sender, 500_000_000);
console.log("Tx:", tx);
})();
Report incorrect code
Copy
Ask AI
import "dotenv/config";
import {
Keypair,
ComputeBudgetProgram,
Transaction,
sendAndConfirmTransaction,
} from "@solana/web3.js";
import { createRpc } from "@lightprotocol/stateless.js";
import {
createMintInterface,
createAtaInterface,
mintToInterface,
createLightTokenTransferInstruction,
getAssociatedTokenAddressInterface,
} from "@lightprotocol/compressed-token";
import { homedir } from "os";
import { readFileSync } from "fs";
// devnet:
// const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`;
// const rpc = createRpc(RPC_URL);
// localnet:
const rpc = createRpc();
const payer = Keypair.fromSecretKey(
new Uint8Array(
JSON.parse(readFileSync(`${homedir()}/.config/solana/id.json`, "utf8")),
),
);
(async function () {
const { mint } = await createMintInterface(rpc, payer, payer, null, 9);
const sender = Keypair.generate();
await createAtaInterface(rpc, payer, mint, sender.publicKey);
const senderAta = getAssociatedTokenAddressInterface(
mint,
sender.publicKey,
);
await mintToInterface(rpc, payer, mint, senderAta, payer, 1_000_000_000);
const recipient = Keypair.generate();
await createAtaInterface(rpc, payer, mint, recipient.publicKey);
const recipientAta = getAssociatedTokenAddressInterface(
mint,
recipient.publicKey,
);
// Transfer tokens. Optional feePayer lets an application cover top-ups
// so the sender only signs to authorize the transfer.
const ix = createLightTokenTransferInstruction(
senderAta,
recipientAta,
sender.publicKey, // owner (signs the transfer)
500_000_000,
payer.publicKey, // optional: separate feePayer covers top-up
);
const tx = new Transaction().add(ix);
const signature = await sendAndConfirmTransaction(rpc, tx, [payer, sender]);
console.log("Tx:", signature);
})();
Transfer tokens between Light Token and SPL accounts
Report incorrect code
Copy
Ask AI
---
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 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
### 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
Use the unified
TransferInterface to transfer tokens between token accounts (SPL, Token 2022, or Light) in a single call.- Guide
- AI Prompt
Prerequisites
Dependencies
Dependencies
Cargo.toml
Report incorrect code
Copy
Ask AI
[dependencies]
light-token = "0.4.0"
light-client = { version = "0.19.0", features = ["v2"] }
solana-sdk = "2"
borsh = "0.10.4"
tokio = { version = "1", features = ["full"] }
Developer Environment
Developer Environment
- In-Memory (LightProgramTest)
- Localnet (LightClient)
- Devnet (LightClient)
Test with Lite-SVM (…)
Report incorrect code
Copy
Ask AI
# Initialize project
cargo init my-light-project
cd my-light-project
# Run tests
cargo test
Report incorrect code
Copy
Ask AI
use light_program_test::{LightProgramTest, ProgramTestConfig};
use solana_sdk::signer::Signer;
#[tokio::test]
async fn test_example() {
// In-memory test environment
let mut rpc = LightProgramTest::new(ProgramTestConfig::default())
.await
.unwrap();
let payer = rpc.get_payer().insecure_clone();
println!("Payer: {}", payer.pubkey());
}
Connects to a local test validator.
- npm
- yarn
- pnpm
Report incorrect code
Copy
Ask AI
npm install -g @lightprotocol/zk-compression-cli@beta
Report incorrect code
Copy
Ask AI
yarn global add @lightprotocol/zk-compression-cli@beta
Report incorrect code
Copy
Ask AI
pnpm add -g @lightprotocol/zk-compression-cli@beta
Report incorrect code
Copy
Ask AI
# Initialize project
cargo init my-light-project
cd my-light-project
# Start local test validator (in separate terminal)
light test-validator
Report incorrect code
Copy
Ask AI
use light_client::rpc::{LightClient, LightClientConfig, Rpc};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Connects to http://localhost:8899
let rpc = LightClient::new(LightClientConfig::local()).await?;
let slot = rpc.get_slot().await?;
println!("Current slot: {}", slot);
Ok(())
}
Replace
<your-api-key> with your actual API key. Get your API key here.Report incorrect code
Copy
Ask AI
use light_client::rpc::{LightClient, LightClientConfig, Rpc};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let rpc_url = "https://devnet.helius-rpc.com?api-key=<your_api_key>";
let rpc = LightClient::new(
LightClientConfig::new(rpc_url.to_string(), None, None)
).await?;
println!("Connected to Devnet");
Ok(())
}
Transfer Interface
The example transfers- SPL token -> Light Token,
- Light Token -> Light Token, and
- Light Token -> SPL token.
Find the source code here.
- Action
- Instruction
Report incorrect code
Copy
Ask AI
use borsh::BorshDeserialize;
use light_client::rpc::Rpc;
use light_token_client::actions::{CreateAta, TransferInterface};
use rust_client::{setup, SetupContext};
use solana_sdk::{signature::Keypair, signer::Signer};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let SetupContext {
mut rpc,
payer,
mint,
associated_token_account,
decimals,
..
} = setup().await;
// Create recipient associated token account
let recipient = Keypair::new();
let (_signature, recipient_associated_token_account) = CreateAta {
mint,
owner: recipient.pubkey(),
idempotent: true,
}
.execute(&mut rpc, &payer)
.await?;
// Transfers tokens between token accounts (SPL, Token-2022, or Light) in a single call.
let sig = TransferInterface {
source: associated_token_account,
mint,
destination: recipient_associated_token_account,
amount: 1000,
decimals,
..Default::default()
}
.execute(&mut rpc, &payer, &payer)
.await?;
let data = rpc
.get_account(recipient_associated_token_account)
.await?
.ok_or("Account not found")?;
let token = light_token_interface::state::Token::deserialize(&mut &data.data[..])?;
println!("Balance: {} Tx: {sig}", token.amount);
Ok(())
}
Report incorrect code
Copy
Ask AI
use anchor_spl::token::spl_token;
use borsh::BorshDeserialize;
use light_client::rpc::Rpc;
use light_program_test::{LightProgramTest, ProgramTestConfig};
use light_token::{
instruction::{
get_associated_token_address, CreateAssociatedTokenAccount, SplInterface,
TransferInterface, LIGHT_TOKEN_PROGRAM_ID,
},
spl_interface::find_spl_interface_pda_with_index,
};
use rust_client::{setup_spl_associated_token_account, setup_spl_mint};
use solana_sdk::signer::Signer;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut rpc = LightProgramTest::new(ProgramTestConfig::new_v2(true, None)).await?;
let payer = rpc.get_payer().insecure_clone();
let decimals = 2u8;
let amount = 10_000u64;
// Setup creates mint, mints tokens and creates SPL associated token account
let mint = setup_spl_mint(&mut rpc, &payer, decimals).await;
let spl_associated_token_account = setup_spl_associated_token_account(&mut rpc, &payer, &mint, &payer.pubkey(), amount).await;
let (interface_pda, interface_bump) = find_spl_interface_pda_with_index(&mint, 0, false);
// Create Light associated token account
let light_associated_token_account = get_associated_token_address(&payer.pubkey(), &mint);
let create_associated_token_account_instruction =
CreateAssociatedTokenAccount::new(payer.pubkey(), payer.pubkey(), mint).instruction()?;
rpc.create_and_send_transaction(&[create_associated_token_account_instruction], &payer.pubkey(), &[&payer])
.await?;
// SPL interface PDA for Mint (holds SPL tokens when transferred to Light Token)
let spl_interface = SplInterface {
mint,
spl_token_program: spl_token::ID,
spl_interface_pda: interface_pda,
spl_interface_pda_bump: interface_bump,
};
// Transfers tokens between token accounts (SPL, Token-2022, or Light) in a single call.
let transfer_instruction = TransferInterface {
source: spl_associated_token_account,
destination: light_associated_token_account,
amount,
decimals,
authority: payer.pubkey(),
payer: payer.pubkey(),
spl_interface: Some(spl_interface),
max_top_up: None,
source_owner: spl_token::ID,
destination_owner: LIGHT_TOKEN_PROGRAM_ID,
}
.instruction()?;
let sig = rpc
.create_and_send_transaction(&[transfer_instruction], &payer.pubkey(), &[&payer])
.await?;
let data = rpc
.get_account(light_associated_token_account)
.await?
.ok_or("Account not found")?;
let token = light_token_interface::state::Token::deserialize(&mut &data.data[..])?;
println!("Balance: {} Tx: {sig}", token.amount);
Ok(())
}
Transfer tokens between Light Token and SPL accounts
Report incorrect code
Copy
Ask AI
---
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
- Guide
- AI Prompt
Transfer Interface CPI
TheTransferInterfaceCpi transfers tokens between token accounts (SPL, Token 2022, or Light Token).- invoke (External signer)
- invoke_signed (PDA signer)
Report incorrect code
Copy
Ask AI
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()?;
Report incorrect code
Copy
Ask AI
use light_token::instruction::TransferInterfaceCpi;
let signer_seeds = authority_seeds!(bump);
TransferInterfaceCpi::new(
amount,
decimals,
source.clone(),
destination.clone(),
authority.clone(),
payer.clone(),
light_token_authority.clone(),
system_program.clone(),
)
.invoke_signed(&[signer_seeds])?;
Full code example
- CPI
- Setup ATA with Macro and CPI
View the source code and full example with shared test utilities.
Report incorrect code
Copy
Ask AI
#![allow(unexpected_cfgs, deprecated)]
use anchor_lang::prelude::*;
use light_token::instruction::TransferInterfaceCpi;
declare_id!("3rb6sG4jiYNLZC8jo8kLsFHpxr2Ci8e8Hh8UmeCMZmUV");
#[program]
pub mod light_token_anchor_transfer_interface {
use super::*;
pub fn transfer(
ctx: Context<TransferAccounts>,
amount: u64,
decimals: u8,
spl_interface_pda_bump: Option<u8>,
) -> Result<()> {
let mut transfer = TransferInterfaceCpi::new(
amount,
decimals,
ctx.accounts.source.to_account_info(),
ctx.accounts.destination.to_account_info(),
ctx.accounts.authority.to_account_info(),
ctx.accounts.payer.to_account_info(),
ctx.accounts.cpi_authority.to_account_info(),
ctx.accounts.system_program.to_account_info(),
);
if let Some(bump) = spl_interface_pda_bump {
transfer = transfer
.with_spl_interface(
ctx.accounts.mint.as_ref().map(|a| a.to_account_info()),
ctx.accounts
.spl_token_program
.as_ref()
.map(|a| a.to_account_info()),
ctx.accounts
.spl_interface_pda
.as_ref()
.map(|a| a.to_account_info()),
Some(bump),
)
.map_err(|e| ProgramError::from(e))?;
}
transfer.invoke().map_err(|e| ProgramError::from(e))?;
Ok(())
}
}
#[derive(Accounts)]
pub struct TransferAccounts<'info> {
/// CHECK: Light token program for CPI
pub light_token_program: AccountInfo<'info>,
/// CHECK: Validated by light-token CPI
#[account(mut)]
pub source: AccountInfo<'info>,
/// CHECK: Validated by light-token CPI
#[account(mut)]
pub destination: AccountInfo<'info>,
pub authority: Signer<'info>,
#[account(mut)]
pub payer: Signer<'info>,
/// CHECK: Validated by light-token CPI
pub cpi_authority: AccountInfo<'info>,
pub system_program: Program<'info, System>,
// SPL interface accounts (optional, for cross-type transfers)
/// CHECK: Validated by light-token CPI - token mint
pub mint: Option<AccountInfo<'info>>,
/// CHECK: SPL Token or Token-2022 program
pub spl_token_program: Option<AccountInfo<'info>>,
/// CHECK: Validated by light-token CPI - pool PDA
#[account(mut)]
pub spl_interface_pda: Option<AccountInfo<'info>>,
}
Uses the
#[light_account(init, associated_token::...)] macro to create the destination ATA during the transfer.View the full example with test utilities.
Report incorrect code
Copy
Ask AI
#![allow(unexpected_cfgs, deprecated)]
use anchor_lang::prelude::*;
use light_sdk::interface::CreateAccountsProof;
use light_token::anchor::{derive_light_cpi_signer, light_program, CpiSigner, LightAccounts};
use light_token::instruction::TransferInterfaceCpi;
declare_id!("672fL1Nm191MbPoygNM9DRiG2psBELn97XUpGbU3jW7E");
pub const LIGHT_CPI_SIGNER: CpiSigner =
derive_light_cpi_signer!("672fL1Nm191MbPoygNM9DRiG2psBELn97XUpGbU3jW7E");
#[derive(AnchorSerialize, AnchorDeserialize, Clone)]
pub struct TransferParams {
pub create_accounts_proof: CreateAccountsProof,
pub dest_associated_token_account_bump: u8,
pub amount: u64,
pub decimals: u8,
}
#[light_program]
#[program]
pub mod create_and_transfer {
use super::*;
pub fn transfer<'info>(
ctx: Context<'_, '_, '_, 'info, Transfer<'info>>,
params: TransferParams,
) -> Result<()> {
TransferInterfaceCpi::new(
params.amount,
params.decimals,
ctx.accounts.source.to_account_info(),
ctx.accounts.destination.to_account_info(),
ctx.accounts.authority.to_account_info(),
ctx.accounts.payer.to_account_info(),
ctx.accounts.light_token_cpi_authority.to_account_info(),
ctx.accounts.system_program.to_account_info(),
)
.invoke()
.map_err(|e| anchor_lang::prelude::ProgramError::from(e))?;
Ok(())
}
}
#[derive(Accounts, LightAccounts)]
#[instruction(params: TransferParams)]
pub struct Transfer<'info> {
#[account(mut)]
pub payer: Signer<'info>,
pub authority: Signer<'info>,
/// CHECK: Validated by light-token CPI
pub mint: AccountInfo<'info>,
/// CHECK: Validated by light-token CPI
#[account(mut)]
pub source: AccountInfo<'info>,
/// CHECK: Validated by light-token CPI
pub recipient: AccountInfo<'info>,
/// CHECK: Validated by light-token CPI
#[account(mut)]
#[light_account(init,
associated_token::authority = recipient,
associated_token::mint = mint,
associated_token::bump = params.dest_associated_token_account_bump
)]
pub destination: UncheckedAccount<'info>,
/// CHECK: Validated by light-token CPI
pub light_token_program: AccountInfo<'info>,
pub system_program: Program<'info, System>,
/// CHECK: Validated by light-token CPI
pub light_token_compressible_config: AccountInfo<'info>,
/// CHECK: Validated by light-token CPI
#[account(mut)]
pub rent_sponsor: AccountInfo<'info>,
/// CHECK: Validated by light-token CPI
pub light_token_cpi_authority: AccountInfo<'info>,
}
Add transfer-interface CPI to an Anchor program
Report incorrect code
Copy
Ask AI
---
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