eth_ subscribeWebSocket
Creates a connection-scoped WebSocket subscription for new events. Reconnects require a new subscription and historical backfill; supported event types depend on the selected upstream.
EthereumTransport WSTry-it ws docsHow to use
- Open a WebSocket to the chain WS endpoint with your key in the path.
- Copy the wscat example below into your terminal.
- Requires a persistent WebSocket — not a one-shot HTTP POST.
Parameters
JSON-RPC positional arguments — order matches the array sent in params. Index badges below match array positions.
typeStringrequiredSubscription type string. Common values: "newHeads", "logs", "newPendingTransactions".
newHeadslogsnewPendingTransactionsfilterObjectoptionalOnly for logs: address and topics filters. This is not the full eth_getLogs filter: subscriptions do not query a historical fromBlock/toBlock range. Use eth_getLogs for backfill.
params array (shape)
1[2 "newHeads"3]
Response fields
The result row describes the complete result; other rows describe its object fields or array elements. Indented rows describe nested members. For subscriptions,params.* rows describe later notifications rather than the initial reply.
| Field | Type | Description |
|---|---|---|
result | DATA | Subscription id; subsequent notifications reference it. |
params.subscription | DATA | Subsequent eth_subscription notifications identify this subscription; notifications have no request id. |
params.result | OBJECT|DATA | Notification payload: header for newHeads, log object for logs, or transaction hash for a supported pending-transaction subscription. New events can be duplicated or reorganized. |