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

# getLargestAccountsの使用方法

> getLargestAccountsの使用例、コード例、リクエストパラメーター、応答構造、ヒントを学びます。

[`getLargestAccounts`](https://www.helius.dev/docs/api-reference/rpc/http/getlargestaccounts) RPCメソッドは、Solanaネットワーク上の上位20アカウントをランク付けしてlamport残高で返します。このメソッドは、ネットワーク分析、富の分配の理解、または重要なSOL保有者の特定に役立ちます。

このメソッドからの結果は、最大2時間RPCノードによってキャッシュされる場合があります。

## 共通のユースケース

* **ネットワーク健康状態の監視:** 最も大きなアカウントにおけるSOLの集中を観察します。
* **経済分析:** Solanaネットワーク上での富の分布を研究します。
* **ホエールの特定:** 大量のSOLを保有しているアカウントを見つけます。

## リクエストパラメーター

このメソッドは、次のパラメーターを持つ設定オブジェクトをオプションで受け取ることができます。

* **`commitment`** (string, optional): 台帳をクエリするときに使用する[コミットメントレベル](https://www.helius.dev/blog/solana-commitment-levels)を指定します。指定されていない場合、ノードのデフォルトのコミットメントが使用されます。
* **`filter`** (string, optional): アカウントタイプで結果をフィルタリングします。受け入れられる値は以下のとおりです。
  * `circulating`: 循環供給の一部である最大アカウントを返します。
  * `nonCirculating`: 循環供給の一部でない最大アカウントを返します（例：ロックされたアカウント、財団アカウント）。
    省略した場合、特定のフィルターなしで全てのアカウントが考慮されます。

## 応答構造

JSON-RPC応答の`result`フィールドは、`RpcResponse`オブジェクトです。このオブジェクト内の`value`フィールドは、20個までのアカウントオブジェクトの配列で、それぞれ次を含みます：

* **`address`** (string): アカウントのbase-58エンコードされた公開鍵。
* **`lamports`** (u64): lamportsでのアカウント残高。

応答には、情報が取得された時点の `slot` を含む `context` オブジェクトも含まれています。

## 例

### 1. 上位20の最大アカウントを取得（フィルターなし）

この例では、供給フィルターなしでlamport残高で上位20の最大アカウントを取得します。

<CodeGroup>
  ```bash cURL theme={"system"}
  # Replace <api-key> with your Helius API key
  curl https://mainnet.helius-rpc.com/?api-key=<api-key> -X POST -H "Content-Type: application/json" -d \
    '{
      "jsonrpc": "2.0",
      "id": 1,
      "method": "getLargestAccounts"
    }'
  ```

  ```javascript JavaScript (using @solana/web3.js) theme={"system"}
  // Replace <api-key> with your Helius API key
  const { Connection } = require('@solana/web3.js');

  async function logLargestAccounts() {
    const connection = new Connection('https://mainnet.helius-rpc.com/?api-key=<api-key>');
    try {
      const largestAccounts = await connection.getLargestAccounts();
      console.log(`Largest Accounts (Slot: ${largestAccounts.context.slot}):`);
      largestAccounts.value.forEach((account, index) => {
        console.log(
          `  ${index + 1}. Address: ${account.address}, Balance: ${account.lamports / 10**9} SOL`
        );
      });
      // For full raw details:
      // console.log(JSON.stringify(largestAccounts, null, 2));
    } catch (error) {
      console.error('Error fetching largest accounts:', error);
    }
  }

  logLargestAccounts();
  ```
</CodeGroup>

### 2. 上位20の最大循環アカウントを取得

この例では、循環供給の一部と見なされる上位20の最大アカウントを取得します。

<CodeGroup>
  ```bash cURL theme={"system"}
  # Replace <api-key> with your Helius API key
  curl https://mainnet.helius-rpc.com/?api-key=<api-key> -X POST -H "Content-Type: application/json" -d \
    '{
      "jsonrpc": "2.0",
      "id": 1,
      "method": "getLargestAccounts",
      "params": [{ "filter": "circulating" }]
    }'
  ```

  ```javascript JavaScript (using @solana/web3.js) theme={"system"}
  // Replace <api-key> with your Helius API key
  const { Connection } = require('@solana/web3.js');

  async function logLargestCirculatingAccounts() {
    const connection = new Connection('https://mainnet.helius-rpc.com/?api-key=<api-key>');
    try {
      const largestAccounts = await connection.getLargestAccounts({ filter: 'circulating' });
      console.log(`Largest Circulating Accounts (Slot: ${largestAccounts.context.slot}):`);
      largestAccounts.value.forEach((account, index) => {
        console.log(
          `  ${index + 1}. Address: ${account.address}, Balance: ${account.lamports / 10**9} SOL`
        );
      });
      // console.log(JSON.stringify(largestAccounts, null, 2));
    } catch (error) {
      console.error('Error fetching largest circulating accounts:', error);
    }
  }

  logLargestCirculatingAccounts();
  ```
</CodeGroup>

## 開発者へのヒント

* **キャッシュされたデータ:** 結果は最大2時間RPCノードによってキャッシュされる可能性があります。これは、データが最新のブロックに対してリアルタイムでないかもしれないことを意味します。
* **トップ20に限定:** このメソッドはトップ20アカウントのみを返します。より包括的な富の分配分析には、他のデータソースまたはメソッドが必要かもしれません。
* **フィルターの動作:** `circulating`および`nonCirculating`フィルターは、これらの分類のためのRPCノードの定義およびデータソースに依存します。

このガイドは、Solanaネットワーク上で最大SOL保有者をクエリするための`getLargestAccounts` RPCメソッドを使用するために必要な情報を提供します。
