Compressed token client
Build token applications with @lightprotocol/compressed-token (TypeScript). Compressed token accounts are always rent-free. The SPL mint and interface PDA still pay rent, but each holder's compressed token account costs a fraction of an SPL account.
| Creation cost |
SPL |
Compressed |
| Token account |
~2,000,000 lamports |
~5,000 lamports |
Compressed token accounts store balance, owner, mint, and delegate like SPL token accounts. They require no associated token account (ATA) and no rent-exempt balance, and convert to and from SPL tokens at any time with compress() and decompress(). Wallets like Phantom and Backpack display them alongside SPL tokens.
When to use compressed tokens
- Token distribution and airdrops without paying up-front rent per recipient
- Sending Payments, Payroll, and similar flow etc.
- Storing token balances rent-free
- Token-2022 mints with metadata and other supported extensions
How it works
Compressed tokens use a standard SPL (or Token-2022) mint plus an interface PDA. The interface PDA is an omnibus account that locks SPL tokens while they are compressed and releases them on decompression. Create it with the mint via createMint(), or add one to an existing mint with createTokenPool().
SPL mint --register--> interface PDA (omnibus PDA)
mintTo / compress --> compressed token accounts (rent-free, in state tree)
decompress --> back to SPL token account
Each mint supports a maximum of 4 interface PDAs. They get write-locked during compression and decompression, so add more with addTokenPools() to raise per-block write-lock capacity for high-throughput distribution.
Prerequisites
Examples run on localnet by default. For devnet or mainnet, set the API_KEY env var (Helius or Triton RPC key) and provide a Solana keypair at ~/.config/solana/id.json. In production, load both from a secrets manager.
import { createRpc } from '@lightprotocol/stateless.js';
// Localnet (defaults to http://127.0.0.1:8899):
const rpc = createRpc();
// Devnet or mainnet:
const rpc = createRpc(`https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`);
Domain references
| Task |
Reference |
| Create a mint with interface PDA, add more |
references/create-mint.md |
| Mint compressed tokens |
references/mint-to.md |
| Transfer compressed tokens |
references/transfer.md |
| Approve and revoke delegates |
references/approve-revoke.md |
| Compress and decompress SPL tokens |
references/compress-decompress.md |
| Merge fragmented compressed accounts |
references/merge-token-accounts.md |
| Token-2022 with compression |
references/token-2022.md |
| Token distribution and airdrops |
references/distribution.md |
| Query balances, accounts, and history |
references/queries.md |
Operations
All functions are in @lightprotocol/compressed-token unless noted. RPC helpers come from @lightprotocol/stateless.js.
- Mints and pools:
createMint (SPL mint + pool), createTokenPool (pool for existing mint), addTokenPools (max 4 per mint).
- Mint and move:
mintTo, approveAndMintTo, transfer, transferDelegated.
- Delegates:
approve, revoke.
- Compress and decompress:
compress, decompress, decompressDelegated, compressSplTokenAccount.
- Consolidate:
mergeTokenAccounts (up to 8 accounts).
- Instruction builders:
CompressedTokenProgram.* methods (compress, decompress, transfer, createTokenPool, deriveTokenPoolPda) and the standalone createMintInstruction export.
- Selection and pools:
getTokenPoolInfos, selectTokenPoolInfo, selectTokenPoolInfosForDecompression, selectMinCompressedTokenAccountsForTransfer.
- RPC (
Rpc): createRpc, getValidityProof, getCompressedTokenAccountsByOwner, getCompressedTokenAccountsByDelegate, getCompressedTokenBalancesByOwnerV2, getCompressionSignaturesForTokenOwner, selectStateTreeInfo.
- Build and send:
buildAndSignTx, sendAndConfirmTx, dedupeSigner.
Reference repos
If cloned locally, scope Read, Glob, Grep to these repositories and the current project directory only.
Workflow
- Clarify intent. Recommend plan mode if not active. Use
AskUserQuestion to resolve blind spots before execution.
- Identify references. Match the task to the domain references and reference repos above.
- Write a plan (YAML task format). Never guess; identify blockers (permissions, dependencies, unknowns) up front.
- Execute. Use
Task subagents for parallel research; track progress with TodoWrite.
- When stuck, spawn a read-only subagent with
Read, Glob, Grep, and DeepWiki MCP access, loading skills/ask-mcp. Scope reads to skill references, example repos, and docs.
Build and test
Install dependencies and run a script against localnet, devnet, or mainnet by setting the RPC URL in createRpc().
npm install @lightprotocol/stateless.js @lightprotocol/compressed-token @solana/web3.js @solana/spl-token
npx tsx your-script.ts
SDK references
@lightprotocol/compressed-token — API docs
@lightprotocol/stateless.js — API docs
DeepWiki fallback
If no matching pattern in the reference repos, ask mcp__deepwiki__ask_question against Lightprotocol/light-protocol, for example "How to mint compressed tokens with @lightprotocol/compressed-token?".
Security
This skill provides code patterns and documentation references only.
- Declared dependencies. Devnet and mainnet examples require
API_KEY (Helius or Triton RPC key) and read ~/.config/solana/id.json for the payer keypair. Neither is needed on localnet. In production, load both from a secrets manager.
- User-provided configuration. RPC endpoints, wallet keypairs, and tokens are configured in the user's application code. The skill demonstrates patterns; it does not store or transmit secrets.
- Filesystem scope.
Read, Glob, Grep must stay within the current project directory and the reference repos above.
- Install source.
npx skills add Lightprotocol/skills installs from the public GitHub repository (Lightprotocol/skills). Verify the source before running.
- Audited protocol. Light Protocol smart contracts are independently audited. Reports are at github.com/Lightprotocol/light-protocol/tree/main/audits.
1---2name: compressed-token3description: For compressed token operations on Solana ~400x cheaper than SPL: create mints with interface PDAs, mint, transfer, approve, revoke, compress, decompress, merge, and Token-2022 with compression. Compressed token accounts are always rent-free. @lightprotocol/compressed-token (TypeScript) with createRpc() from @lightprotocol/stateless.js.4---5
6# Compressed token client
7
8Build token applications with `@lightprotocol/compressed-token` (TypeScript). Compressed token accounts are always rent-free. The SPL mint and interface PDA still pay rent, but each holder's compressed token account costs a fraction of an SPL account.
9
10| Creation cost | SPL | Compressed |
11| :---------------- | :------------------ | :------------------- |
12| **Token account** | ~2,000,000 lamports | ~**5,000** lamports |
13
14Compressed token accounts store balance, owner, mint, and delegate like SPL token accounts. They require no associated token account (ATA) and no rent-exempt balance, and convert to and from SPL tokens at any time with `compress()` and `decompress()`. Wallets like Phantom and Backpack display them alongside SPL tokens.
15
16## When to use compressed tokens
17
18- Token distribution and airdrops without paying up-front rent per recipient
19- Sending Payments, Payroll, and similar flow etc.
20- Storing token balances rent-free
21- Token-2022 mints with metadata and other supported extensions
22
23## How it works
24
25Compressed tokens use a standard SPL (or Token-2022) mint plus an interface PDA. The interface PDA is an omnibus account that locks SPL tokens while they are compressed and releases them on decompression. Create it with the mint via `createMint()`, or add one to an existing mint with `createTokenPool()`.
26
27```text
28SPL mint --register--> interface PDA (omnibus PDA)
29mintTo / compress --> compressed token accounts (rent-free, in state tree)
30decompress --> back to SPL token account
31```
32
33Each mint supports a maximum of 4 interface PDAs. They get write-locked during compression and decompression, so add more with `addTokenPools()` to raise per-block write-lock capacity for high-throughput distribution.
34
35## Prerequisites
36
37Examples run on localnet by default. For devnet or mainnet, set the `API_KEY` env var (Helius or Triton RPC key) and provide a Solana keypair at `~/.config/solana/id.json`. In production, load both from a secrets manager.
38
39```typescript
40import { createRpc } from '@lightprotocol/stateless.js';
41
42// Localnet (defaults to http://127.0.0.1:8899):
43const rpc = createRpc();
44
45// Devnet or mainnet:
46const rpc = createRpc(`https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`);
47```
48
49## Domain references
50
51| Task | Reference |
52|------|-----------|
53| Create a mint with interface PDA, add more | [references/create-mint.md](references/create-mint.md) |
54| Mint compressed tokens | [references/mint-to.md](references/mint-to.md) |
55| Transfer compressed tokens | [references/transfer.md](references/transfer.md) |
56| Approve and revoke delegates | [references/approve-revoke.md](references/approve-revoke.md) |
57| Compress and decompress SPL tokens | [references/compress-decompress.md](references/compress-decompress.md) |
58| Merge fragmented compressed accounts | [references/merge-token-accounts.md](references/merge-token-accounts.md) |
59| Token-2022 with compression | [references/token-2022.md](references/token-2022.md) |
60| Token distribution and airdrops | [references/distribution.md](references/distribution.md) |
61| Query balances, accounts, and history | [references/queries.md](references/queries.md) |
62
63## Operations
64
65All functions are in `@lightprotocol/compressed-token` unless noted. RPC helpers come from `@lightprotocol/stateless.js`.
66
67- **Mints and pools:** `createMint` (SPL mint + pool), `createTokenPool` (pool for existing mint), `addTokenPools` (max 4 per mint).
68- **Mint and move:** `mintTo`, `approveAndMintTo`, `transfer`, `transferDelegated`.
69- **Delegates:** `approve`, `revoke`.
70- **Compress and decompress:** `compress`, `decompress`, `decompressDelegated`, `compressSplTokenAccount`.
71- **Consolidate:** `mergeTokenAccounts` (up to 8 accounts).
72- **Instruction builders:** `CompressedTokenProgram.*` methods (`compress`, `decompress`, `transfer`, `createTokenPool`, `deriveTokenPoolPda`) and the standalone `createMintInstruction` export.
73- **Selection and pools:** `getTokenPoolInfos`, `selectTokenPoolInfo`, `selectTokenPoolInfosForDecompression`, `selectMinCompressedTokenAccountsForTransfer`.
74- **RPC (`Rpc`):** `createRpc`, `getValidityProof`, `getCompressedTokenAccountsByOwner`, `getCompressedTokenAccountsByDelegate`, `getCompressedTokenBalancesByOwnerV2`, `getCompressionSignaturesForTokenOwner`, `selectStateTreeInfo`.
75- **Build and send:** `buildAndSignTx`, `sendAndConfirmTx`, `dedupeSigner`.
76
77## Reference repos
78
79- [compressed-token-cookbook](https://github.com/Lightprotocol/examples-zk-compression/tree/main/compressed-token-cookbook) — action-level and instruction-level examples for every operation, plus wallet integration (balances, history, send, compress, decompress).
80- [example-token-distribution](https://github.com/Lightprotocol/examples-zk-compression/tree/main/example-token-distribution) — simple and optimized batched airdrop flows, decompress-on-claim pattern.
81- [examples-zk-compression](https://github.com/Lightprotocol/examples-zk-compression) — more ZK compression examples.
82
83If cloned locally, scope `Read`, `Glob`, `Grep` to these repositories and the current project directory only.
84
85## Workflow
86
871. **Clarify intent.** Recommend plan mode if not active. Use `AskUserQuestion` to resolve blind spots before execution.
882. **Identify references.** Match the task to the domain references and reference repos above.
893. **Write a plan** (YAML task format). Never guess; identify blockers (permissions, dependencies, unknowns) up front.
904. **Execute.** Use `Task` subagents for parallel research; track progress with `TodoWrite`.
915. **When stuck**, spawn a read-only subagent with `Read`, `Glob`, `Grep`, and DeepWiki MCP access, loading `skills/ask-mcp`. Scope reads to skill references, example repos, and docs.
92
93## Build and test
94
95Install dependencies and run a script against localnet, devnet, or mainnet by setting the RPC URL in `createRpc()`.
96
97```bash
98npm install @lightprotocol/stateless.js @lightprotocol/compressed-token @solana/web3.js @solana/spl-token
99npx tsx your-script.ts
100```
101
102## SDK references
103
104- `@lightprotocol/compressed-token` — [API docs](https://lightprotocol.github.io/light-protocol/compressed-token/index.html)
105- `@lightprotocol/stateless.js` — [API docs](https://lightprotocol.github.io/light-protocol/stateless.js/index.html)
106
107## DeepWiki fallback
108
109If no matching pattern in the reference repos, ask `mcp__deepwiki__ask_question` against `Lightprotocol/light-protocol`, for example "How to mint compressed tokens with @lightprotocol/compressed-token?".
110
111## Security
112
113This skill provides code patterns and documentation references only.
114
115- **Declared dependencies.** Devnet and mainnet examples require `API_KEY` (Helius or Triton RPC key) and read `~/.config/solana/id.json` for the payer keypair. Neither is needed on localnet. In production, load both from a secrets manager.
116- **User-provided configuration.** RPC endpoints, wallet keypairs, and tokens are configured in the user's application code. The skill demonstrates patterns; it does not store or transmit secrets.
117- **Filesystem scope.** `Read`, `Glob`, `Grep` must stay within the current project directory and the reference repos above.
118- **Install source.** `npx skills add Lightprotocol/skills` installs from the public GitHub repository ([Lightprotocol/skills](https://github.com/Lightprotocol/skills)). Verify the source before running.
119- **Audited protocol.** Light Protocol smart contracts are independently audited. Reports are at [github.com/Lightprotocol/light-protocol/tree/main/audits](https://github.com/Lightprotocol/light-protocol/tree/main/audits).