OpenInfra.sh is now live - Solana infrastructure, included with every server. LEARN MORE HERE >

OpenInfra.shopeninfra.sh

getMultipleAccounts

Returns account state and metadata for multiple addresses, in request order.

Request

Send a JSON-RPC 2.0 POST request with method: "getMultipleAccounts". The params array takes an array of base-58 encoded public keys (up to 100) and an optional configuration object.

curl · JSON-RPCjson
{  "jsonrpc": "2.0",  "id": 1,  "method": "getMultipleAccounts",  "params": [    [      "vines1vzrYbzLMRdu58ou5XTby4qAqVRLmqo36NKPTg",      "4fYNw3dojWmQ4dXtSGE9epjRGy9pFSx62YypT7avPYvA"    ],    {      "encoding": "base64",      "commitment": "finalized"    }  ]}

@solana/kit

kit.tsts
import { address, createSolanaRpc } from "@solana/kit"; const rpc_url = "https://rpc.openinfra.sh";const rpc = createSolanaRpc(rpc_url); let addresses = [  address("vines1vzrYbzLMRdu58ou5XTby4qAqVRLmqo36NKPTg"),  address("4fYNw3dojWmQ4dXtSGE9epjRGy9pFSx62YypT7avPYvA")]; let config = {  encoding: "base64",  commitment: "finalized"}; let accounts = await rpc.getMultipleAccounts(addresses, config).send(); console.log(accounts);

@solana/web3.js

web3.tsts
import {  Connection,  PublicKey,  type GetMultipleAccountsConfig} from "@solana/web3.js"; const connection = new Connection("https://rpc.openinfra.sh", "confirmed"); let addresses = [  new PublicKey("vines1vzrYbzLMRdu58ou5XTby4qAqVRLmqo36NKPTg"),  new PublicKey("4fYNw3dojWmQ4dXtSGE9epjRGy9pFSx62YypT7avPYvA")]; let config: GetMultipleAccountsConfig = {  commitment: "finalized"}; let accounts = await connection.getMultipleAccountsInfo(addresses, config); console.log(accounts);

Rust

main.rsrs
use anyhow::Result;use solana_account_decoder::UiAccountEncoding;use solana_client::{nonblocking::rpc_client::RpcClient, rpc_config::RpcAccountInfoConfig};use solana_commitment_config::CommitmentConfig;use solana_sdk::pubkey; #[tokio::main]async fn main() -> Result<()> {    let client = RpcClient::new_with_commitment(        String::from("https://rpc.openinfra.sh"),        CommitmentConfig::confirmed(),    );     let addresses = [        pubkey!("vines1vzrYbzLMRdu58ou5XTby4qAqVRLmqo36NKPTg"),        pubkey!("4fYNw3dojWmQ4dXtSGE9epjRGy9pFSx62YypT7avPYvA"),    ];     let config = RpcAccountInfoConfig {        encoding: UiAccountEncoding::Base64.into(),        data_slice: None,        commitment: CommitmentConfig::finalized().into(),        min_context_slot: None,    };     let accounts = client        .get_multiple_accounts_with_config(&addresses, config)        .await?;     println!("{:#?}", accounts);     Ok(())}

Parameters

ParameterTypeRequiredDescription
pubkeysarrayYesArray of Pubkeys to query, as base-58 encoded strings. Maximum 100 entries.
configobjectNoOptional configuration object. See fields below.
config.commitmentstringNoDesired finality level. Accepted values: processed, confirmed, finalized (default).
config.encodingstringNoEncoding for returned account data. Accepted values: base64 (default), base58, base64+zstd, jsonParsed, binary (deprecated).
config.dataSliceobjectNoRequest a slice of account data: { offset, length }. Only available for base58, base64, base64+zstd, and binary encodings.
config.minContextSlotnumberNoThe minimum slot at which the request may be evaluated.

commitment values

ValueDescription
processedReturn data from the highest slot this node has processed on the fork it currently considers best. This is the newest view, but it can still change if the cluster switches forks.
confirmedReturn data from the highest slot that at least two-thirds of active stake has directly voted to confirm. More stable than processed, but a weaker guarantee than finalized.
finalizedReturn data from the highest slot that the cluster recognizes as finalized. The slot has reached maximum vote lockout in validators' vote towers and is recognized by at least two-thirds of active stake. This is the strongest commitment level.

encoding values

EncodingData formatNotes
base64[data, "base64"]Recommended.
base58[data, "base58"]Slow. The account's data field must be 128 bytes or fewer.
base64+zstd[data, "base64+zstd"]Zstandard compressed.
jsonParsed{program, parsed, space}Falls back to base64 if no parser is found for the owning program.
binarystringDeprecated. Same base58 encoding as base58 with the same 128-byte limit, but returns data as a plain string. Use base64 instead.

jsonParsed program values

When encoding is jsonParsed, the program field in the returned account object identifies the parser used:

program valueParsed account type
address-lookup-tableAddress lookup table accounts
bpf-upgradeable-loaderUpgradeable loader program and buffer accounts
configConfig accounts
nonceDurable nonce accounts
spl-tokenSPL Token accounts
spl-token-2022SPL Token 2022 accounts
stakeStake accounts
sysvarSysvar accounts
voteVote accounts

dataSlice example

Examplejson
{ "offset": 0, "length": 32 }

minContextSlot example

Examplejson
{ "minContextSlot": 341197000 }

Response

response.jsonjson
{  "jsonrpc": "2.0",  "result": {    "context": { "apiVersion": "3.1.8", "slot": 341197247 },    "value": [      {        "data": ["", "base64"],        "executable": false,        "lamports": 88849814690250,        "owner": "11111111111111111111111111111111",        "rentEpoch": 18446744073709551615,        "space": 0      },      {        "data": ["", "base64"],        "executable": false,        "lamports": 998763433,        "owner": "2WRuhE4GJFoE23DYzp2ij6ZnuQ8p9mJeU6gDgfsjR4or",        "rentEpoch": 18446744073709551615,        "space": 0      }    ]  },  "id": 1}

The result is an RpcResponse object. Each entry in value corresponds positionally to the requested pubkey and is either null (account does not exist) or an account object.

FieldTypeDescription
contextobjectSlot and API version the node used to answer this request.
context.slotu64Slot at which the node evaluated this request.
context.apiVersionstringRPC API version reported by the node. May be omitted by older nodes.
valuearrayArray of account objects (or null) in the same order as the requested pubkeys.
value[n].datastring | array | objectAccount data. Format depends on encoding: plain base-58 string for binary; [data, encoding] for base58, base64, or base64+zstd; { program, parsed, space } for jsonParsed.
value[n].executableboolWhether the account contains a program and is therefore read-only.
value[n].lamportsu64Lamports assigned to this account.
value[n].ownerstringProgram owner pubkey, as a base-58 encoded string.
value[n].rentEpochu64Epoch at which this account next owes rent.
value[n].spaceu64 | nullAccount data size in bytes.

jsonParsed data object fields

When encoding is jsonParsed and a parser is available, the data field is an object with the following shape:

FieldTypeDescription
programstringName of the parser that produced the decoded account data.
parsedobjectParser-specific JSON payload. Structure depends on the owning program and account type.
spaceu64Account data size in bytes.