circle-infogetMultipleAccounts

Explore getMultipleAccounts: Use Cases, Examples, Parameters, Response Format, and Best Practices

The getMultipleAccounts RPC method lets you fetch data for up to 100 accounts in a single call—dramatically reducing network overhead compared to individual getAccountInfo requests. This batch approach improves responsiveness and scalability for applications that need to load or process many accounts at once.


✅ Common Use Cases

  • Batch Account Loading Retrieve data for multiple known accounts (e.g., a user’s token accounts or on-chain configuration accounts) in one request.

  • Portfolio Trackers Simultaneously fetch balances and states for all token accounts owned by a user.

  • Marketplace & NFT UIs Load details of multiple NFT or marketplace item accounts in a single call.

  • dApp Performance Optimization Reduce RPC calls, speed up load times, and enhance user experience when handling large sets of accounts.


🛠 Request Parameters

{
  "pubkeys": ["<base58Pubkey1>", "<base58Pubkey2>", ],  // Required, max 100 keys
  "options": {                                          // Optional
    "commitment": "processed|confirmed|finalized",
    "encoding": "base64|base58|base64+zstd|jsonParsed",
    "dataSlice": { "offset": <number>, "length": <number> },
    "minContextSlot": <u64>
  }
}
  • pubkeys Array of base-58 encoded public keys (max 100).

  • options

    • commitment: Query confirmation level.

    • encoding: How to return account data (jsonParsed for structured formats).

    • dataSlice: Fetch only a byte range (offset + length) for large accounts.

    • minContextSlot: Ensure the data is at least as recent as this slot.


📦 Response Structure

  • context.slot: Slot at which data was retrieved.

  • value: Array matching the order of pubkeys. Each element is either null or an account object.


💡 Examples

  1. Basic Info for Two Accounts

  2. Parsed SPL Token Data


Code Examples

Example Response


🧠 Developer Tips

  • 100-Account Limit: You can request up to 100 accounts per call.

  • Partial Failures: A single failure doesn’t abort the batch—check for null entries.

  • jsonParsed Convenience: Saves manual deserialization for common programs (e.g., SPL Token).

  • Use dataSlice for large accounts to minimize payload size and bandwidth.

  • Handle Nulls Gracefully: Null indicates non-existent accounts or fetch errors—plan your UI/logic accordingly.


By batching account queries with getMultipleAccounts, your Solana application can achieve faster load times and more efficient RPC usage.

2/2Ask ChatGPT

Last updated