Avalanche
¿Listo para usar esto en producción?
El plan gratuito cubre proyectos personales. El pago por uso escala sin necesidad de tarjeta.
Avalanche
El plan gratuito cubre proyectos personales. El pago por uso escala sin necesidad de tarjeta.
eth_subscribe opens a push-based subscription over a WebSocket connection to an Avalanche C-Chain node. Instead of repeatedly polling for new data, your client registers interest in a stream — new block headers, matching logs, pending transaction hashes, or sync status — and the node pushes eth_subscription notifications as events occur. On the C-Chain, where Snowman consensus delivers finality in roughly one to two seconds, this lets you react to confirmed AVAX activity almost as fast as it lands. Point your WebSocket client at https://avalanche.therpc.io/YOUR_API_KEY (chain ID 43114, 0xa86a) using the wss:// scheme, and you can drive event-driven applications without the latency and overhead of a polling loop.
newHeads to stream fresh C-Chain block headers into a real-time dashboard, updating chain height and gas readings every block without a single poll.logs with an address and topic filter to receive events from a contract — for example Trader Joe swaps or an Aave lending market — the moment they are mined.newPendingTransactions to watch AVAX-denominated transactions enter the C-Chain mempool, useful for tracking submissions before they finalize under Snowman consensus.| # | 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 Avalanche 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. |
eth_subscribe only works over a WebSocket connection. Calling it over plain HTTP against https://avalanche.therpc.io/YOUR_API_KEY returns a "notifications not supported" error — connect with the wss:// scheme instead.eth_getLogs over the missed C-Chain block range so you do not lose events.removed: true during a chain reorganization. Although the C-Chain's fast Snowman finality makes deep reorgs rare, your handler should still process removed events explicitly to keep downstream state consistent.Parámetros
"newHeads" | "logs" | "newPendingTransactions" | "syncing"
Required only for `logs` subscriptions. Same filter shape as eth_newFilter: `address` and/or `topics`.