getMultipleAccounts
All the specifications for getMultipleAccounts RPC Method on Solana
Returns the account information for a list of Pubkeys. getAccountInfo returns for a single account, this works with an array of accounts.
Parameters required for this RPC call
An array of pubkeys to query, as base-58 encoded strings. These are the addresses for the accounts which we are trying to get account information.
configuration : This contains the following parameters, all are optional fields.
commitment: The commitment describes how finalized a block is at that point in time. Commitment levels processed, confirmed and finalized are supported, defaults to finalized.
encoding: Encoding format for each returned transaction. The supported options are json, jsonParsed, base58 and base64. You can know more about Parsed responses more on Solana docs.
minContextSlot: The minimum slot that the request can be evaluated at. This is a number.
dataSlice: Request a slice of the account's data.
length: <usize>- number of bytes to returnoffset: <usize>- byte offset from which to start reading
curl https://rpc.shyft.to?api_key=YOUR-API-KEY -s -X \
POST -H "Content-Type: application/json" -d '
{
"jsonrpc": "2.0",
"id": 1,
"method": "getMultipleAccounts",
"params": [
[
"vines1vzrYbzLMRdu58ou5XTby4qAqVRLmqo36NKPTg",
"4fYNw3dojWmQ4dXtSGE9epjRGy9pFSx62YypT7avPYvA"
],
{
"encoding": "base58",
"commitment": "finalized"
}
]
}
'import {
Connection,
PublicKey,
clusterApiUrl,
type GetMultipleAccountsConfig,
} from "@solana/web3.js";
const connection = new Connection("https://rpc.shyft.to?api_key=YOUR-API-KEY", "confirmed");
let addresses = [
new PublicKey("vines1vzrYbzLMRdu58ou5XTby4qAqVRLmqo36NKPTg"),
new PublicKey("4fYNw3dojWmQ4dXtSGE9epjRGy9pFSx62YypT7avPYvA"),
];
let config: GetMultipleAccountsConfig = {
commitment: "finalized",
};
let accounts = await connection.getMultipleAccountsInfo(addresses, config);
console.log(accounts);Last updated
Was this helpful?