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

# getInflationRewardの使用方法

> getInflationRewardの使用例、コード例、リクエストパラメータ、レスポンス構造、およびヒントを学びます。

[`getInflationReward`](https://www.helius.dev/docs/api-reference/rpc/http/getinflationreward) RPCメソッドは、特定のエポックに対して1つ以上のアドレスに付与された[インフレーション](https://www.helius.dev/blog/solana-issuance-inflation-schedule)報酬（一般にステーキング報酬として知られる）を照会できます。

これは、ステークアカウントやインフレーション報酬を受け取った可能性のあるアカウントによって受け取られた報酬を確認するのに役立ちます。

<Warning>
  **パフォーマンス向上のためバッチ処理を避ける**

  アーカイバルメソッドのバッチ処理は遅延を大幅に増加させます。10件以上のリクエストのバッチ処理は許可されていません。
</Warning>

## 一般的な使用例

* **ステーキング報酬の確認:** 過去のエポックでステークアカウントが期待通りの報酬を受け取ったかどうかを確認します。
* **報酬履歴の追跡:** アドレスの履歴を構築するために複数のエポックの報酬を照会します。
* **バリデータの支払い監査:** バリデータはこれを使用して報酬の分配を確認できます（ただし、報酬はバリデータのIDではなくステークアカウントに支払われます）。

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

このメソッドは2つの主要なパラメータを取ります：

1. **`addresses`**（文字列の配列）：照会したいアカウントのbase-58でエンコードされた公開鍵のリスト。許可されるアドレスの最大数はRPCプロバイダにより異なる場合があります（例：Heliusでは有料プランで最大1005まで）。
2. **`config`**（オブジェクト、省略可能）：次の省略可能なフィールドを持つ構成オブジェクト：
   * **`commitment`**（文字列、省略可能）：[コミットメントレベル](https://www.helius.dev/blog/solana-commitment-levels)を指定します。指定がない場合は、`finalized`がデフォルトとなります。
   * **`epoch`**（整数、省略可能）：報酬を取得するエポック番号。指定がない場合、通常は最も最近完了したエポックの報酬が使用されます。
   * **`minContextSlot`**（整数、省略可能）：リクエストが評価可能な最小スロット。これにより、このスロットまで処理された台帳状態に対してクエリが行われることが保証されます。

## レスポンス構造

JSON-RPCレスポンスの`result`フィールドは、入力された`addresses`配列に対応する配列になります。結果配列の各要素は次のいずれかになります：

* 指定されたエポックでアドレスが報酬を受け取った場合はインフレーション報酬の詳細を含む**オブジェクト**。
* アドレスがそのエポックでインフレーション報酬を受け取らなかった場合、またはアカウントが存在しなかった場合は\*\*`null`\*\*。

報酬オブジェクトには次のフィールドがあります：

* **`epoch`**（u64）：この報酬が付与されたエポック。
* **`effectiveSlot`**（u64）：報酬が適用され有効となったスロット。
* **`amount`**（u64）：報酬の額（ラムポート単位）。
* **`postBalance`**（u64）：報酬が付与された後のアカウントの残高（ラムポート単位）。
* **`commission`**（u8 | 定義なし）：投票アカウントの場合、この報酬がクレジットされた時にバリデータが差し引く手数料率（0-100％）。非投票アカウントの場合は`undefined`。

## 例

### 1. 単一アドレスのインフレーション報酬を取得（前のエポック）

この例では、特定のアドレスに対する最も最近完了したエポックのインフレーション報酬を取得します。

<CodeGroup>
  ```bash cURL theme={"system"}
  # Replace YOUR_VOTE_ACCOUNT_PUBKEY with an actual vote account public key
  # 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": "getInflationReward",
      "params": [
        ["YOUR_VOTE_ACCOUNT_PUBKEY"]
      ]
    }'
  ```

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

  async function checkInflationReward() {
    const connection = new Connection('https://mainnet.helius-rpc.com/?api-key=<api-key>');
    const voteAccountPubkey = new PublicKey('YOUR_VOTE_ACCOUNT_PUBKEY'); // Example: 'Vote111111111111111111111111111111111111111'

    try {
      const rewards = await connection.getInflationReward([voteAccountPubkey]);
      if (rewards && rewards[0]) {
        const rewardInfo = rewards[0];
        console.log(`Reward for Epoch ${rewardInfo.epoch}:`);
        console.log(`  Amount: ${rewardInfo.amount} lamports`);
        console.log(`  Effective Slot: ${rewardInfo.effectiveSlot}`);
        console.log(`  Post Balance: ${rewardInfo.postBalance} lamports`);
        if (rewardInfo.commission !== undefined) {
          console.log(`  Commission: ${rewardInfo.commission}%`);
        }
      } else {
        console.log('No inflation reward found for the address in the previous epoch.');
      }
      // console.log(JSON.stringify(rewards, null, 2));
    } catch (error) {
      console.error('Error fetching inflation reward:', error);
    }
  }

  checkInflationReward();
  ```
</CodeGroup>

### 2. 特定のエポックに対して複数のアドレスのインフレーション報酬を取得

<CodeGroup>
  ```bash cURL theme={"system"}
  # Replace <api-key> with your Helius API key
  # Replace PUBKEY_1 and PUBKEY_2 with actual public keys
  curl https://mainnet.helius-rpc.com/?api-key=<api-key> -X POST -H "Content-Type: application/json" -d \
    '{
      "jsonrpc": "2.0",
      "id": 1,
      "method": "getInflationReward",
      "params": [
        ["PUBKEY_1", "PUBKEY_2"],
        { "epoch": 450, "commitment": "confirmed" }
      ]
    }'
  ```

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

  async function checkMultipleRewards() {
    const connection = new Connection('https://mainnet.helius-rpc.com/?api-key=<api-key>');
    const address1 = new PublicKey('PUBKEY_1'); 
    const address2 = new PublicKey('PUBKEY_2');
    const specificEpoch = 450;

    try {
      const rewards = await connection.getInflationReward(
        [address1, address2],
        specificEpoch,
        { commitment: 'confirmed' }
      );
      rewards.forEach((rewardInfo, index) => {
        const address = index === 0 ? 'PUBKEY_1' : 'PUBKEY_2';
        if (rewardInfo) {
          console.log(`Reward for ${address} in Epoch ${rewardInfo.epoch}:`);
          console.log(`  Amount: ${rewardInfo.amount} lamports`);
        } else {
          console.log(`No inflation reward found for ${address} in Epoch ${specificEpoch}.`);
        }
      });
      // console.log(JSON.stringify(rewards, null, 2));
    } catch (error) {
      console.error('Error fetching inflation rewards for epoch ', specificEpoch, error);
    }
  }

  checkMultipleRewards();
  ```
</CodeGroup>

## 開発者向けヒント

* **エポックの特定:** 報酬はエポックごとに一度だけ付与されます。正しいエポック番号を照会していることを確認してください。
* **報酬のタイミング:** インフレーション報酬はエポックの終わりに計算され、次のエポックの始めに適用されます。`effectiveSlot`はこれが起こる時を示します。
* **結果がnullの場合:** あるアドレスの結果が`null`である場合、その指定されたエポックでそのアドレスに報酬が見つからなかったことを意味します。これは、アカウントが資格を持たない（例：十分にステークされていないステークアカウント）場合や、報酬がゼロの場合、またはその時点でアカウントが存在しなかった場合が考えられます。
* **レート制限:** 多数のアドレスを照会する際は、特にRPCプロバイダのレート制限に注意してください。

このガイドでは、Solanaネットワーク上でステーキング報酬を正確に取得し検証するために`getInflationReward`メソッドを使用する方法を説明します。
