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

> Đăng ký nhận thông báo từ trình xác thực về nhiều loại cập nhật trên mỗi slot.

<Note>
  Gói đăng ký này chưa ổn định. Định dạng của gói đăng ký này có thể thay đổi trong tương lai và không phải lúc nào cũng được hỗ trợ.
</Note>

## Endpoint

WebSocket khả dụng trên mainnet và devnet tại các URL sau:

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

<Note>WebSocket có bộ hẹn giờ ngắt kết nối sau 10 phút không hoạt động. Bạn nên triển khai kiểm tra trạng thái và gửi ping mỗi phút để duy trì kết nối WebSocket.</Note>

## Xác thực

<ParamField query="api-key" type="string" required>
  Khóa API Helius của bạn. Bạn có thể nhận khóa miễn phí trong [bảng điều khiển](https://dashboard.helius.dev/api-keys).
</ParamField>

## Nội dung

<ParamField body="params" type="array">
  <Expandable title="properties" defaultOpen>
    <ParamField body="none" type="null">
      Không yêu cầu tham số.
    </ParamField>
  </Expandable>
</ParamField>

## Phản hồi

<ResponseField name="result" type="integer">
  ID đăng ký (cần thiết để hủy đăng ký)
</ResponseField>

## Định dạng thông báo

Thông báo sẽ là một đối tượng có các trường sau:

* `err: <string|undefined>` - Thông báo lỗi. Chỉ xuất hiện nếu bản cập nhật có loại "dead".
* `parent: <u64|undefined>` - Slot cha. Chỉ xuất hiện nếu bản cập nhật có loại "createdBank".
* `slot: <u64>` - Slot vừa được cập nhật
* `stats: <object|undefined>` - Chỉ xuất hiện nếu bản cập nhật có loại "frozen". Một đối tượng có các trường sau:
  * `maxTransactionsPerEntry: <u64>`
  * `numFailedTransactions: <u64>`
  * `numSuccessfulTransactions: <u64>`
  * `numTransactionEntries: <u64>`
* `timestamp: <i64>` - Dấu thời gian Unix của bản cập nhật, tính bằng mili giây
* `type: <string>` - Loại cập nhật, là một trong các giá trị sau:
  * "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>
