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

# 購読する

> 高性能なgRPC APIを使用して、アカウント、トランザクション、ブロック、およびスロットの更新を購読し、リアルタイム通知を受け取ります。

<hide>
  ## エンドポイント

  gRPCサービスは次のURLでmainnetとdevnetで利用可能です:

  * **Mainnet** `https://laserstream-mainnet.helius-rpc.com:443`
  * **Devnet** `https://laserstream-devnet.helius-rpc.com:443`
</hide>

## 認証

<ParamField query="x-token" type="string" required>
  あなたのHelius APIキー。無料で取得できます
  [ダッシュボード](https://dashboard.helius.dev/api-keys)で。
</ParamField>

## メッセージ

gRPC APIは、単一のリクエストで組み合わせることのできる複数のサブスクリプションタイプをサポートします:

<ParamField body="accounts" type="object">
  アカウントの更新を購読します。指定されたアカウントが変更された場合にデータを返します。

  <Expandable title="プロパティ" defaultOpen>
    <ParamField body="account" type="array">
      監視するアカウントのパブキーの配列。
    </ParamField>

    <ParamField body="owner" type="array">
      監視する所有者のパブキーの配列（これらのプログラムが所有するすべてのアカウント）。
    </ParamField>

    <ParamField body="filters" type="object">
      オプションで適用するフィルタ。

      <Expandable title="フィルタオプション">
        <ParamField body="memcmp" type="object">
          アカウントデータ内のオフセットで特定のバイトによるフィルタリング。

          <Expandable title="プロパティ">
            <ParamField body="offset" type="integer">
              データの比較を開始するバイト位置。
            </ParamField>

            <ParamField body="bytes" type="string">
              比較対象データ（バイトフォーマット）。
            </ParamField>

            <ParamField body="base58" type="string">
              比較対象データ（base58フォーマット）。
            </ParamField>

            <ParamField body="base64" type="string">
              比較対象データ（base64フォーマット）。
            </ParamField>
          </Expandable>
        </ParamField>

        <ParamField body="datasize" type="integer">
          正確なアカウントデータサイズによるフィルタリング（バイト単位）。
        </ParamField>

        <ParamField body="token_account_state" type="boolean">
          トークンアカウントのみをフィルタ。
        </ParamField>

        <ParamField body="lamports" type="object">
          SOLバランスによるフィルタリング。

          <Expandable title="比較演算子">
            <ParamField body="eq" type="integer">
              指定された額と等しい。
            </ParamField>

            <ParamField body="ne" type="integer">
              指定された額と等しくない。
            </ParamField>

            <ParamField body="lt" type="integer">
              指定された額より小さい。
            </ParamField>

            <ParamField body="gt" type="integer">
              指定された額より大きい。
            </ParamField>
          </Expandable>
        </ParamField>
      </Expandable>
    </ParamField>

    <ParamField body="nonempty_txn_signature" type="boolean">
      `true`の場合、トランザクションによって引き起こされた更新のみを含めます。`false`の場合、トランザクションによって引き起こされていない更新のみを含めます。`undefined`の場合、すべての更新を含めます。
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="slots" type="object">
  スロットの更新を購読します。

  <Expandable title="プロパティ" defaultOpen>
    <ParamField body="filter_by_commitment" type="boolean">
      コミットメントレベルでスロットをフィルタ。
    </ParamField>

    <ParamField body="interslot_updates" type="boolean">
      中間スロットのステータス更新を含めます（PROCESSED, CONFIRMED, FINALIZED,
      FIRST\_SHRED\_RECEIVED, COMPLETED, CREATED\_BANK, DEAD）。
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="transactions" type="object">
  トランザクションの更新を購読します。

  <Expandable title="プロパティ" defaultOpen>
    <ParamField body="vote" type="boolean">
      投票トランザクションを含めます。
    </ParamField>

    <ParamField body="failed" type="boolean">
      失敗したトランザクションを含めます。
    </ParamField>

    <ParamField body="signature" type="string">
      特定のトランザクション署名を監視します。
    </ParamField>

    <ParamField body="account_include" type="array">
      これらのアカウントに影響を与えるトランザクションのみを含めます。
    </ParamField>

    <ParamField body="account_exclude" type="array">
      これらのアカウントに影響を与えるトランザクションを除外します。
    </ParamField>

    <ParamField body="account_required" type="array">
      これらすべてのアカウントに影響を与える必要があるトランザクション。
    </ParamField>

    <ParamField body="token_accounts" type="enum">
      オプションの関連トークンアカウント（ATA）展開（フィールドタグ30, `TokenAccountExpansionControlFlag`）。設定した場合、`account_include`ウォレットは、SPLトークンバランスを**所有する**トランザクションと一致します。例えば、ウォレットのトークンアカウントではなく、そのパブキーに触れるトークンの受信転送。2つのバリアント:

      * `ALL` (**0**) — ウォレットが所有するトークンバランスを参照する任意のトランザクションに一致します。高ボリューム。
      * `BALANCE_CHANGED` (**1**) — ウォレットが所有するトークンバランスがトランザクションで変更（またはトークンアカウントが閉鎖）された場合に一致します。

      展開を無効にするには、**フィールドを欠席させたままにします**（`None`) — "off"の列挙値はありません。範囲外の整数は構成ビルド時に拒否されます: `Invalid token_accounts value, expected ALL (0) or BALANCE_CHANGED (1)`。

      <Warning>
        `ALL`は**ゼロ値**です。列挙を`0`に設定して"デフォルト/オフ"を期待するクライアントは`ALL`を取得します — 最も幅広く、高ボリュームなモードです。"拡張なし"を意味する唯一の方法はフィールドを完全に省略することです。
      </Warning>
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="transactions_status" type="object">
  トランザクションステータスの更新を購読します。

  <Expandable title="プロパティ" defaultOpen>
    <ParamField body="vote" type="boolean">
      投票トランザクションを含めます。
    </ParamField>

    <ParamField body="failed" type="boolean">
      失敗したトランザクションを含めます。
    </ParamField>

    <ParamField body="signature" type="string">
      特定のトランザクション署名を監視します。
    </ParamField>

    <ParamField body="account_include" type="array">
      これらのアカウントに影響を与えるトランザクションのみを含めます。
    </ParamField>

    <ParamField body="account_exclude" type="array">
      これらのアカウントに影響を与えるトランザクションを除外します。
    </ParamField>

    <ParamField body="account_required" type="array">
      これらすべてのアカウントに影響を与える必要があるトランザクション。
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="blocks" type="object">
  ブロックの更新を購読します。

  <Expandable title="プロパティ" defaultOpen>
    <ParamField body="account_include" type="array">
      これらのアカウントに影響を与えるトランザクションを含むブロックのみを含めます。
    </ParamField>

    <ParamField body="include_transactions" type="boolean">
      完全なトランザクションの詳細を含めます。
    </ParamField>

    <ParamField body="include_accounts" type="boolean">
      アカウントの更新を含めます。
    </ParamField>

    <ParamField body="include_entries" type="boolean">
      ブロックエントリを含めます。
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="blocks_meta" type="object">
  ブロックメタデータの更新を購読します（完全なブロックの更新より軽量です）。

  <Expandable title="returns" defaultOpen>
    <ParamField body="slot" type="integer">
      スロット番号。
    </ParamField>

    <ParamField body="blockhash" type="string">
      ブロックハッシュ。
    </ParamField>

    <ParamField body="rewards" type="array">
      報酬情報。
    </ParamField>

    <ParamField body="block_time" type="integer">
      ブロック時間。
    </ParamField>

    <ParamField body="block_height" type="integer">
      ブロック高さ。
    </ParamField>

    <ParamField body="parent_slot" type="integer">
      親スロット。
    </ParamField>

    <ParamField body="parent_blockhash" type="string">
      親ブロックハッシュ。
    </ParamField>

    <ParamField body="executed_transaction_count" type="integer">
      トランザクション数。
    </ParamField>

    <ParamField body="entries_count" type="integer">
      エントリ数。
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="entry" type="object">
  エントリの更新を購読します。

  <Expandable title="returns" defaultOpen>
    <ParamField body="slot" type="integer">
      スロット番号。
    </ParamField>

    <ParamField body="index" type="integer">
      エントリインデックス。
    </ParamField>

    <ParamField body="num_hashes" type="integer">
      ハッシュの数。
    </ParamField>

    <ParamField body="hash" type="string">
      ハッシュ。
    </ParamField>

    <ParamField body="executed_transaction_count" type="integer">
      トランザクション数。
    </ParamField>

    <ParamField body="starting_transaction_index" type="integer">
      開始トランザクションインデックス。
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="commitment" type="enum">
  サブスクリプションのコミットメントレベル:

  <Expandable title="レベル" defaultOpen>
    <ParamField body="PROCESSED" type="integer">
      (0): 現在のノードによって処理済み。
    </ParamField>

    <ParamField body="CONFIRMED" type="integer">
      (1): クラスターの超多数によって確認済み。
    </ParamField>

    <ParamField body="FINALIZED" type="integer">
      (2): クラスターによって最終化済み。
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="accounts_data_slice" type="array">
  受信する部分アカウントデータを指定します:

  <Expandable title="プロパティ" defaultOpen>
    <ParamField body="offset" type="integer">
      データを読み始めるバイト位置。
    </ParamField>

    <ParamField body="length" type="integer">
      読み取るバイト数。
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="ping" type="object">
  接続の健康チェックのためのping-pongメッセージを有効にします。

  <Expandable title="プロパティ" defaultOpen>
    <ParamField body="id" type="integer">
      pingの数値識別子。
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="from_slot" type="integer">
  更新を受信し始めるスロット。これより前のスロットの更新は除外されます。
