Learn getMultipleAccounts use cases, code examples, request parameters, response structure, and tips.
getMultipleAccounts
RPC method is a highly efficient way to fetch information for a list of Solana accounts simultaneously. Instead of making individual getAccountInfo
requests for each account, getMultipleAccounts
allows you to batch these requests, reducing network overhead and improving the responsiveness of your application.
pubkeys
(array
of string
, required):
["So11111111111111111111111111111111111111112", "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"]
options
(object
, optional): A configuration object containing one or more of the following fields:
commitment
(string
): Specifies the commitment level for the query (e.g., "finalized"
, "confirmed"
, "processed"
).encoding
(string
): The encoding for the account data. Options include:
"base64"
(default): Standard base64 encoding."base58"
: Slower, but may be useful in some contexts."base64+zstd"
: Base64 encoded zstd compressed data."jsonParsed"
: If the account is owned by a program for which the RPC node has a parser (e.g., SPL Token Program, Stake Program), the data
field will be a JSON object. This is very useful for structured data.dataSlice
(object
): Allows you to fetch only a specific portion of the account data. This is useful for large accounts where you only need a small piece of information.
offset
(usize
): The offset in bytes from the start of the account data.length
(usize
): The number of bytes to return from the offset.dataSlice
is only available for base58
, base64
, or base64+zstd
encodings.minContextSlot
(u64
): The minimum slot that the request can be evaluated at.result
field containing:
context
(object
):
slot
(u64
): The slot at which the information was retrieved.apiVersion
(string
, optional): The API version of the node.value
(array
):
pubkeys
array.null
: If the account at the specified public key does not exist or an error occurred for that specific account.lamports
(u64
): The number of lamports owned by the account.owner
(string
): The base-58 encoded public key of the program that owns the account.data
(array
or object
): The account data. If encoding
is jsonParsed
and a parser exists, this will be a JSON object. Otherwise, it’s typically an array ["encoded_string", "encoding_format"]
(e.g., ["SGVsbG8=", "base64"]
).executable
(boolean
): Whether the account contains a program (is executable).rentEpoch
(u64
): The next epoch at which this account will owe rent.space
(u64
): The data length of the account in bytes.jsonParsed
encoding to get structured data.
value
array for null
.jsonParsed
Convenience: Using jsonParsed
encoding is highly recommended when dealing with common account types like SPL Token accounts, as it saves you from manual deserialization.dataSlice
for Large Accounts: For very large accounts (e.g., some program state accounts), use dataSlice
to fetch only the necessary bytes to avoid excessive data transfer.null
entries in the response value
array, indicating that an account was not found or could not be fetched.getMultipleAccounts
, you can build more performant and scalable Solana applications.