Learn getAccountInfo use cases, code examples, request parameters, response structure, and tips.
getAccountInfo
RPC method is a fundamental tool for querying the Solana blockchain. It allows you to retrieve all stored information associated with a specific account public key. This includes the account’s lamport balance, the program that owns it, whether it’s executable, and its stored data.
publicKey
(string, required): The base-58 encoded public key of the account to query.
config
(object, optional): A configuration object with the following fields:
commitment
(string, optional): Specifies the commitment level to use for the query. Defaults to finalized
.
finalized
: The node will query the most recent block confirmed by the supermajority of the cluster as having reached maximum lockout.confirmed
: The node will query the most recent block that has been voted on by a supermajority of the cluster.processed
: The node will query its most recent block. Note that the block may not be complete.encoding
(string, optional): The encoding for account data. Defaults to base64
.
base58
(slow)base64
base64+zstd
(if data is compressed)jsonParsed
: If the account data is a known program state (e.g., token accounts, stake accounts), the node will attempt to parse it into a JSON structure. For generic program accounts, this usually falls back to binary (base64).dataSlice
(object, optional): Limits the returned account data to a specific slice. Only available for base58
, base64
, or base64+zstd
encodings.
offset
(number): The number of bytes from the start of the account data to begin the slice.length
(number): The number of bytes to return.minContextSlot
(number, optional): The minimum slot that the request can be evaluated at.result
field will contain an object with two main properties:
context
(object): Contains metadata about the request.
slot
(number): The slot at which the information was retrieved.apiVersion
(string, optional): The RPC API version.value
(object | null): If the account does not exist, this will be null
. Otherwise, it’s an object containing:
lamports
(number): The number of lamports (1 SOL = 1,000,000,000 lamports) owned by the account.owner
(string): The base-58 encoded public key of the program that owns this account.data
(array | object | string): The data stored in the account. The format depends on the encoding
parameter used in the request.
base64
(default), base58
, base64+zstd
: This is typically an array [encoded_string, encoding_format]
, e.g., ["string_data", "base64"]
.jsonParsed
: This can be a JSON object if the data is parsable by the RPC node (e.g., for SPL Token accounts). Otherwise, it may default to ["", "base64"]
or similar if the data isn’t recognized as a standard layout.executable
(boolean): true
if the account contains a program, false
otherwise.rentEpoch
(number): The next epoch at which this account will owe rent.space
(number, optional): The length of the data in bytes. (Note: The official Solana docs list space
, while some RPC providers might include it. It represents the total space allocated for the account’s data). For more details on account data and deserialization, refer to our detailed guide.value
field in the result will be null
.
9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin
) on mainnet.
Note: Replace YOUR_API_KEY
with your actual Helius API key in the examples below.
getMultipleAccounts
to batch requests and reduce round trips.data
field often requires deserialization based on the owning program’s data structures. Tools and libraries specific to the program (e.g., SPL Token library for token accounts) are usually needed. Our blog post on deserializing account data provides helpful techniques and examples.getAccountInfo
is generally a low-cost query, but frequent polling can add up. Optimize your query patterns.jsonParsed
Wisely: While jsonParsed
can be convenient, it might not support all account types, and its output can change if a program updates its data structures. For critical applications, parsing binary data with a known layout offers more stability.dataSlice
: If you only need a small portion of an account’s data, use dataSlice
to reduce the amount of data transferred and potentially lower query costs.