> ## 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.

# getTransactionCountの使い方

> getTransactionCountのユースケース、コード例、リクエストパラメータ、レスポンス構造、ヒントを学びます。

[`getTransactionCount`](https://www.helius.dev/docs/api-reference/rpc/http/gettransactioncount) RPCメソッドは、指定されたコミットメントレベルで、ジェネシス以来Solana台帳によって処理された現在の総取引数を返します。

## 一般的なユースケース

* **ネットワーク統計:** ネットワーク上の全体的な取引量を一般的な健康または活動の指標として表示します。
* **成長の追跡:** 時間の経過による取引数の増加を監視して、ネットワークの採用と使用傾向を観察します。
* **ダッシュボードメトリクス:** ブロックチェーン活動の概要を高レベルで提供します。

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

このメソッドは1つのオプションパラメータを持ちます:

1. **`options`** (object, optional): 次を含むことができるオプションの設定オブジェクト:

* **`commitment`** (string, optional): クエリの[コミットメントレベル](https://www.helius.dev/blog/solana-commitment-levels)を指定します（例えば、`"finalized"`, `"confirmed"`, `"processed"`）。指定されない場合、ノードのデフォルトのコミットメントが使用されます。
* **`minContextSlot`** (u64, optional): リクエストを評価できる最小スロット。

## レスポンス構造

JSON-RPCレスポンスの`result`フィールドは、コミットメントレベルで決定されるスロットまでの台帳からの総取引数を表す単一の`u64`番号です。

**レスポンス例:**

```json theme={"system"}
{
  "jsonrpc": "2.0",
  "result": 398146706879,
  "id": 1
}
```

## コード例

<CodeGroup>
  ```bash cURL theme={"system"}
  # Basic Request (uses default commitment of the RPC node):
  curl -X POST -H "Content-Type: application/json" -d \
    '{
      "jsonrpc": "2.0",
      "id": 1,
      "method": "getTransactionCount"
    }' \
    <YOUR_RPC_URL>

  # Request with a specific commitment level:
  curl -X POST -H "Content-Type: application/json" -d \
    '{
      "jsonrpc": "2.0",
      "id": 1,
      "method": "getTransactionCount",
      "params": [
        {
          "commitment": "confirmed"
        }
      ]
    }' \
    <YOUR_RPC_URL>
  ```

  ```javascript JavaScript (using @solana/web3.js) theme={"system"}
  const { Connection } = require('@solana/web3.js');

  async function getCurrentTransactionCount() {
    // Replace with your RPC endpoint
    const connection = new Connection('https://mainnet.helius-rpc.com/?api-key=<api-key>');

    try {
      const transactionCount = await connection.getTransactionCount();
      console.log(`Current ledger transaction count: ${transactionCount}`);

      // Example with commitment
      const confirmedTransactionCount = await connection.getTransactionCount('confirmed');
      console.log(`Current ledger transaction count (confirmed): ${confirmedTransactionCount}`);

    } catch (error) {
      console.error('Error fetching transaction count:', error);
    }
  }

  getCurrentTransactionCount();
  ```
</CodeGroup>

## 開発者のヒント

* **台帳全体のカウント:** このカウントは、特定のアカウントやブロックだけでなく、 inception 以来の台帳上で処理されたすべての取引を表します。
* **増加する値:** 取引数は単調に増加する値です。
* **コミットメントレベル:** 戻りカウントは選択された`commitment`レベルに依存します。 `processed`コミットメントは、`finalized`よりも高く、より最新のカウントをもたらす可能性がありますが、`finalized`はロールバックに対する保証を提供します。
* **TPSメトリックではない:** ネットワーク活動に関連していますが、この単一の値は、定義された期間でのカウントを比較しない限り、直接的に毎秒トランザクション数（TPS）を示すものではありません。

このガイドは、Solanaネットワーク上の総取引数を取得するための`getTransactionCount` RPCメソッドの使用方法を説明します。
