Program ID
Overview
The Light System program acts as the gateway for all compressed account operations. It coordinates between your program, the Account Compression program, and the ZK proof verification system.Key Responsibilities
State Validation
Verifies compressed account ownership and signatures
Proof Verification
Validates ZK proofs for state transitions
CPI Context
Manages cross-program invocation contexts
Tree Coordination
Coordinates with Account Compression for updates
Core Instructions
Invoke
Executes compressed account operations directly from user programs.Contains all data for the compressed account operation:
input_compressed_accounts_with_merkle_context: Accounts being spent/nullifiedoutput_compressed_accounts: New accounts being createdrelay_fee: Optional fee for transaction relaycompress_or_decompress_lamports: Lamport transfer amountis_compress: Whether operation compresses or decompressesproof: Zero-knowledge proof for the state transition (optional)
authority(signer): Must own all input compressed accountsregistered_program_pda: Proof that caller program is registerednoop_program: Event logging programaccount_compression_authority: PDA authority for compression programaccount_compression_program: Account Compression programsol_pool_pda: Optional SOL pool for compression/decompressiondecompression_recipient: Optional recipient for decompressed lamports- Remaining accounts: Merkle trees, nullifier queues, and address trees
- Verifies authority owns all input compressed accounts
- Validates ZK proof if provided
- Nullifies input accounts in Merkle trees
- Creates output accounts
- Handles lamport compression/decompression
programs/system/src/lib.rs:94
InvokeCpi
Executes compressed account operations via CPI from another program.Similar to Invoke, but includes:
invoking_program: Program making the CPI callcpi_context_account: Context account for the CPI- All fields from InstructionDataInvoke
- Authority check is deferred to the invoking program
- Requires a CPI context account to track program state
- Enables composability between compressed programs
programs/system/src/lib.rs:119
InvokeCpiWithReadOnly
CPI invocation with read-only compressed account support.Specifies which accounts are read-only:
ReadOnly: All accounts are read-onlyWriteOnly: All accounts are writableMixed: Some accounts read-only, some writable
programs/system/src/lib.rs:139
InvokeCpiWithAccountInfo
CPI invocation with additional account information for complex operations. Use Case: Advanced operations requiring extra metadata Source:programs/system/src/lib.rs:155
InitializeCpiContextAccount
Creates a CPI context account for a program to use InvokeCpi. Accounts:fee_payer(signer): Pays for account creationcpi_context_account(writable): Context account to initializeassociated_merkle_tree: Tree the context is bound to
- Derives PDA for CPI context account
- Allocates account with sufficient space
- Initializes context with program and tree information
programs/system/src/accounts/init_context_account.rs
Account Types
CPI Context Account
Stores state for cross-program invocations.Account type identifier
Program that created this context
Associated Merkle tree for this context
PDA bump seed
State Validation Flow
Usage in Custom Programs
Basic Invoke Example
InvokeCpi from Your Program
Proof Verification
The Light System program integrates with the ZK proof verifier:Proof Structure
Proof Structure
When Proofs are Required
When Proofs are Required
- Required: When nullifying existing compressed accounts
- Optional: When only creating new compressed accounts
- Not Required: Read-only operations
Proof Generation
Proof Generation
Proofs are generated off-chain by the Light Prover service:SDK automatically requests proofs when needed:
Error Codes
| Code | Name | Description |
|---|---|---|
| 3000 | InvalidAuthority | Authority does not own compressed accounts |
| 3001 | InvalidProof | ZK proof verification failed |
| 3002 | InvalidMerkleContext | Merkle context doesn’t match account |
| 3003 | SumCheckFailed | Input/output sum mismatch |
| 3004 | InvalidAccountData | Compressed account data invalid |
| 3005 | AccountNotFound | Referenced account not found in tree |
| 3006 | InvalidCpiContext | CPI context account invalid |
| 3007 | ProgramNotRegistered | Calling program not registered |
programs/system/src/errors.rs
SDK Support
The Light System program has extensive SDK support:Source Code
View the full source code on GitHub:Next Steps
Compressed Token Program
See how tokens use the system program
Build Custom Program
Build with compressed accounts