Ethereum
¿Listo para usar esto en producción?
El plan gratuito cubre proyectos personales. El pago por uso escala sin necesidad de tarjeta.
Ethereum
El plan gratuito cubre proyectos personales. El pago por uso escala sin necesidad de tarjeta.
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.| # | Nombre | Tipo | Requerido | Descripción |
|---|---|---|---|---|
| 1 | subscriptionType | string | Sí | Subscription type: `newHeads` — new block headers; `logs` — matching event logs; `newPendingTransactions` — pending tx hashes; `syncing` — node sync status changes. |
| 2 | filter | object | No | Required only for `logs` subscriptions. Same filter shape as eth_newFilter: `address` and/or `topics`. |
| Tipo | Descripción |
|---|---|
| string | Hex subscription ID. Subsequent notifications arrive as `eth_subscription` messages with `params.subscription` matching this ID. |
Try it live in the Ethereum playground.
| Código | Mensaje | Causa |
|---|---|---|
-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.Parámetros
"newHeads" | "logs" | "newPendingTransactions" | "syncing"
Required only for `logs` subscriptions. Same filter shape as eth_newFilter: `address` and/or `topics`.