Overview
This quickstart guide will walk you through creating a compressed token mint, minting tokens, and transferring them - all with dramatically reduced storage costs compared to standard SPL tokens.By the end of this guide, you’ll have a working compressed token application running on a local test validator.
Prerequisites
Start Test Validator
Open a new terminal and start the Light Protocol test validator:Keep this terminal running. The validator includes all Light Protocol programs pre-deployed and a local ZK prover service.
- All Light Protocol programs (Account Compression, System, Compressed Token, Registry)
- Local ZK Prover at
http://127.0.0.1:3001 - Local Photon Indexer at
http://127.0.0.1:8784 - Solana RPC at
http://127.0.0.1:8899
Create Your Application
Create a new fileindex.ts:
index.ts
Run the Application
Execute your script:Congratulations! You’ve successfully created and used compressed tokens on Solana.
What Just Happened?
Let’s break down what your application did:Created a Compressed Mint
Created a Compressed Mint
Instead of creating a regular SPL Token mint (which costs rent), you created a compressed mint that stores only a small fingerprint on-chain. The full mint data is stored in the cheaper Solana ledger space.Cost Savings: ~99.8% reduction compared to SPL Token
Minted Compressed Tokens
Minted Compressed Tokens
The
mintTo function created compressed token accounts stored in Merkle trees. These accounts:- Have no rent burden
- Are fully composable with other programs
- Support standard SPL Token operations
Transferred Tokens
Transferred Tokens
The
transfer function:- Generated a zero-knowledge proof of account ownership
- Nullified the old account state in the tree
- Created new account states for sender and recipient
- Updated the Merkle tree roots on-chain
Queried Balances
Queried Balances
The
getCompressedTokenBalance RPC method queried the Photon indexer, which:- Indexes all compressed account state
- Provides fast queries by owner/mint
- Maintains Merkle proofs for transactions
Cost Comparison
Here’s what you saved compared to regular SPL tokens:| Operation | SPL Token | Compressed Token | Savings |
|---|---|---|---|
| Create Mint | 0.00144 SOL | 0.000005 SOL | 99.7% |
| Create Account | 0.00203 SOL | 0.000005 SOL | 99.8% |
| Mint Tokens | 0.000005 SOL | 0.000005 SOL | 0% |
| Transfer | 0.000005 SOL | ~0.00002 SOL | -300% |
Transfers are slightly more expensive due to ZK proof verification, but the overall savings on account creation far outweigh this cost.
Using the CLI
You can also use the CLI for quick operations:Next Steps
Now that you’ve built your first compressed token app, explore more advanced features:Compressed Tokens Guide
Learn about batch operations, delegation, and Token-2022 extensions
Compressed PDAs
Build custom programs with compressed state
JavaScript SDK
Explore the full SDK API
Testing
Write tests for your compressed applications
Troubleshooting
Test validator fails to start
Test validator fails to start
Make sure no other Solana validator is running:
Airdrop fails
Airdrop fails
The local validator may be slow to start. Wait 10 seconds and try again, or check if the validator is running:
Import errors
Import errors
Ensure you’re using TypeScript with
tsx or compile first:RPC connection errors
RPC connection errors
Verify the test validator is running and the endpoints are correct:
- Solana RPC:
http://127.0.0.1:8899 - Photon Indexer:
http://127.0.0.1:8784 - ZK Prover:
http://127.0.0.1:3001
Example Projects
Check out complete example projects:Node.js Client
Complete Node.js example with compressed tokens
Web Client
React web application example
Program Examples
Solana program integration examples
GitHub Repo
Main Light Protocol repository