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

# 如何使用 getInflationGovernor

> 了解 getInflationGovernor 的使用案例、代码示例、请求参数、响应结构和提示。

[RPC 方法](https://www.helius.dev/docs/api-reference/rpc/http/getinflationgovernor)返回 Solana 集群的当前[通胀](https://www.helius.dev/blog/solana-issuance-inflation-schedule)参数。这些参数定义了新 SOL（通胀）的发行管理方式，包括初始利率、逐渐减少的方式、长期终端利率以及基金分配。

理解这些参数对于与代币经济学、质押奖励和 Solana 整体经济模型相关的分析非常重要。

## 常见用例

* **经济分析：** 获取当前 SOL 通胀的管理参数以进行研究或建模。
* **质押奖励计算：** 虽然 `getInflationRate` 提供当前年利率，但 `getInflationGovernor` 提供决定此利率及其未来走向的基础参数。
* **了解代币经济学：** 了解计划的代币供应变化。

## 请求参数

此方法可以选择性地接受一个包含以下参数的配置对象：

* **`commitment`**（字符串，可选）：指定查询分类账时使用的[承诺级别](https://www.helius.dev/blog/solana-commitment-levels)。如果未提供，则使用节点的默认承诺（通常为 `finalized`）。

## 响应结构

JSON-RPC 响应的 `result` 字段将是一个包含以下通胀参数的对象（均为 `f64` 浮点数，表示百分比或项）：

* **`initial`**：初始通胀率（例如，0.15 表示 15%）。
* **`terminal`**：长期终端通胀率（例如，0.015 表示 1.5%）。
* **`taper`**：通胀率从 `initial` 降低到 `terminal` 率的速度。这是通胀率本身的年度百分比下降（例如，0.15 的收缩率意味着通胀率每年下降 15%，直到达到终端率）。
* **`foundation`**：分配给 Solana 基金会的新通胀 SOL 的比例（例如，0.05 表示 5%）。
* **`foundationTerm`**：分配在 `foundation` 的年份期间。

## 示例

### 1. 获取当前通胀治理参数

此示例使用默认的承诺获取当前的通胀治理设置。

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

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

  async function logInflationGovernor() {
    const connection = new Connection('https://mainnet.helius-rpc.com/?api-key=<api-key>');
    try {
      const inflationGovernor = await connection.getInflationGovernor();
      console.log('Current Inflation Governor Parameters:');
      console.log(`  Initial Rate: ${(inflationGovernor.initial * 100).toFixed(2)}%`);
      console.log(`  Terminal Rate: ${(inflationGovernor.terminal * 100).toFixed(2)}%`);
      console.log(`  Taper Rate: ${(inflationGovernor.taper * 100).toFixed(2)}% per year`);
      console.log(`  Foundation Allocation: ${(inflationGovernor.foundation * 100).toFixed(2)}%`);
      console.log(`  Foundation Term: ${inflationGovernor.foundationTerm} years`);
      // For full raw details:
      // console.log(JSON.stringify(inflationGovernor, null, 2));
    } catch (error) {
      console.error('Error fetching inflation governor:', error);
    }
  }

  logInflationGovernor();
  ```
</CodeGroup>

### 2. 使用“confirmed”承诺获取通胀治理参数

<CodeGroup>
  ```bash cURL theme={"system"}
  curl https://mainnet.helius-rpc.com/?api-key=<api-key> -X POST -H "Content-Type: application/json" -d \
    '{
      "jsonrpc": "2.0",
      "id": 1,
      "method": "getInflationGovernor",
      "params":[{"commitment":"confirmed"}]
    }'
  ```

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

  async function logConfirmedInflationGovernor() {
    const connection = new Connection('https://mainnet.helius-rpc.com/?api-key=<api-key>');
    try {
      const inflationGovernor = await connection.getInflationGovernor('confirmed');
      console.log('Confirmed Inflation Governor Parameters:');
      console.log(`  Initial Rate: ${(inflationGovernor.initial * 100).toFixed(2)}%`);
      console.log(`  Terminal Rate: ${(inflationGovernor.terminal * 100).toFixed(2)}%`);
      // console.log(JSON.stringify(inflationGovernor, null, 2));
    } catch (error) {
      console.error('Error fetching confirmed inflation governor:', error);
    }
  }

  logConfirmedInflationGovernor();
  ```
</CodeGroup>

## 开发者提示

* **静态参数：** 这些通胀参数在集群的创始阶段或通过网络升级设置，通常不会频繁更改，除非有正式的治理流程和网络更新。
* **对质押奖励的影响：** 这些参数共同决定了整体的通胀计划，从而影响质押SOL的年度百分比收益率（APR）。
* **基金会分配：** `foundation`和`foundationTerm`参数描述了通胀的特定部分，该部分在定义的时间内流向Solana基金会，以支持生态系统的发展和运营。

本指南概述了如何使用`getInflationGovernor` RPC方法来检索和理解控制Solana网络通胀的核心参数。

## 相关方法

<CardGroup cols={2}>
  <Card title="getInflationRate" href="/docs/zh/api-reference/rpc/http/getinflationrate">
    获取当前纪元的通胀率
  </Card>

  <Card title="getInflationReward" href="/docs/zh/api-reference/rpc/http/getinflationreward">
    获取特定地址的通胀奖励
  </Card>
</CardGroup>
