getMultipleAccounts

The getMultipleAccounts method returns the account information for multiple accounts simultaneously. This is an optimized version of getAccountInfo that allows fetching data for many accounts in a single RPC call, significantly improving performance for applications that need to query multiple accounts.

Fetching multiple accounts individually would require multiple round-trips to the RPC server, introducing latency and consuming more resources. This method batches account queries into a single request, making it essential for efficient data retrieval. Common use cases include loading portfolio data (multiple token accounts), fetching related program accounts, or retrieving data for a set of NFTs. The method maintains the same flexibility as getAccountInfo for encoding, commitment, and data slicing.

This method is crucial for building responsive user interfaces, efficient data indexers, and any application that needs to display information about multiple accounts simultaneously. Most Solana wallets, DEXes, and NFT platforms rely heavily on this method to minimize latency and provide smooth user experiences. The method preserves the order of requested accounts in the response.

Parameters

parameter
type
description
accountPubkeys
array
Array of account public keys as base-58 encoded strings (maximum 100 accounts)
config
object
Optional configuration object
config.commitment
string
Level of commitment: 'processed', 'confirmed', or 'finalized' (default: 'finalized')
config.encoding
string
Encoding for account data: 'base58' (slow), 'base64', 'base64+zstd', or 'jsonParsed' (default: 'base58')
config.dataSlice
object
Optional. Request a slice of account data. Contains 'offset' (integer) and 'length' (integer)
config.minContextSlot
number
Optional. Minimum slot that the request can be evaluated at

Return Object

field
type
description
context
object
RPC response context with slot information
context.slot
number
The slot at which this data was retrieved
value
array
Array of account information objects in the same order as requested. null for accounts that don't exist
value[].lamports
number
Number of lamports assigned to this account
value[].owner
string
Base-58 encoded public key of the program this account is assigned to
value[].data
array|object|string
Account data in the requested encoding
value[].executable
boolean
Boolean indicating if the account contains a program
value[].rentEpoch
number
The epoch at which this account will next owe rent

Request Example

Request

Response Example

Response

Tip: Maximum 100 accounts per request. The response array matches the request order, with null for non-existent accounts. Use jsonParsed encoding for token accounts to get automatically parsed data. For large batches, split into multiple requests to avoid timeout issues.


Share on
Share on FacebookShare on XShare on LinkedIn
Did you find this page useful?