> ## Documentation Index
> Fetch the complete documentation index at: https://solana.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> This page is part of the Solana developer documentation at https://solana.com/developers/docs. Append `.md` to any docs URL, or send `Accept: text/markdown`, to get the page as Markdown.
> Index of all pages: https://solana.com/llms.txt. Per-section indexes such as https://solana.com/developers/docs/payments/llms.txt are smaller; prefer them when working on one task.
> Coding agents: install the official Solana skill for current APIs and conventions with `npx skills add https://github.com/solana-foundation/solana-dev-skill` (also served at https://solana.com/SKILL.md).
> Code in the cookbook and task pages comes from tested example files. Prefer it over writing API calls from memory.

# getLargestAccounts

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

<Info>
  **Source**

  [`get_largest_accounts`](https://github.com/anza-xyz/agave/blob/v4.3.2/rpc/src/rpc.rs#L1070)
</Info>

<Warning>
  The public mainnet, devnet, and testnet endpoints turn this method off. They
  answer every request with HTTP `429` "Too many requests for a specific RPC
  call", which waiting does not clear. Call it on an RPC provider that serves
  it, or on a local network at `http://localhost:8899`, as the examples on this
  page do: `solana-test-validator`, or Surfpool started with `--offline` (a
  Surfpool that forks a public cluster forwards this method there and gets the
  same `429`).
</Warning>

<RequestExample>
  ```bash cURL
  curl http://localhost:8899 -s -X POST \
    -H "Content-Type: application/json" \
    -d '
    {
      "jsonrpc": "2.0",
      "id": 1,
      "method": "getLargestAccounts",
      "params": [
        {
          "commitment": "finalized",
          "sortResults": true
        }
      ]
    }
  '
  ```

  ```ts Kit
  import { createSolanaRpc } from "@solana/kit";

  const rpc_url = "http://localhost:8899";
  const rpc = createSolanaRpc(rpc_url);

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

  console.log(largestAccounts);
  ```

  ```ts web3.js
  import { Connection, type GetLargestAccountsConfig } from "@solana/web3.js";

  const connection = new Connection("http://localhost:8899", "confirmed");

  let config: GetLargestAccountsConfig = {
    commitment: "finalized",
    filter: "circulating"
  };

  let largestAccounts = await connection.getLargestAccounts(config);

  console.log(largestAccounts);
  ```

  ```rs 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("http://localhost:8899"),
          CommitmentConfig::confirmed(),
      );

      let config = RpcLargestAccountsConfig {
          commitment: CommitmentConfig::finalized().into(),
          filter: RpcLargestAccountsFilter::Circulating.into(),
          sort_results: true.into(),
          ..Default::default()
      };
      let largest_accounts = client.get_largest_accounts_with_config(config).await?;

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

      Ok(())
  }
  ```
</RequestExample>

<ResponseExample>
  ```json Response
  {
    "jsonrpc": "2.0",
    "result": {
      "context": { "apiVersion": "4.3.2", "slot": 54 },
      "value": [
        {
          "address": "99P8ZgtJYe1buSK8JXkvpLh8xPsCFuLYhz9hQFNw93WJ",
          "lamports": 999974
        },
        {
          "address": "uPwWLo16MVehpyWqsLkK3Ka8nLowWvAHbBChqv2FZeL",
          "lamports": 42
        }
      ]
    },
    "id": 1
  }
  ```
</ResponseExample>

## Parameters

<ParamField body="config" type="object">
  Configuration object containing the following fields:

  <Expandable title="properties" defaultOpen>
    <ParamField body="commitment" type="string" default="finalized">
      Values: `processed`, `confirmed`, `finalized`

      Solana RPC uses the following commitment levels:

      | Value       | Description                                                                                                                                                                               |
      | ----------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
      | `processed` | Return data from the highest slot this node has processed. This is the newest view, but the block can still be skipped.                                                                   |
      | `confirmed` | Return data from the same slot as `finalized`. Kept for compatibility and planned for removal in a later release.                                                                         |
      | `finalized` | Return data from the highest slot with a finalization certificate, from votes by 80% of stake in one round or 60% of stake in each of two rounds. This is the strongest commitment level. |
    </ParamField>

    <ParamField body="filter" type="string">
      Values: `circulating`, `nonCirculating`

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

      ```json Example
      { "filter": "circulating" }
      ```
    </ParamField>

    <ParamField body="sortResults" type="bool" default="true">
      Values: `true`, `false`

      Whether to sort the returned accounts by lamport balance before returning them
    </ParamField>
  </Expandable>
</ParamField>

## Result

<ResponseField name="result" type="object">
  RpcResponse object containing:

  <Expandable title="properties" defaultOpen>
    <ResponseField name="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. |
    </ResponseField>

    <ResponseField name="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.            |
    </ResponseField>
  </Expandable>
</ResponseField>
