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

# voteSubscribe

> 订阅以在 gossip 中观察到新投票时接收通知。这些投票是共识前的，因此不能保证这些投票会进入账本。

<Note>
  此订阅不稳定，仅在验证器使用 `--rpc-pubsub-enable-vote-subscription` 标志启动时可用。此订阅的格式将来可能会更改。
</Note>

<Warning>
  这是一个不稳定的 RPC 方法，**Helius 不支持**。此文档仅供参考。
</Warning>

## 端点

主网和开发网上可用 Websockets，使用以下 URL：

* **Mainnet** `wss://mainnet.helius-rpc.com/?api-key=<api-key>`
* **Devnet** `wss://devnet.helius-rpc.com/?api-key=<api-key>`

<Note>Websockets 有 10 分钟的不活动计时器；强烈建议实施健康检查并每分钟发送 ping 以保持 websocket 连接活跃。</Note>

## 授权

<ParamField query="api-key" type="string" required>
  您的 Helius API 密钥。您可以在[仪表板](https://dashboard.helius.dev/api-keys)中免费获取一个。
</ParamField>

## 请求体

<ParamField body="params" type="array">
  <Expandable title="properties" defaultOpen>
    <ParamField body="none" type="null">
      不需要参数。
    </ParamField>
  </Expandable>
</ParamField>

## 响应

<ResponseField name="result" type="integer">
  订阅 ID（取消订阅时需要）
</ResponseField>

## 通知格式

通知将是一个包含以下字段的对象：

* `hash: <string>` - 投票哈希
* `slots: <array>` - 投票涵盖的插槽，作为 u64 整数数组
* `timestamp: <i64|null>` - 投票的时间戳
* `signature: <string>` - 包含此投票的交易签名
* `votePubkey: <string>` - 投票账户的公钥，作为 base-58 编码的字符串

<RequestExample>
  ```json Request theme={"system"}
  {
    "jsonrpc": "2.0",
    "id": 1,
    "method": "voteSubscribe"
  }
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={"system"}
  {
    "jsonrpc": "2.0",
    "result": 0,
    "id": 1
  }
  ```

  ```json Notification theme={"system"}
  {
    "jsonrpc": "2.0",
    "method": "voteNotification",
    "params": {
      "result": {
        "hash": "8Rshv2oMkPu5E4opXTRyuyBeZBqQ4S477VG26wUTFxUM",
        "slots": [1, 2],
        "timestamp": null
      },
      "subscription": 0
    }
  }
  ```
</ResponseExample>
