Ethereum
Prêt à utiliser cela en production ?
Le niveau gratuit couvre les projets personnels. Le paiement à l'usage évolue sans carte bancaire.
Ethereum
Le niveau gratuit couvre les projets personnels. Le paiement à l'usage évolue sans carte bancaire.
eth_subscribe opens a push-based stream over a WebSocket connection to an Ethereum node. Instead of polling on a timer, you subscribe once and the node sends eth_subscription notifications as events happen. Four subscription types are supported: newHeads for each new block header (about one per 12-second slot under PoS), logs for event logs matching an address-and-topics filter, newPendingTransactions for mempool hashes, and syncing for changes in the node's sync state. Because this is a stateful streaming method, it requires the WebSocket endpoint wss://ethereum.therpc.io/YOUR_API_KEY on chain ID 1, not the plain HTTP path. The call returns a hex subscription ID, and you tear the stream down with eth_unsubscribe.
newHeads to drive a live dashboard or block-explorer view, reacting the instant each Ethereum block header arrives instead of polling for the chain head.logs subscription with a contract address and topic set to receive smart-contract events, such as Aave borrows or an ERC-721 mint, the moment the blocks carrying them are gossiped.newPendingTransactions to observe transactions entering the mempool, feeding a fee tracker or front-running-aware order flow.| # | Nom | Type | Obligatoire | Description |
|---|---|---|---|---|
| 1 | subscriptionType | string | Oui | Subscription type: `newHeads` — new block headers; `logs` — matching event logs; `newPendingTransactions` — pending tx hashes; `syncing` — node sync status changes. |
| 2 | filter | object | Non | Required only for `logs` subscriptions. Same filter shape as eth_newFilter: `address` and/or `topics`. |
| Type | Description |
|---|---|
| string | Hex subscription ID. Subsequent notifications arrive as `eth_subscription` messages with `params.subscription` matching this ID. |
Try it live in the Ethereum playground.
| Code | Message | Cause |
|---|---|---|
-32602 | invalid argument | Unknown subscription type or malformed filter for a logs subscription. |
-32000 | notifications not supported | Method called over an HTTP connection instead of WebSocket. |
wss://ethereum.therpc.io/YOUR_API_KEY.eth_getLogs over the missed block range so you do not silently skip events.logs notifications can arrive with removed: true to retract a previously delivered log. Handle these explicitly, since an event you acted on may end up off the canonical chain before it reaches the finalized tag.Paramètres
"newHeads" | "logs" | "newPendingTransactions" | "syncing"
Required only for `logs` subscriptions. Same filter shape as eth_newFilter: `address` and/or `topics`.