Retrieve compressed account information by address or hash. RPC method guide with use cases, tips and examples.
getCompressedAccount RPC method retrieves information about a specific compressed account using either its address or hash. Information includes the compressed account state, balance, and metadata.
address (string, optional): The base-58 encoded address of the compressed account to query.hash (string, optional): The base-58 encoded 32-byte hash of the compressed account.address OR hash must be provided, but not both. If neither is provided, the request will fail.
Response
Returns compressed account information directly, or null if account not found:
hash (string): The 32-byte hash of the compressed account as a base-58 string.owner (string): The base-58 encoded public key of the program that owns this account.lamports (number): The number of lamports owned by the account.tree (string): The public key of the merkle tree storing this account.leafIndex (number): The leaf index of this account in the merkle tree.seq (number): The sequence number of this account.slotCreated (number): The slot when this account was created.data (object, optional): The account data object containing:
discriminator (BN): The account discriminator as BN object.data (string): Base64 encoded account data.dataHash (string): The 32-byte hash of the account data.address when you know the account’s derived address, and hash when you have the specific hash from a previous query or transactionhash parameter, pass the hash value directly as returned from other RPC methods (like getCompressedAccountsByOwner). Hash values must be used immediately after retrieval for accurate resultsnull before accessing account properties, as the account may not existleafIndex, tree, and seq fields are crucial for generating merkle proofs when updating or transferring compressed accountsdata field contains program-specific information. Use the discriminator to identify the account type and parse the data accordinglydataHash field allows you to verify the integrity of the account data without storing the full data on-chainDependencies & Setup
Cargo.toml:An ID to identify the request.
test-account The version of the JSON-RPC protocol.
2.0 The name of the method to invoke.
getCompressedAccount Request for compressed account data
{
"address": null,
"hash": "11111111111111111111111111111111"
}