cURL
JSON RPC Methods
Getcompressedaccountsbyowner
Retrieve all compressed accounts owned by a specific address. RPC method guide with use cases, tips and examples.
POST
cURL
The
Common Use Cases
Examples
The below examples work - just make sure you installed the dependencies.
For Rust examples: Requires
Example: Get All Compressed Accounts
Example: Paginated Account Discovery with Balance Aggregation
Example: Filter by Data Slice
getCompressedAccountsByOwner RPC method returns all compressed accounts owned by a specific address, with support for filtering, pagination, and data slicing.
You can test this method via the OpenAPI example or custom examples below.
- Portfolio Discovery: Find all compressed accounts for a wallet
- Token Account Enumeration: Discover user’s compressed token holdings
- Account Migration: Identify accounts to migrate from regular to compressed
- Balance Aggregation: Calculate total holdings across all accounts
owner(PublicKey, required): Base58-encoded public key of the account owner to query compressed accounts for.options(object, optional): Configuration object for filtering and pagination:filters(array, optional): Array of filter objects to narrow results by specific criteriadataSlice(object, optional): Slice of account data to return withoffsetandlengthfieldscursor(string, optional): Cursor for pagination from previous response to fetch next pagelimit(BN, optional): Maximum number of accounts to return (usebn()helper)
items(array): Array of compressed account objects with merkle contexthash(string): Unique hash identifying the account for merkle proof generationaddress(string, optional): Account address if availablelamports(number): Account balance in lamportsowner(string): Public key of the account ownerdata(object): Account data information including discriminator and data hashtree(string): Public key of the merkle tree storing this accountleafIndex(number): Position of account in the merkle treeseq(number): Sequence number for account orderingslotCreated(number): Slot when account was created
cursor(string | null): Pagination cursor for next batch, null if no more results
- Pagination Strategy: Use cursor-based pagination for owners with many accounts to avoid timeouts and ensure consistent results
- Data Slicing Optimization: Implement data slicing when you only need account metadata to reduce response size and improve performance
- Empty Response Handling: Handle cases gracefully where new addresses have no compressed accounts - this is normal behavior
- Caching Considerations: Cache results appropriately as compressed account states can change with each transaction
- Batch Size: Start with smaller batch sizes (50-100) and adjust based on response times and data needs
No accounts found
No accounts found
Owner has no compressed accountsThis is normal for new addresses or those that haven’t used compression:
Request timeout with large responses
Request timeout with large responses
Too many accounts returned at onceUse pagination and data slicing to reduce response size:
Dependencies & Setup
Dependencies & Setup
light-client, solana-sdk, anyhow, and tokio crates. See Rust example comments for setup details.- TypeScript
- cURL
- Rust
TypeScript
Body
application/json
An ID to identify the request.
Available options:
test-account The version of the JSON-RPC protocol.
Available options:
2.0 The name of the method to invoke.
Available options:
getCompressedAccountsByOwner