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

# slotsUpdatesSubscribe

> 订阅以接收来自验证器的每个 slot 上各种更新的通知。

<Note>
  此订阅不稳定。此订阅的格式可能会在未来发生变化，并且可能并不总是受支持。
</Note>

## 端点

主网和 devnet 上可用的 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>

## 通知格式

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

* `err: <string|undefined>` - 错误消息。仅在更新类型为 "dead" 时存在。
* `parent: <u64|undefined>` - 父槽位。仅在更新类型为 "createdBank" 时存在。
* `slot: <u64>` - 新更新的槽位
* `stats: <object|undefined>` - 仅在更新类型为 "frozen" 时存在。一个包含以下字段的对象：
  * `maxTransactionsPerEntry: <u64>`
  * `numFailedTransactions: <u64>`
  * `numSuccessfulTransactions: <u64>`
  * `numTransactionEntries: <u64>`
* `timestamp: <i64>` - 更新的 Unix 时间戳（毫秒）
* `type: <string>` - 更新类型，包括以下之一：
  * "firstShredReceived"
  * "completed"
  * "createdBank"
  * "frozen"
  * "dead"
  * "optimisticConfirmation"
  * "root"

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

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

  ```json Notification theme={"system"}
  {
    "jsonrpc": "2.0",
    "method": "slotsUpdatesNotification",
    "params": {
      "result": {
        "parent": 75,
        "slot": 76,
        "timestamp": 1625081266243,
        "type": "optimisticConfirmation"
      },
      "subscription": 0
    }
  }
  ```
</ResponseExample>
