Base
هل أنت مستعد لاستدعاء هذا في الإنتاج؟
الخطة المجانية تغطي المشاريع الشخصية. الدفع حسب الاستخدام يتوسع دون بطاقة.
Base
الخطة المجانية تغطي المشاريع الشخصية. الدفع حسب الاستخدام يتوسع دون بطاقة.
eth_subscribe opens a push-based subscription over a WebSocket connection to a Base node, so the node streams notifications the moment events occur instead of forcing you to poll on a timer. Base is Coinbase's OP Stack optimistic rollup that settles to Ethereum L1 and pays gas in ETH, and its sequencer produces a fresh block roughly every two seconds — fast enough that polling wastes calls and still misses updates between requests. With one open socket you can subscribe to newHeads, contract logs, newPendingTransactions, or syncing and let those ~2-second blocks arrive as eth_subscription events. Connect to https://base.therpc.io/YOUR_API_KEY (chain ID 8453, hex 0x2105) over its WebSocket transport to start a stream.
newHeads to drive real-time Base dashboards — each ~2-second block header arrives over the socket, so block-height counters and gas widgets update without polling.logs from a Base contract as they are mined, for example Aerodrome or Uniswap swap events, by passing an address/topics filter and reacting to each emission instantly.newPendingTransactions to watch hashes enter the Base sequencer's mempool, useful for tracking a user's submitted ETH transfer before it lands on chain.| # | الاسم | النوع | مطلوب | الوصف |
|---|---|---|---|---|
| 1 | subscriptionType | string | نعم | Subscription type: `newHeads` — new block headers; `logs` — matching event logs; `newPendingTransactions` — pending tx hashes; `syncing` — node sync status changes. |
| 2 | filter | object | لا | Required only for `logs` subscriptions. Same filter shape as eth_newFilter: `address` and/or `topics`. |
| النوع | الوصف |
|---|---|
| string | Hex subscription ID. Subsequent notifications arrive as `eth_subscription` messages with `params.subscription` matching this ID. |
Try it live in the Base playground.
| الكود | الرسالة | السبب |
|---|---|---|
-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 the plain HTTP endpoint returns a "notifications not supported" error — point your client at the Base WebSocket transport, not the request/response HTTP URL.eth_getLogs over the missed Base block range so no swaps or transfers are dropped.logs notifications can include entries with removed: true. Handle these explicitly and roll back the affected state rather than treating every event as final.المعاملات
"newHeads" | "logs" | "newPendingTransactions" | "syncing"
Required only for `logs` subscriptions. Same filter shape as eth_newFilter: `address` and/or `topics`.