Real-time Substreams WebSocket streaming

    Substreams WebSocketBeta

    Stream decoded blocks, swaps, transfers, and any Substreams DatabaseChanges output in real time. Subscribe to one channel or many across SVM, EVM, and TVM with the same URL pattern — and resume where you left off after a disconnect.

    EVTsession welcome#

    Sent once per connection. Describes every stream the server is configured to broadcast, and echoes the subscriptions this connection actually resolved to.

    {
      "type":        "session",
      "status":      "connected",
      "client_id":   1,
      "streams": [
        {
          "network":        "solana",
          "package_name":   "svm_dex",
          "package_version":"v0.5.1",
          "module_hash":    "bd388f2e39f5dcc237cfbdb8d6c96d9e5678c797",
          "tables":         ["swaps"]
        }
      ],
      "subscriptions":  ["solana@swaps"],
      "wrap_envelope":  false
    }

    EVTblock payload#

    One payload per (network, table) per block. A package that emits both swaps and transfers produces two per-table broadcasts each block. Event-row values are strings on the wire per DatabaseChanges proto — numeric parsing is the consumer's job.

    {
      "network":     "solana",
      "table":       "swaps",
      "block_num":   350000000,
      "block_hash":  "Gsk6…",
      "timestamp":   "2026-05-13 17:00:00",
      "module_hash": "bd388f2e…",
      "events": [
        {
          "protocol":      "raydium_cpmm",
          "user":          "F2MUE…",
          "input_mint":    "So11111111111111111111111111111111111111112",
          "output_mint":   "13muFY…",
          "input_amount":  "1287000000",
          "output_amount": "6848381008732"
        }
      ]
    }

    Fields

    networkstring

    Chain identifier — solana, mainnet, base, …

    tablestring

    DatabaseChanges table emitted by the package's db_out. Together with network identifies the channel.

    block_numnumber

    Block height. Use block_num + 1 as the resume cursor on reconnect.

    module_hashstring

    40-hex SHA-1 of the Substreams output module. Mismatch with the welcome value means the operator deployed a new package.

    eventsarray

    Rows for this table only, in source order. Per-event @table is dropped since the parent payload carries table. Upstream ordinal, operation, pk, composite_pk, update_op are never surfaced.

    EVTstream lifecycle#

    Same connection, distinguished by "type": "stream". Carries package provenance so clients can route on their own.

    { "type": "stream", "status": "started",   "network": "…", "module_hash": "…" }
    { "type": "stream", "status": "completed", "…" }
    { "type": "stream", "status": "error",     "message": "…" }
    { "type": "stream", "status": "fatal",     "message": "…" }
    { "type": "stream", "status": "undo",      "last_valid_block": 350000000 }

    undo fires on chain reorganizations. Roll back any state materialized past last_valid_block.