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

OpenInfra.shopeninfra.sh

getLargestAccounts

Returns the 20 largest accounts by lamport balance. Some RPC nodes may serve cached results for up to two hours.

Request

Send a JSON-RPC 2.0 POST request with method: "getLargestAccounts". The params array accepts an optional configuration object.

curl · JSON-RPCjson
{  "jsonrpc": "2.0",  "id": 1,  "method": "getLargestAccounts",  "params": [    {      "commitment": "finalized",      "sortResults": true    }  ]}

@solana/kit

kit.tsts
import { createSolanaRpc } from "@solana/kit"; const rpc_url = "https://rpc.openinfra.sh";const rpc = createSolanaRpc(rpc_url); let largestAccounts = await rpc.getLargestAccounts().send(); console.log(largestAccounts);

@solana/web3.js

web3.tsts
import {  Connection,  clusterApiUrl,  type GetLargestAccountsConfig} from "@solana/web3.js"; const connection = new Connection("https://rpc.openinfra.sh", "confirmed"); let config: GetLargestAccountsConfig = {  commitment: "finalized",  filter: "circulating"}; let largestAccounts = await connection.getLargestAccounts(config); console.log(largestAccounts);

Rust

main.rsrs
use anyhow::Result;use solana_client::{    nonblocking::rpc_client::RpcClient,    rpc_config::{RpcLargestAccountsConfig, RpcLargestAccountsFilter},};use solana_commitment_config::CommitmentConfig; #[tokio::main]async fn main() -> Result<()> {    let client = RpcClient::new_with_commitment(        String::from("https://rpc.openinfra.sh"),        CommitmentConfig::confirmed(),    );     let config = RpcLargestAccountsConfig {        commitment: CommitmentConfig::finalized().into(),        filter: RpcLargestAccountsFilter::Circulating.into(),        sort_results: true.into(),    };    let largest_accounts = client.get_largest_accounts_with_config(config).await?;     println!("{:#?}", largest_accounts);     Ok(())}

Parameters

ParameterTypeRequiredDescription
configobjectNoOptional configuration object. See fields below.
config.commitmentstringNoDesired finality level. Accepted values: processed, confirmed, finalized (default).
config.filterstringNoFilter results by account type. Accepted values: circulating, nonCirculating. If omitted, both circulating and non-circulating accounts are included.
config.sortResultsboolNoWhether to sort accounts by lamport balance before returning. Defaults to true.

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.

filter example

{ "filter": "circulating" }

Response

response.jsonjson
{  "jsonrpc": "2.0",  "result": {    "context": { "apiVersion": "3.1.8", "slot": 54 },    "value": [      {        "address": "99P8ZgtJYe1buSK8JXkvpLh8xPsCFuLYhz9hQFNw93WJ",        "lamports": 999974      },      {        "address": "uPwWLo16MVehpyWqsLkK3Ka8nLowWvAHbBChqv2FZeL",        "lamports": 42      }    ]  },  "id": 1}

The result is an RpcResponse object with a context field and a value array of up to 20 account-balance objects.

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. This field may be omitted by older nodes.
valuearrayArray of up to 20 account-balance objects, sorted by lamport balance descending when sortResults is true.
value[].addressstringAccount address, as a base-58 encoded string.
value[].lamportsu64Number of lamports held by this account.