Documentation Index
Fetch the complete documentation index at: https://docs.zkterm.io/llms.txt
Use this file to discover all available pages before exploring further.
Overview
zkCompression integrates Light Protocol to enable ZK Compression on Solana, allowing you to compress SPL tokens and reduce storage costs by up to 5000x.
How It Works
-
Compress: Regular SPL tokens are converted to compressed tokens stored in a Merkle tree state.
-
Store: Only the Merkle root is stored on-chain, dramatically reducing costs.
-
Decompress: Compressed tokens can be decompressed back to regular SPL tokens at any time.
Cost Comparison
| Operation | Regular SPL | Compressed |
|---|
| Token Account | ~0.002 SOL | ~0.00002 SOL |
| Transfer | ~0.000005 SOL | ~0.000001 SOL |
| Storage per token | ~165 bytes | ~0.165 bytes |
Compressed tokens are 5000x cheaper to create and 98% cheaper to transfer.
Terminal Commands
Show Help
Shows all available Light Protocol commands and cost savings info.
Compress SOL
zk light compress <amount> --from <wallet>
Convert regular SOL to compressed SOL. Compressed SOL has NO rent costs.
Example:
zk light compress 0.1 --from mysol
Decompress SOL
zk light decompress <amount> --from <wallet>
Convert compressed SOL back to regular SOL.
Example:
zk light decompress 0.1 --from mysol
Create Compressed Token
zk light create-token --decimals <n> --from <wallet>
Create a new compressed SPL token mint (5000x cheaper than standard).
Example:
zk light create-token --decimals 9 --from mysol
Mint Compressed Tokens
zk light mint <token> <amount> <address> --from <wallet>
Mint compressed tokens to a specified address.
Transfer Compressed Tokens
zk light transfer <token> <amount> <address> --from <wallet>
Transfer compressed tokens to another address.
Check Balance
zk light balance <address> [token]
Check compressed token balances for an address.
Account Info
zk light account-info <address>
Get detailed compressed account information including all token balances.
Airdrop
zk light airdrop <token> <amount> --recipients <addr1,addr2,...> --from <wallet>
Mass token distribution to multiple recipients.
View Token Portfolio
Display unified portfolio view of all tokens (regular + compressed):
Token Portfolio
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Token Balance Type Mint
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
USDC 1,234.56 Regular EPjFWdd5...
USDC 500.00 [C] EPjFWdd5...
SOL 10.5 Regular So11111...
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
[C] = Compressed Token
API Reference
Compress SOL
POST /api/light/compress
Content-Type: application/json
{
"amount": 0.1,
"walletId": "wallet-uuid"
}
Response:
{
"success": true,
"txHash": "5abc...",
"amount": 0.1,
"costSavings": {
"standardRent": 2039280,
"compressedRent": 0
}
}
Decompress SOL
POST /api/light/decompress
Content-Type: application/json
{
"amount": 0.1,
"walletId": "wallet-uuid"
}
Response:
{
"success": true,
"txHash": "6def...",
"amount": 0.1
}
Create Compressed Token
POST /api/light/create-token
Content-Type: application/json
{
"decimals": 9,
"walletId": "wallet-uuid"
}
Response:
{
"success": true,
"mintAddress": "CompMint123...",
"txHash": "7ghi..."
}
Get Account Info
GET /api/light/account-info/<address>
Response:
{
"address": "YourAddress123...",
"compressedBalance": "0.5",
"tokenBalances": [
{
"mint": "EPjFWdd5...",
"symbol": "USDC",
"balance": "100.00"
}
]
}
Technical Details
Light Protocol Integration
zkCompression uses the following Light Protocol packages:
import { Rpc, createRpc } from "@lightprotocol/stateless.js";
import { compress, decompress } from "@lightprotocol/compressed-token";
Wallet Security
zkCompression implements wallet mutex locking and private key zeroization for security:
- Mutex locking prevents concurrent wallet access
- Private keys are zeroized from memory after use
- Automatic retry polling for RPC indexer sync
- Auto-create Associated Token Account during decompression
RPC Configuration
zkCompression uses Helius RPC with Light Protocol extensions:
const connection = createRpc(
process.env.HELIUS_RPC_URL,
process.env.HELIUS_RPC_URL, // Compression RPC
process.env.HELIUS_RPC_URL // Prover RPC
);
Error Handling
| Error | Cause | Solution |
|---|
Account not found | ATA doesn’t exist | Auto-created during decompression |
Insufficient balance | Not enough tokens | Check balance with zk tokens |
RPC indexer sync | Indexer lag | Automatic retry polling handles this |
Example: Full Compression Flow
# 1. Check current balances
> zk tokens
USDC: 1000.00 (Regular)
# 2. Compress 0.1 SOL
> zk light compress 0.1 --from mysol
Compressing SOL...
Transaction: 5abc...
COMPRESSION SUCCESSFUL
Amount: 0.1 SOL
TxHash: 5abc...
RENT SAVINGS:
Standard: 2039280 lamports
Compressed: 0 lamports (NO RENT!)
# 3. Check account info
> zk light account-info <your-address>
COMPRESSED ACCOUNT INFO
Address: <your-address>
SOL Balance: 0.1 SOL
# 4. Decompress when needed
> zk light decompress 0.05 --from mysol
Decompressing SOL...
Transaction: 6def...
DECOMPRESSION SUCCESSFUL
Amount: 0.05 SOL
TxHash: 6def...