Use this file to discover all available pages before exploring further.
The light-token API matches the SPL-token API almost entirely, and extends their functionality to include the light token program in addition to the SPL-token and Token-2022 programs.
Your users use the same stablecoins, just stored more efficiently.
Load creates the associated token account (ATA) if needed and loads any compressed state into it. Share the ATA address with the sender.
About loading: Light Token accounts reduce account rent ~200x by auto-compressing inactive
accounts. Before any action, the SDK detects cold balances and adds
instructions to load them. This almost always fits in a single
atomic transaction with your regular transfer. APIs return TransactionInstruction[][] so the same
loop handles the rare multi-transaction case automatically.
Instruction
Action
import { Transaction, sendAndConfirmTransaction } from "@solana/web3.js";import { createLoadAtaInstructions, getAssociatedTokenAddressInterface,} from "@lightprotocol/compressed-token/unified";const ata = getAssociatedTokenAddressInterface(mint, recipient);// Returns TransactionInstruction[][].// Each inner array is one transaction.// Almost always returns just one.const instructions = await createLoadAtaInstructions( rpc, ata, recipient, mint, payer.publicKey);for (const ixs of instructions) { const tx = new Transaction().add(...ixs); await sendAndConfirmTransaction(rpc, tx, [payer]);}
import { loadAta, getAssociatedTokenAddressInterface,} from "@lightprotocol/compressed-token/unified";const ata = getAssociatedTokenAddressInterface(mint, recipient);const sig = await loadAta(rpc, ata, recipient, mint, payer);if (sig) console.log("Loaded:", sig);
Compare to SPL
import { createAssociatedTokenAccountInstruction, getAssociatedTokenAddressSync, getOrCreateAssociatedTokenAccount,} from "@solana/spl-token";const ata = getAssociatedTokenAddressSync(mint, recipient);// Instruction:const tx = new Transaction().add( createAssociatedTokenAccountInstruction(payer.publicKey, ata, recipient, mint));// Action:const ata = await getOrCreateAssociatedTokenAccount( connection, payer, mint, recipient);
Your app logic may require you to create a single sign request for your user. Here’s how to do this:
Sign all transactions together
const transactions = instructions.map((ixs) => new Transaction().add(...ixs));// One approval for allconst signed = await wallet.signAllTransactions(transactions);for (const tx of signed) { // send... await sendAndConfirmTransaction(rpc, tx);}
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.
Optimize sending (parallel conditional loads, then transfer)
Unwrap moves the token balance from a light-token account to a SPL-token account.
Use this to compose with applications that do not yet support light-token.
---description: Integrate light-token APIs for stablecoin paymentsallowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression---## Integrate light-token APIs for stablecoin paymentsContext:- Guide: https://zkcompression.com/light-token/toolkits/for-payments- Skills and resources index: https://zkcompression.com/skill.md- SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison- Dedicated skill: https://github.com/Lightprotocol/skills/tree/main/skills/payments-and-wallets- Packages: @lightprotocol/compressed-token, @lightprotocol/stateless.js- Full examples: https://github.com/Lightprotocol/examples-light-token/tree/main/toolkits/payments-and-walletsSPL → Light Token API mapping:| Operation | SPL | Light Token || Receive | getOrCreateAssociatedTokenAccount() | createLoadAtaInstructions() / loadAta() || Transfer | createTransferInstruction() | createTransferInterfaceInstructions() || Get Balance | getAccount() | getAtaInterface() || Tx History | getSignaturesForAddress() | getSignaturesForOwnerInterface() || Wrap SPL | N/A | createWrapInstruction() / wrap() || Unwrap | N/A | createUnwrapInstructions() / unwrap() |### 1. Index project- Grep `@solana/spl-token|@lightprotocol|createTransferInstruction|getAccount|Connection|Keypair|stablecoin|payment` across src/- Glob `**/*.ts` and `**/*.tsx` for project structure- Identify: RPC setup, existing token operations, payment flow, wallet signing pattern- Check package.json for existing @lightprotocol/* or @solana/spl-token dependencies- Task subagent (Grep/Read/WebFetch) if project has multiple packages to scan in parallel### 2. Read references- WebFetch the guide above — review Instruction and Action tabs for each operation- 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 payment integration, migrate existing SPL payment flow, add alongside existing SPL)- AskUserQuestion: which operations? (receive, send, balance, history, wrap, unwrap — or all)- AskUserQuestion: instruction-level API (build your own transactions) or action-level API (high-level, fewer lines)?- 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 (createRpc with ZK Compression endpoint)- Key pattern: import from `@lightprotocol/compressed-token/unified` for all interface APIs- 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`- Set up RPC: `createRpc(RPC_ENDPOINT)` with a ZK Compression endpoint (Helius, Triton)- Import from `@lightprotocol/compressed-token/unified` for the interface APIs- Follow the 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