in-solana by Supanode

getMultipleAccounts — Solana RPC Method

getMultipleAccounts returns account data for up to 100 public keys in a single request. It is the batched version of getAccountInfo — use it whenever you need data for more than one account to save round trips.

Parameters

NameTypeRequiredDescription
pubkeysstring[]YesArray of base-58 encoded public keys. Maximum 100.
commitmentstringNoprocessed, confirmed, or finalized. Default: finalized.
encodingstringNobase58, base64, base64+zstd, jsonParsed. Default: base64.
dataSliceobjectNo{offset: usize, length: usize}. Not available with jsonParsed.
minContextSlotnumberNoMinimum slot at which the request can be evaluated.

Request

curl -X POST https://api.mainnet-beta.solana.com \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "getMultipleAccounts",
    "params": [
      [
        "vines1vzrYbzLMRdu58ou5XTby4qAqVRLmqo36NKPTg",
        "4fYNw3dojWmQ4dXtSGE9epjRGy9pFSx62YypT7avPYvA"
      ],
      {"encoding": "base64"}
    ]
  }'

TypeScript (@solana/kit)

import { createSolanaRpc, address } from "@solana/kit";

const rpc = createSolanaRpc("https://api.mainnet-beta.solana.com");
const accounts = await rpc
  .getMultipleAccounts(
    [
      address("vines1vzrYbzLMRdu58ou5XTby4qAqVRLmqo36NKPTg"),
      address("4fYNw3dojWmQ4dXtSGE9epjRGy9pFSx62YypT7avPYvA"),
    ],
    { encoding: "base64" }
  )
  .send();

for (const account of accounts.value) {
  if (account) {
    console.log(`Balance: ${account.lamports}, Owner: ${account.owner}`);
  } else {
    console.log("Account not found");
  }
}

Response

{
  "jsonrpc": "2.0",
  "result": {
    "context": { "slot": 341200000, "apiVersion": "2.2.4" },
    "value": [
      {
        "data": ["base64-data", "base64"],
        "executable": false,
        "lamports": 1000000000,
        "owner": "11111111111111111111111111111111",
        "rentEpoch": 18446744073709551615,
        "space": 0
      },
      null
    ]
  },
  "id": 1
}
FieldTypeDescription
valuearrayArray of account objects or null, in the same order as the input pubkeys. null means the account does not exist.

Each account object has the same fields as getAccountInfo: data, executable, lamports, owner, rentEpoch, space.

Common errors

  • Too many accounts — exceeding the 100-account limit returns an error.
  • Invalid public key — any malformed base-58 key in the array causes the entire request to fail.
  • Encoding mismatch — using dataSlice with jsonParsed returns an error.

Performance

getMultipleAccounts is significantly more efficient than making individual getAccountInfo calls. A single call for 100 accounts saves 99 round trips. The response size depends on the account data — use dataSlice to fetch only the bytes you need, or encoding: "base64+zstd" for compression.

FAQ

What is the maximum number of accounts per request? 100 accounts per request. If you need more, split into multiple calls.

What happens if one account does not exist? Its position in the value array is null. Other accounts in the request are unaffected.

Is the response order guaranteed? Yes. The value array matches the order of the input pubkeys array exactly.

When should I use getMultipleAccounts vs getProgramAccounts? Use getMultipleAccounts when you know the specific public keys you want. Use getProgramAccounts when you need to discover accounts by owner program, data size, or data content.

Does dataSlice work the same as in getAccountInfo? Yes. {offset: 0, length: 32} returns only the first 32 bytes of each account’s data. This is useful when you only need a specific field from accounts with a known layout.

Parameters

ParameterTypeRequiredDescriptionDefault
pubkeysarrayYesArray of base-58 encoded public keys to query (up to 100).—
commitmentstringNoCommitment level: processed, confirmed, or finalized.finalized
encodingstringNoData encoding: base58, base64, base64+zstd, jsonParsed.base64
dataSliceobjectNoLimit returned data: {offset: usize, length: usize}. Not available with jsonParsed.—
minContextSlotnumberNoMinimum slot at which the request can be evaluated.—

Updated: