Overview
The compressed token program (cTokenmWW8bLPjZEBAUgYy3zKxQZW6VKi7bqNFEVv3m) implements SPL Token-compatible operations for compressed tokens. Instructions support both compressed accounts (in Merkle trees) and decompressed CToken accounts (standard Solana accounts).
Program ID: cTokenmWW8bLPjZEBAUgYy3zKxQZW6VKi7bqNFEVv3mDocumentation: Compressed Token Program
Instruction Categories
Token Operations
Transfer2, MintAction, Freeze, Thaw
Account Management
Create, Close token accounts
CToken Operations
Transfer, Approve, Burn, Mint
Discriminator Reference
Compressed Token Operations
| Instruction | Discriminator | SPL Compatible |
|---|---|---|
| Transfer2 | 101 | No |
| MintAction | 103 | No |
| Freeze | Anchor | No |
| Thaw | Anchor | No |
CToken Account Operations
| Instruction | Discriminator | SPL Equivalent |
|---|---|---|
| CreateTokenAccount | 18 | InitializeAccount3 |
| CreateAssociatedTokenAccount | 100 | - |
| CreateAssociatedTokenAccountIdempotent | 102 | - |
| CloseTokenAccount | 9 | CloseAccount |
CToken Transfer & Approval
| Instruction | Discriminator | SPL Equivalent |
|---|---|---|
| CTokenTransfer | 3 | Transfer |
| CTokenTransferChecked | 12 | TransferChecked |
| CTokenApprove | 4 | Approve |
| CTokenRevoke | 5 | Revoke |
CToken Mint & Burn
| Instruction | Discriminator | SPL Equivalent |
|---|---|---|
| CTokenMintTo | 7 | MintTo |
| CTokenMintToChecked | 14 | MintToChecked |
| CTokenBurn | 8 | Burn |
| CTokenBurnChecked | 15 | BurnChecked |
CToken Freeze
| Instruction | Discriminator | SPL Equivalent |
|---|---|---|
| CTokenFreezeAccount | 10 | FreezeAccount |
| CTokenThawAccount | 11 | ThawAccount |
Rent Management
| Instruction | Discriminator | SPL Compatible |
|---|---|---|
| Claim | 104 | No |
| WithdrawFundingPool | 105 | No |
Transfer2
Discriminator: 101Enum:
InstructionType::Transfer2
Batch transfer instruction supporting compress, decompress, and transfer operations.
Instruction Data
Input compressed token accounts to spend (with Merkle proofs)
Output compressed token accounts to create
Transfers between CToken (decompressed) accounts
Amounts to compress or decompress
True for compress operations, false for decompress
Operations
Transfer Compressed
Transfer Compressed
Transfer between compressed token accounts.Flow:
- Verify inclusion proofs for input accounts
- Sum check: inputs = outputs
- Insert nullifiers for spent accounts
- Insert output account hashes into queue
Compress
Compress
Convert CToken account to compressed token.Flow:
- Verify CToken account ownership
- Burn tokens from CToken account
- Create compressed token account
- Optionally close CToken account
Decompress
Decompress
Convert compressed token to CToken account.Flow:
- Verify inclusion proof for compressed account
- Insert nullifier (spend compressed account)
- Mint tokens to CToken account
Example
MintAction
Discriminator: 103Enum:
InstructionType::MintAction
Batch instruction for mint management and minting operations.
Actions
| Action | Description |
|---|---|
| CreateCompressedMint | Create new compressed mint |
| MintTo | Mint compressed tokens |
| UpdateMintAuthority | Change mint authority |
| UpdateFreezeAuthority | Change freeze authority |
| MintToCToken | Mint to CToken account |
| UpdateMetadataField | Update token metadata |
| UpdateMetadataAuthority | Change metadata authority |
| RemoveMetadataKey | Remove metadata field |
| DecompressMint | Convert to SPL mint |
| CompressAndCloseCMint | Compress and close mint account |
Instruction Data
Example: Mint Tokens
CToken Instructions
CTokenTransfer
Discriminator: 3SPL Equivalent: Transfer Transfer tokens between CToken accounts.
- Source CToken account (mut)
- Destination CToken account (mut)
- Authority (signer)
CTokenApprove
Discriminator: 4SPL Equivalent: Approve Approve delegate for CToken account.
- CToken account (mut)
- Delegate
- Owner (signer)
CTokenMintTo
Discriminator: 7SPL Equivalent: MintTo Mint tokens to CToken account.
- Mint
- Destination CToken account (mut)
- Mint authority (signer)
CTokenBurn
Discriminator: 8SPL Equivalent: Burn Burn tokens from CToken account.
- CToken account (mut)
- Mint (mut)
- Authority (signer)
Account Management
CreateTokenAccount
Discriminator: 18SPL Equivalent: InitializeAccount3 Create CToken account.
CloseTokenAccount
Discriminator: 9SPL Equivalent: CloseAccount Close CToken account and reclaim rent. Rent distribution:
- If compressible: rent → rent recipient
- Remaining lamports → destination account
Rent Management
Claim
Discriminator: 104Enum:
InstructionType::Claim
Claim rent from expired compressible accounts.
- Account must be compressible
- Rentability period expired
- Rent authority matches
WithdrawFundingPool
Discriminator: 105Enum:
InstructionType::WithdrawFundingPool
Withdraw from rent recipient pool.
Error Codes
Common error codes (30000+ range):| Code | Error | Description |
|---|---|---|
| 30001 | InsufficientFunds | Not enough tokens |
| 30002 | InvalidMint | Wrong mint for operation |
| 30003 | InvalidAuthority | Authority check failed |
| 30004 | InvalidDelegate | Delegate check failed |
| 30005 | AccountFrozen | Account is frozen |
| 30006 | MintHasNoFreezeAuthority | Mint cannot freeze |
| 30007 | SumCheckFailed | Inputs != outputs |
| 30008 | InvalidProof | ZK proof verification failed |
| 30009 | DecompressionError | Failed to decompress |
| 30010 | CompressionError | Failed to compress |
Best Practices
Always Validate Proofs
Always Validate Proofs
Transfer2 requires valid ZK proofs. Never skip proof validation.
Check Sum Constraints
Check Sum Constraints
For transfers, verify that total inputs equal total outputs (including fees).
Handle Tree Rollovers
Handle Tree Rollovers
When Merkle trees roll over, update account Merkle context references.
Use Batch Operations
Use Batch Operations
Transfer2 and MintAction support batching. Combine operations for efficiency.
Resources
Program Source
View on GitHub
Instruction Docs
Detailed instruction reference
SDK
TypeScript SDK
Examples
Program examples