Skip to main content

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

  1. Compress: Regular SPL tokens are converted to compressed tokens stored in a Merkle tree state.
  2. Store: Only the Merkle root is stored on-chain, dramatically reducing costs.
  3. Decompress: Compressed tokens can be decompressed back to regular SPL tokens at any time.

Cost Comparison

OperationRegular SPLCompressed
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

zk light 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

zk tokens
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:
  1. Mutex locking prevents concurrent wallet access
  2. Private keys are zeroized from memory after use
  3. Automatic retry polling for RPC indexer sync
  4. 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

ErrorCauseSolution
Account not foundATA doesn’t existAuto-created during decompression
Insufficient balanceNot enough tokensCheck balance with zk tokens
RPC indexer syncIndexer lagAutomatic 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...