Documentation Index
Fetch the complete documentation index at: https://luminouslabs-cc5545c6-bump-sdks.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Overview
This guide assumes you are familiar with transactions on Solana. If you aren’t, we recommend to read the Solana documentation on transactions.
- Instructions must specify the list of all compressed accounts being read or written to.
- To read or write to a compressed account, the instruction must send the current account state on-chain and prove its validity.
- Each unique state tree that gets read or written to (via any compressed account) needs to be specified as per Solana’s regular on-chain account access lists.
Reading Compressed Accounts
Reading compressed accounts follows a similar pattern to Solana accounts.- The main difference is that compressed account RPC methods query an indexer instead of the ledger directly.
- The indexer, called Photon, reconstructs compressed account state from the Solana ledger by reading transaction logs.
| Solana RPC | Photon RPC Calls |
|---|---|
| getAccountInfo | getCompressedAccount |
| getBalance | getCompressedBalance |
| getTokenAccountsByOwner | getCompressedTokenAccountsByOwner |
| getProgramAccounts | getCompressedAccountsByOwner |
- Clients
- Programs
Clients read compressed accounts similar to Solana accounts:
- Fetch the compressed account data from your RPC provider using its address or hash
- Here you use
getCompressedAccount(), similar togetAccountInfo().
- Here you use
- Deserialize the account’s data field into the appropriate data structure.
Writing to Compressed Accounts
Writing to compressed accounts can be described more generally as:- Fetch the compressed account data from your RPC provider using its address or hash
- Fetch a validity proof from your RPC provider using the account hash via
getValidityProof()to prove the account hash exists in the state tree.
address: persistent identifier of the compressed account (unchanged)owner program: program ID that owns this account (unchanged)data: current account datadata': updated account datavalidity proof: 128-byte ZK proof that verifies the current account hash exists in the state tree
See this guide to update a compressed account.
.png?fit=max&auto=format&n=EvBEH3OpOSn_oCxU&q=85&s=f4c884d9befd136cb8ebd93d4fe013d8)
On-chain Execution
To write compressed state, a program invokes the Light System Program via CPI. The system program then does the following:- Runs relevant checks (sum check, etc.)
- Verifies the validity proof
- Nullifies the existing leaf of the compressed account that is being written to, to prevent double spending.
- Appends the new compressed account hash to the state tree and advances the tree’s state root
- Emits the new compressed account state onto the Solana ledger
- Before Tx Execution
- After Tx Execution
.png?fit=max&auto=format&n=LDeRKfgrXmDGno5L&q=85&s=883e0e6ade2e98433588129a109aeaf0)
.png?fit=max&auto=format&n=LDeRKfgrXmDGno5L&q=85&s=a50e05d039944e1bd8d10ed130591779)