</ParamField>

<RequestExample>
  ```json Accounts Subscription theme={"system"}
  {
    "slots": {
        "slots": {}
    },
    "accounts": {
        "user-defined-label": {
            "account": [
                "DjUF9ASpyMbVpGJmTvzfSbCgUWj6JowwLh8dGAJzSPmu",
                "5U3bH5b6XtG99aVCE9ycvDgBKQx3fVT8WwTNbMToFuEr"
            ],
            "owner": [
                "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
            ],
            "filter": {
                "memcmp": {
                    "offset": 0,
                    "bytes": "0102030405"
                },
                "datasize": 165,
                "token_account_state": true,
                "lamports": {
                    "gt": 100000000
                }
            },
            "nonempty_txn_signature": true
        }
    },
    "transactions": {},
    "blocks": {},
    "blocks_meta": {},
    "accounts_data_slice": [],
    "commitment": 1
  }
  ```

  ```json Slots Subscription theme={"system"}
  {
    "slots": {
      "incoming_slots": {}
    },
    "commitment": 1
  }
  ```

  ```json Transactions Subscription theme={"system"}
  {
    "transactions": {
      "vote": false,
      "failed": true,
      "signature": "4RPMxKBhCBubFmZ1r9BC52ztjG3qBTW9Gp1PXfufUSATQaLKTW3Dj6vQBYyVrhfjgJ4PjZLzwYs4Z92KDCPw8Qym",
      "account_include": ["DjUF9ASpyMbVpGJmTvzfSbCgUWj6JowwLh8dGAJzSPmu"],
      "account_exclude": ["TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"],
      "account_required": ["11111111111111111111111111111111"]
    },
    "commitment": 2
  }
  ```

  ```json Wallet + Token Transfers (ATA expansion) theme={"system"}
  {
    "transactions": {
      "wallet": {
        "vote": false,
        "failed": false,
        "account_include": ["DjUF9ASpyMbVpGJmTvzfSbCgUWj6JowwLh8dGAJzSPmu"],
        "account_exclude": [],
        "account_required": [],
        "token_accounts": 1
      }
    },
    "commitment": 1
  }
  ```

  ```json Transaction Status Subscription theme={"system"}
  {
    "transactions_status": {
      "vote": false,
      "failed": true,
      "account_include": ["DjUF9ASpyMbVpGJmTvzfSbCgUWj6JowwLh8dGAJzSPmu"],
      "account_exclude": ["TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"],
      "account_required": ["11111111111111111111111111111111"]
    },
    "commitment": 2
  }
  ```

  ```json Blocks Subscription theme={"system"}
  {
    "blocks": {
      "account_include": ["DjUF9ASpyMbVpGJmTvzfSbCgUWj6JowwLh8dGAJzSPmu"],
      "include_transactions": 1,
      "include_accounts": 1,
      "include_entries": 0
    },
    "commitment": 2
  }
  ```

  ```json Block Metadata Subscription theme={"system"}
  {
    "blocks_meta": {},
    "commitment": 2,
    "from_slot": 139000000
  }
  ```

  ```json Entry Subscription theme={"system"}
  {
    "entry": {},
    "commitment": 1
  }
  ```

  ```json Partial Account Data Subscription theme={"system"}
  {
    "accounts": {
      "account": ["DjUF9ASpyMbVpGJmTvzfSbCgUWj6JowwLh8dGAJzSPmu"]
    },
    "accounts_data_slice": [
      {
        "offset": 0,
        "length": 64
      },
      {
        "offset": 128,
        "length": 32
      }
    ],
    "commitment": 2
  }
  ```

  ```json Ping Subscription theme={"system"}
  {
    "ping": {
      "id": 1
    }
  }
  ```

  ```json Combined Subscription theme={"system"}
  {
    "accounts": {
      "account": ["DjUF9ASpyMbVpGJmTvzfSbCgUWj6JowwLh8dGAJzSPmu"],
      "nonempty_txn_signature": true
    },
    "slots": {
      "filter_by_commitment": 1,
      "interslot_updates": 1
    },
    "commitment": 2,
    "from_slot": 139000000,
    "ping": {
      "id": 123
    }
  }
  ```
