Program ID
Overview
The Compressed Token program enables rent-free token operations through ZK compression while maintaining full compatibility with SPL Token interfaces. Tokens can exist in two forms:- Compressed Tokens: Stored as leaves in Merkle trees (rent-free)
- CToken Accounts: Decompressed Solana accounts (SPL-compatible layout)
Key Features
SPL Compatible
Matches SPL Token instruction interface
Token-2022 Extensions
Supports metadata, transfer fees, and more
Compression/Decompression
Seamlessly move between compressed and decompressed
Rent Management
Compressible extension for rent reclamation
Account Types
Compressed Token (TokenData)
Compressed token account stored in a Merkle tree.Compressed mint address
Token account owner
Token balance
Optional delegate authority
Account state: Initialized, Frozen, or Uninitialized
Type-length-value encoded extensions (for Token-2022 compatibility)
- V1:
[2, 0, 0, 0, 0, 0, 0, 0](little-endian, Poseidon hashed) - V2:
[0, 0, 0, 0, 0, 0, 0, 3](big-endian, Poseidon hashed) - ShaFlat:
[0, 0, 0, 0, 0, 0, 0, 4](big-endian, SHA-256 truncated)
program-libs/token-interface/src/state/compressed_token/token_data.rs
CToken Account (Decompressed)
Solana account with SPL Token-compatible layout.Mint address (compressed or decompressed)
Account owner
Token balance
Optional delegate
Initialized, Frozen, or Uninitialized
Native token amount (not supported)
Amount delegated to delegate
Authority that can close the account
Token-2022 extensions:
Compressible: Rent management dataPausableAccount: Pausable account markerPermanentDelegate: Permanent delegate markerTransferHook: Transfer hook configurationTransferFee: Transfer fee configuration
[owner, program_id, mint]
Source: program-libs/token-interface/src/state/ctoken/ctoken_struct.rs
Compressed Mint
Mint account for compressed tokens.Authority that can mint tokens
Total supply of tokens minted
Number of decimals
Whether mint is initialized
Authority that can freeze accounts
Optional Token-2022 metadata extension:
name: Token namesymbol: Token symboluri: Metadata URI
program-libs/token-interface/src/state/mint/compressed_mint.rs
Instruction Reference
Token Account Management
CreateTokenAccount (18)
CreateTokenAccount (18)
Creates a regular CToken account.Accounts:
fee_payer(signer, writable)authority(signer)token_account(writable): Account to createmint: Mint accountcompressible_config: Optional config for compressible extensionrent_recipient: Optional rent sponsorsystem_program
compressible: Whether to add Compressible extension
programs/compressed-token/program/src/ctoken/create.rsCreateAssociatedTokenAccount (100)
CreateAssociatedTokenAccount (100)
Creates an associated token account (deterministic address).Derivation: Seeds
[owner, program_id, mint]Source: programs/compressed-token/program/src/ctoken/create_ata.rsCreateAssociatedTokenAccountIdempotent (102)
CreateAssociatedTokenAccountIdempotent (102)
Creates ATA, succeeds if already exists.Use Case: Safe to call multiple timesSource:
programs/compressed-token/program/src/ctoken/create_ata.rsCloseTokenAccount (9)
CloseTokenAccount (9)
Closes a CToken account.Process:
- Requires zero balance
- Returns rent exemption to rent recipient (if compressible)
- Returns remaining lamports to destination
programs/compressed-token/program/src/ctoken/close/Transfer Operations
Transfer2 (101)
Transfer2 (101)
Batch transfer instruction supporting multiple operations.Modes:
- Compress: Convert SPL/CToken to compressed token
- Decompress: Convert compressed token to CToken
- CompressAndClose: Compress CToken and close account
- Transfer: Standard compressed token transfer
inputs: Input compressed tokens (to spend)outputs: Output compressed tokens (to create)mint_indices: Multi-mint support (map outputs to mints)compression_indices: Map compression operations to inputsproof: ZK proof for state transitions
programs/compressed-token/program/src/compressed_token/transfer2/CTokenTransfer (3)
CTokenTransfer (3)
Transfer between CToken accounts (decompressed).Accounts:
source(writable): Source CToken accountdestination(writable): Destination CToken accountauthority(signer): Source owner or delegate
amount: Amount to transfer
programs/compressed-token/program/src/ctoken/transfer/default.rsCTokenTransferChecked (12)
CTokenTransferChecked (12)
Transfer with decimals validation.Additional Parameter:
decimals: Must match mint decimals
programs/compressed-token/program/src/ctoken/transfer/checked.rsMint Operations
MintAction (103)
MintAction (103)
Batch instruction for mint management and minting.Actions:
CreateCompressedMint: Create new compressed mintMintTo: Mint to compressed tokenMintToCToken: Mint to CToken accountUpdateMintAuthority: Change mint authorityUpdateFreezeAuthority: Change freeze authorityUpdateMetadataField: Update metadata (name, symbol, URI)UpdateMetadataAuthority: Change metadata authorityRemoveMetadataKey: Remove metadata fieldDecompressMint: Convert compressed mint to SPL mintCompressAndCloseCMint: Compress mint and close CToken
programs/compressed-token/program/src/compressed_token/mint_action/CTokenMintTo (7)
CTokenMintTo (7)
Mint tokens to CToken account.Accounts:
mint(writable): Mint accountdestination(writable): CToken accountauthority(signer): Mint authority
amount: Amount to mint
programs/compressed-token/program/src/ctoken/mint_to.rsCTokenMintToChecked (14)
CTokenMintToChecked (14)
Mint with decimals validation.Additional Parameter:
decimals: Must match mint
programs/compressed-token/program/src/ctoken/mint_to.rsBurn Operations
CTokenBurn (8)
CTokenBurn (8)
Burn tokens from CToken account.Accounts:
token_account(writable): Account to burn frommint(writable): Mint to decrease supplyauthority(signer): Owner or delegate
amount: Amount to burn
programs/compressed-token/program/src/ctoken/burn.rsCTokenBurnChecked (15)
CTokenBurnChecked (15)
Burn with decimals validation.Source:
programs/compressed-token/program/src/ctoken/burn.rsDelegate Operations
CTokenApprove (4)
CTokenApprove (4)
Approve a delegate on CToken account.Accounts:
token_account(writable): Account to delegatedelegate: Delegate addressowner(signer): Account owner
amount: Amount to delegate
programs/compressed-token/program/src/ctoken/approve_revoke.rsCTokenRevoke (5)
CTokenRevoke (5)
Revoke delegate from CToken account.Source:
programs/compressed-token/program/src/ctoken/approve_revoke.rsFreeze Operations
CTokenFreezeAccount (10)
CTokenFreezeAccount (10)
Freeze a CToken account.Accounts:
token_account(writable): Account to freezemint: Mint accountauthority(signer): Freeze authority
programs/compressed-token/program/src/ctoken/freeze_thaw.rsCTokenThawAccount (11)
CTokenThawAccount (11)
Thaw a frozen CToken account.Effect: Sets account state back to InitializedSource:
programs/compressed-token/program/src/ctoken/freeze_thaw.rsRent Management (Compressible Extension)
Claim (104)
Claim (104)
Claims rent from expired compressible accounts.Accounts:
rent_recipient(writable): Receives claimed renttoken_account(writable): Compressible account to claim fromcompressible_config: Config with expiry settingsrent_authority: Optional authority for claiming
- Account must be compressible (
is_compressible()returns true) - Config must not be inactive
- Checks if account is expired based on config
- Transfers rent exemption to rent recipient
- Closes the account
programs/compressed-token/program/src/compressible/claim.rsWithdrawFundingPool (105)
WithdrawFundingPool (105)
Withdraws funds from rent recipient pool.Accounts:
rent_recipient(writable): Rent recipient accountdestination(writable): Withdrawal destinationcompressible_config: Associated configrent_sponsor(signer): Must match config
amount: Amount to withdraw
programs/compressed-token/program/src/compressible/withdraw_funding_pool.rsToken-2022 Extensions
The Compressed Token program supports these Token-2022 extensions:TokenMetadata
Name, symbol, URI for mints
Compressible
Custom extension for rent management
TransferFee
Configurable transfer fees
TransferHook
Custom transfer validation
PausableAccount
Account can be paused
PermanentDelegate
Permanent delegate authority
programs/compressed-token/program/src/extensions/
Usage Examples
Creating a Compressed Token
Transferring Compressed Tokens
Compressing SPL Tokens
Decompressing to CToken Account
Error Codes
| Code | Name | Description |
|---|---|---|
| 4000 | MintMismatch | Token accounts have different mints |
| 4001 | InsufficientFunds | Insufficient balance for operation |
| 4002 | InvalidMint | Mint account invalid or uninitialized |
| 4003 | OwnerMismatch | Authority doesn’t match owner |
| 4004 | AccountFrozen | Account is frozen |
| 4005 | InvalidDelegate | Delegate not authorized |
| 4006 | MintDecimalsMismatch | Decimals don’t match mint |
| 4007 | SumCheckFailed | Input/output amounts don’t match |
| 4008 | InvalidExtension | Token-2022 extension validation failed |
| 4009 | CompressibleConfigInactive | Config is inactive |
| 4010 | NotCompressible | Account not eligible for compression |
programs/compressed-token/anchor/src/lib.rs(ErrorCode enum)program-libs/token-interface/src/error.rs(CTokenError enum)
Source Code
View the full source code on GitHub:Next Steps
Token Quickstart
Build your first compressed token app
Registry Program
Learn about protocol configuration