eth_subscribe
Creates a subscription. The first parameter selects the subscription kind and determines which optional second-parameter shape applies and what notification data is pushed to the client. Returns a subscription ID that can later be passed to `eth_unsubscribe` to cancel the subscription.
Subscription notifications are delivered as JSON-RPC notifications with method `eth_subscription` and `params` of the form `{ "subscription": <id>, "result": <data> }`, where `<data>` depends on the kind:
- `newHeads`: a block header (same shape as a Block object, without `transactions`, `withdrawals`, `uncles`, or `size`). No second parameter. - `logs`: a Log object matching the supplied Filter (same shape as the filter accepted by `eth_getLogs`). Removed logs (due to chain reorgs) are pushed with `removed: true`. - `newPendingTransactions`: a transaction hash by default, or a full transaction object if the optional boolean second parameter is `true`. - `transactionReceipts`: an array of receipt objects (same shape as `eth_getTransactionReceipt`) for transactions included in the latest imported block. If the optional `{ transactionHashes: [...] }` filter is provided, only receipts for those transactions are pushed; otherwise receipts for all transactions in the block are pushed.
This method is only available on transports that support server-initiated notifications (e.g. WebSocket and IPC).
Subscribes to events on the node.
Parameters (by position)
kind string required
arg unknown or unknown or object
Show Option 1 Logs filter (for `logs`)
Logs filter (for `logs`) Logs filter (for `logs`) fields
arg object or object
Show Option 1 Filter by block range object
Filter by block range objectFilter by block range fields
arg object
Filter by block range
Show arg object
arg objectarg fields
-
address
null or string or array<string>
Show Option 1
Any AddressnullShow Option 2
AddressstringShow Option 3
Addressesarray -
fromBlock
string or string
Show Option 1
Block numberstringShow Option 2
Block tagstringBlock tagfieldsearliest: The lowest numbered block the client has available;finalized: The most recent crypto-economically secure block, cannot be re-orged outside of manual intervention driven by community coordination;safe: The most recent block that is safe from re-orgs under honest majority and certain synchronicity assumptions;latest: The most recent block in the canonical chain observed by the client, this block may be re-orged out of the canonical chain even under healthy/normal conditions. Before the merge transition is finalized, any call querying forfinalizedorsafeblock MUST be responded to with-39001: Unknown blockerrorfromBlock
stringearliest: The lowest numbered block the client has available;finalized: The most recent crypto-economically secure block, cannot be re-orged outside of manual intervention driven by community coordination;safe: The most recent block that is safe from re-orgs under honest majority and certain synchronicity assumptions;latest: The most recent block in the canonical chain observed by the client, this block may be re-orged out of the canonical chain even under healthy/normal conditions. Before the merge transition is finalized, any call querying forfinalizedorsafeblock MUST be responded to with-39001: Unknown blockerrorAllowed values:
earliestfinalizedsafelatest -
toBlock
string or string
Show Option 1
Block numberstringShow Option 2
Block tagstringBlock tagfieldsearliest: The lowest numbered block the client has available;finalized: The most recent crypto-economically secure block, cannot be re-orged outside of manual intervention driven by community coordination;safe: The most recent block that is safe from re-orgs under honest majority and certain synchronicity assumptions;latest: The most recent block in the canonical chain observed by the client, this block may be re-orged out of the canonical chain even under healthy/normal conditions. Before the merge transition is finalized, any call querying forfinalizedorsafeblock MUST be responded to with-39001: Unknown blockerrortoBlock
stringearliest: The lowest numbered block the client has available;finalized: The most recent crypto-economically secure block, cannot be re-orged outside of manual intervention driven by community coordination;safe: The most recent block that is safe from re-orgs under honest majority and certain synchronicity assumptions;latest: The most recent block in the canonical chain observed by the client, this block may be re-orged out of the canonical chain even under healthy/normal conditions. Before the merge transition is finalized, any call querying forfinalizedorsafeblock MUST be responded to with-39001: Unknown blockerrorAllowed values:
earliestfinalizedsafelatest -
topics
null or array<unknown>
Show Option 1
Any Topic MatchnullShow Option 2
Specified Filter TopicsarraySpecified Filter Topicsfieldstopics
null or string or array<string>Show Option 1
Any Topic MatchnullShow Option 2
Single Topic MatchstringShow Option 3
Multiple Topic Matcharray -
additionalProperties
true
Show Option 2 Filter by block hash object
Filter by block hash objectFilter by block hash fields
arg object
Filter by block hash
Show arg object
arg objectarg fields
-
address
null or string or array<string>
Show Option 1
Any AddressnullShow Option 2
AddressstringShow Option 3
Addressesarray -
blockHash
stringrequiredblock hash
Match pattern:
^0x[0-9a-f]{64}$
-
topics
null or array<unknown>
Show Option 1
Any Topic MatchnullShow Option 2
Specified Filter TopicsarraySpecified Filter Topicsfieldstopics
null or string or array<string>Show Option 1
Any Topic MatchnullShow Option 2
Single Topic MatchstringShow Option 3
Multiple Topic Matcharray -
additionalProperties
true
Show Option 2 Full-transaction flag (for `newPendingTransactions`) boolean
Full-transaction flag (for `newPendingTransactions`) booleanFull-transaction flag (for `newPendingTransactions`) fields
arg boolean
Full-transaction flag (for newPendingTransactions)
Show Option 3 Transaction receipts filter (for `transactionReceipts`) object
Transaction receipts filter (for `transactionReceipts`) objectResult
Subscription ID string
hex encoded unsigned integer
Match pattern: ^0x(0|[1-9a-f][0-9a-f]*)$