---
title: getLargestAccounts
description: >-
  Returns the 20 largest accounts by lamport balance. Some RPC nodes may serve
  cached results for up to two hours.
url: /docs/rpc/http/getlargestaccounts
type: reference
hideTableOfContents: true
---

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

<Callout type="info" title="Source">
  [`get_largest_accounts`](https://github.com/anza-xyz/agave/blob/v3.1.8/rpc/src/rpc.rs#L1045)
</Callout>

<APIMethod>

```jsonc !!request curl
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "getLargestAccounts",
  "params": [
    // !hover(1:4) config
    {
      // !hover commitment
      "commitment": "finalized",
      // !hover sortResults
      "sortResults": true
    }
  ]
}
```

```ts !!request title="Kit"
import { createSolanaRpc } from "@solana/kit";

const rpc_url = "https://api.devnet.solana.com";
const rpc = createSolanaRpc(rpc_url);

let largestAccounts = await rpc.getLargestAccounts().send();

console.log(largestAccounts);
```

```ts !!request title="web3.js"
import {
  Connection,
  clusterApiUrl,
  type GetLargestAccountsConfig
} from "@solana/web3.js";

const connection = new Connection(clusterApiUrl("devnet"), "confirmed");

// !hover(1:4) config
let config: GetLargestAccountsConfig = {
  // !hover commitment
  commitment: "finalized",
  // !hover filter
  filter: "circulating"
};

let largestAccounts = await connection.getLargestAccounts(config);

console.log(largestAccounts);
```

```rs !!request title="Rust"
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://api.devnet.solana.com"),
        CommitmentConfig::confirmed(),
    );

    // !hover(1:5) config
    let config = RpcLargestAccountsConfig {
        // !hover commitment
        commitment: CommitmentConfig::finalized().into(),
        // !hover filter
        filter: RpcLargestAccountsFilter::Circulating.into(),
        sort_results: true.into(),
    };
    let largest_accounts = client.get_largest_accounts_with_config(config).await?;

    println!("{:#?}", largest_accounts);

    Ok(())
}
```

### !params

#### !! config

!type object

Configuration object containing the following fields:

##### !! commitment

!type string  
!values processed confirmed finalized  
!default finalized

Solana RPC uses the following commitment levels:

| Value       | Description                                                                                                                                                                                                                                                                |
| ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `processed` | Return 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.                                                                                         |
| `confirmed` | Return data from the highest slot that at least two-thirds of active stake has directly voted to confirm. This is more stable than `processed`, but it is still a weaker guarantee than `finalized`.                                                                       |
| `finalized` | Return data from the highest slot that the cluster recognizes as finalized. In practice, this means 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

!type string  
!values circulating nonCirculating

Filter results by account type. If omitted, the RPC node includes both
circulating and non-circulating accounts.

```json title="Example"
{ "filter": "circulating" }
```

##### !! sortResults

!type bool  
!values true false  
!default true

Whether to sort the returned accounts by lamport balance before returning them

### !!result

```jsonc !response
{
  "jsonrpc": "2.0",
  // !hover(1:13) result
  "result": {
    // !hover context
    "context": { "apiVersion": "3.1.8", "slot": 54 },
    // !hover(1:10) value
    "value": [
      {
        "address": "99P8ZgtJYe1buSK8JXkvpLh8xPsCFuLYhz9hQFNw93WJ",
        "lamports": 999974
      },
      {
        "address": "uPwWLo16MVehpyWqsLkK3Ka8nLowWvAHbBChqv2FZeL",
        "lamports": 42
      }
    ]
  },
  "id": 1
}
```

!type object

RpcResponse object containing:

#### !! context

!type object

Slot and API version the node used to answer this request.

| Field        | Type     | Description                                                                     |
| ------------ | -------- | ------------------------------------------------------------------------------- |
| `slot`       | `u64`    | Slot at which the node evaluated this request.                                  |
| `apiVersion` | `string` | RPC API version reported by the node. This field may be omitted by older nodes. |

#### !! value

!type array

Array of up to 20 account-balance objects with the following fields:

| Field      | Type     | Description                                   |
| ---------- | -------- | --------------------------------------------- |
| `address`  | `string` | Account address, as a base-58 encoded string. |
| `lamports` | `u64`    | Number of lamports in the account.            |

</APIMethod>
