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

# signatureSubscribe

> 订阅以在具有给定签名的交易达到指定的承诺级别时收到通知。

这是单个通知的订阅。由服务器在通知 `signatureNotification` 发送后自动取消。

## 端点

主网和开发网均可通过以下 URL 使用 Websockets：

* **主网** `wss://mainnet.helius-rpc.com/?api-key=<api-key>`
* **开发网** `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" required>
  <Expandable title="properties" defaultOpen>
    <ParamField body="signature" type="string" required>
      交易签名，作为 base-58 编码字符串。

      交易签名必须是交易的第一个签名（有关更多详细信息，请参阅交易 ID）。
    </ParamField>

    <ParamField body="config" type="object">
      包含以下字段的配置对象：

      <ParamField body="commitment" type="string">
        订阅的承诺级别。可以是 `finalized`、`confirmed` 或 `processed`。
      </ParamField>

      <ParamField body="enableReceivedNotification" type="boolean">
        是否在收到交易签名时发送通知。
      </ParamField>
    </ParamField>
  </Expandable>
</ParamField>

## 响应

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

## 通知格式

通知将是一个 RpcResponse JSON 对象，值包含一个对象，具有：

* `slot: <u64>` - 相应的插槽。
* `value: <object|string>` - RpcSignatureResult 的通知值，结果为：
  * 当 `enableReceivedNotification` 为 `true` 并收到签名时：字面字符串 `"receivedSignature"`，或者
  * 当签名被处理时：`err: <object|null>`：
    * 如果交易在指定的承诺级别成功处理，则为 `null`，或者
    * 如果交易失败，则为 TransactionError

<RequestExample>
  ```json Request theme={"system"}
  {
    "jsonrpc": "2.0",
    "id": 1,
    "method": "signatureSubscribe",
    "params": [
      "2EBVM6cB8vAAD93Ktr6Vd8p67XPbQzCJX47MpReuiCXJAtcjaxpvWpcg9Ege1Nr5Tk3a2GFrByT7WPBjdsTycY9b",
      {
        "commitment": "finalized",
        "enableReceivedNotification": false
      }
    ]
  }
  ```
</RequestExample>

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

  ```json Notification (Processed Transaction) theme={"system"}
  {
    "jsonrpc": "2.0",
    "method": "signatureNotification",
    "params": {
      "result": {
        "context": {
          "slot": 5207624
        },
        "value": {
          "err": null
        }
      },
      "subscription": 24006
    }
  }
  ```

  ```json Notification (Received Transaction) theme={"system"}
  {
    "jsonrpc": "2.0",
    "method": "signatureNotification",
    "params": {
      "result": {
        "context": {
          "slot": 5207624
        },
        "value": "receivedSignature"
      },
      "subscription": 24006
    }
  }
  ```
</ResponseExample>