</RequestExample>

## コミットメントレベル

すべてのサブスクリプションは次のコミットメントレベルをサポートしています:

* `PROCESSED`: 現在のノードによって処理された(0)
* `CONFIRMED`: クラスターの超多数によって確認された(1)
* `FINALIZED`: クラスターによって最終化された(2)

## レスポンス構造

サブスクリプションのレスポンスには以下が含まれます:

* `filters`: この更新に一致したフィルタ名
* 以下の更新タイプの1つ:
  * `account`: アカウントデータ、所有者、ラメンツ、実行可能ステータスなど
  * `slot`: スロット情報とステータス更新
  * `transaction`: 完全なトランザクションの詳細、署名、メタデータ
  * `transaction_status`: トランザクション実行ステータス（成功／エラー）
  * `block`: トランザクション、アカウント、報酬を含む完全なブロックデータ
  * `block_meta`: 完全なトランザクションの詳細なしの軽量なブロックメタデータ
  * `entry`: ブロック内のエントリ詳細
  * `ping`/`pong`: 接続の健康チェックメッセージ
* `created_at`: 更新が作成されたタイムスタンプ

<ResponseExample>
  ```json Account Update theme={"system"}
  {
    "filters": ["accounts"],
    "account": {
      "account": {
        "pubkey": "BASE58_ENCODED_PUBKEY",
        "lamports": 12345678,
        "owner": "BASE58_ENCODED_OWNER",
        "executable": false,
        "rent_epoch": 361,
        "data": "BASE64_ENCODED_DATA",
        "write_version": 123,
        "txn_signature": "BASE58_ENCODED_SIGNATURE"
      },
      "slot": 189554321,
      "is_startup": false
    },
    "created_at": "2023-04-28T12:34:56.789Z"
  }
  ```

  ```json Slot Update theme={"system"}
  {
    "filters": ["slots"],
    "slot": {
      "slot": 189554321,
      "parent": 189554320,
      "status": 2,
      "dead_error": null
    },
    "created_at": "2023-04-28T12:34:56.789Z"
  }
  ```

  ```json Transaction Update theme={"system"}
  {
    "filters": ["transactions"],
    "transaction": {
      "transaction": {
        "signature": "BASE58_ENCODED_SIGNATURE",
        "is_vote": false,
        "transaction": {
          "signatures": ["BASE58_ENCODED_SIGNATURE"],
          "message": {
            "header": {
              "num_required_signatures": 1,
              "num_readonly_signed_accounts": 0,
              "num_readonly_unsigned_accounts": 1
            },
            "account_keys": ["BASE58_ENCODED_PUBKEY1", "BASE58_ENCODED_PUBKEY2"],
            "recent_blockhash": "BASE58_ENCODED_BLOCKHASH",
            "instructions": [
              {
                "program_id_index": 1,
                "accounts": [0],
                "data": "BASE64_ENCODED_INSTRUCTION_DATA"
              }
            ]
          }
        },
        "meta": {
          "err": null,
          "fee": 5000,
          "pre_balances": [10000000, 1],
          "post_balances": [9995000, 1],
          "pre_token_balances": [],
          "post_token_balances": [],
          "log_messages": ["Program log: Instruction executed"],
          "rewards": []
        },
        "index": 2
      },
      "slot": 189554321
    },
    "created_at": "2023-04-28T12:34:56.789Z"
  }
  ```

  ```json Block Metadata Update theme={"system"}
  {
    "filters": ["blocks_meta"],
    "block_meta": {
      "slot": 189554321,
      "blockhash": "BASE58_ENCODED_BLOCKHASH",
      "rewards": [
        {
          "pubkey": "BASE58_ENCODED_PUBKEY",
          "lamports": 1785000,
          "post_balance": 48589432109,
          "reward_type": 0,
          "commission": 10
        }
      ],
      "block_time": 1682684096,
      "block_height": 185432109,
      "parent_slot": 189554320,
      "parent_blockhash": "BASE58_ENCODED_PARENT_BLOCKHASH",
      "executed_transaction_count": 2576,
      "entries_count": 16
    },
    "created_at": "2023-04-28T12:34:56.789Z"
  }
  ```

  ```json Entry Update theme={"system"}
  {
    "filters": ["entry"],
    "entry": {
      "slot": 189554321,
      "index": 5,
      "num_hashes": 8765432,
      "hash": "BASE58_ENCODED_HASH",
      "executed_transaction_count": 128,
      "starting_transaction_index": 1024
    },
    "created_at": "2023-04-28T12:34:56.789Z"
  }
  ```

  ```json Pong Response theme={"system"}
  {
    "filters": [],
    "pong": {
      "id": 1
    },
    "created_at": "2023-04-28T12:34:56.789Z"
  }
  ```
</ResponseExample>
