Skip to main content
POST
cURL
ThegetCompressedAccountsByOwner 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.
Common Use Cases
  • 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
Parameters
  1. owner (PublicKey, required): Base58-encoded public key of the account owner to query compressed accounts for.
  2. options (object, optional): Configuration object for filtering and pagination:
    • filters (array, optional): Array of filter objects to narrow results by specific criteria
    • dataSlice (object, optional): Slice of account data to return with offset and length fields
    • cursor (string, optional): Cursor for pagination from previous response to fetch next page
    • limit (BN, optional): Maximum number of accounts to return (use bn() helper)
Note: All options parameters are optional. Without filters, returns all compressed accounts for the owner. Response The response contains a paginated list of compressed accounts:
  • items (array): Array of compressed account objects with merkle context
    • hash (string): Unique hash identifying the account for merkle proof generation
    • address (string, optional): Account address if available
    • lamports (number): Account balance in lamports
    • owner (string): Public key of the account owner
    • data (object): Account data information including discriminator and data hash
    • tree (string): Public key of the merkle tree storing this account
    • leafIndex (number): Position of account in the merkle tree
    • seq (number): Sequence number for account ordering
    • slotCreated (number): Slot when account was created
  • cursor (string | null): Pagination cursor for next batch, null if no more results
Developer Tips
  • 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
Troubleshooting
Owner has no compressed accountsThis is normal for new addresses or those that haven’t used compression:
Too many accounts returned at onceUse pagination and data slicing to reduce response size:
Examples The below examples work - just make sure you installed the dependencies.
For Rust examples: Requires light-client, solana-sdk, anyhow, and tokio crates. See Rust example comments for setup details.
Example: Get All Compressed Accounts
Example: Paginated Account Discovery with Balance Aggregation
TypeScript
Example: Filter by Data Slice

Body

application/json
id
enum<string>
required

An ID to identify the request.

Available options:
test-account
jsonrpc
enum<string>
required

The version of the JSON-RPC protocol.

Available options:
2.0
method
enum<string>
required

The name of the method to invoke.

Available options:
getCompressedAccountsByOwner
params
object
required

Response

id
enum<string>
required

An ID to identify the response.

Available options:
test-account
jsonrpc
enum<string>
required

The version of the JSON-RPC protocol.

Available options:
2.0
error
object
result
object