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

# logsSubscribe

> トランザクションのログ送信を購読します。

## エンドポイント

以下のURLで本番環境と開発環境でWebsocketが利用可能です:

* **本番環境** `wss://mainnet.helius-rpc.com/?api-key=<api-key>`
* **開発環境** `wss://devnet.helius-rpc.com/?api-key=<api-key>`

<Note>Websocketは10分間の非アクティブタイマーがありますので、接続を維持するために定期的なヘルスチェックと毎分pingを送信することを強く推奨します。</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="プロパティ" defaultOpen>
    <ParamField body="filter" type="string | object" required>
      アカウントタイプで結果を受け取るためのログのフィルター条件。現在サポートされているフィルタータイプは以下の通りです:

      * `all` - 単純な投票トランザクションを除くすべてのトランザクションを購読
      * `allWithVotes` - 単純な投票トランザクションを含むすべてのトランザクションを購読
      * 以下のフィールドを持つJSONオブジェクト:
        * `mentions: [ <string> ]` - 単一のPubkey（base-58エンコードされた文字列として）を含む配列; 存在する場合、このアドレスが言及されているトランザクションのみを購読

      注: 現在、`mentions`フィールドは、メソッド呼び出しごとに1つのPubkey文字列のみをサポートしています。複数のアドレスを指定するとエラーになります。
    </ParamField>

    <ParamField body="config" type="object">
      以下のフィールドを含む構成オブジェクト:

      <ParamField body="commitment" type="string">
        購読のコミットメントレベル。 `finalized`, `confirmed`, または `processed` が指定可能です。
      </ParamField>
    </ParamField>
  </Expandable>
</ParamField>

## レスポンス

<ResponseField name="result" type="integer">
  購読ID（購読を解除するために必要）
</ResponseField>

## 通知フォーマット

通知は次の値を持つRpcResponse JSONオブジェクトとなります:

* `signature: <string>` - トランザクション署名base58エンコード。
* `err: <object|null>` - トランザクションが失敗した場合のエラー、成功した場合はnull。 トランザクションエラー定義を参照。
* `logs: <array[string]>` - トランザクション実行中に出力されたログメッセージの配列。

<RequestExample>
  ```json Request theme={"system"}
  {
    "jsonrpc": "2.0",
    "id": 1,
    "method": "logsSubscribe",
    "params": [
      {
        "mentions": ["11111111111111111111111111111111"]
      },
      {
        "commitment": "finalized"
      }
    ]
  }
  ```
</RequestExample>

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

  ```json Notification theme={"system"}
  {
    "jsonrpc": "2.0",
    "method": "logsNotification",
    "params": {
      "result": {
        "context": {
          "slot": 5208469
        },
        "value": {
          "signature": "5h6xBEauJ3PK6SWCZ1PGjBvj8vDdWG3KpwATGy1ARAXFSDwt8GFXM7W5Ncn16wmqokgpiKRLuS83KUxyZyv2sUYv",
          "err": null,
          "logs": [
            "SBF program 83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri success"
          ]
        }
      },
      "subscription": 24040
    }
  }
  ```
</ResponseExample>
