Polygon
هل أنت مستعد لاستدعاء هذا في الإنتاج؟
الخطة المجانية تغطي المشاريع الشخصية. الدفع حسب الاستخدام يتوسع دون بطاقة.
Polygon
الخطة المجانية تغطي المشاريع الشخصية. الدفع حسب الاستخدام يتوسع دون بطاقة.
eth_subscribe opens a push-based subscription over a WebSocket connection to a Polygon PoS node. Instead of repeatedly polling for changes, your client registers interest in an event stream — new block headers, matching logs, pending transaction hashes, or sync status — and the node pushes eth_subscription notifications the moment events occur. On Polygon's fast ~2-second Bor block cadence this is the difference between catching every block and falling behind a busy poller. Point a WebSocket client at the Polygon mainnet endpoint behind https://polygon.therpc.io/YOUR_API_KEY (chain ID 137, 0x89) and the gas-cheap, MATIC-fee network will deliver updates with minimal latency.
newHeads to drive a real-time dashboard or block explorer that reacts to each Polygon block as it is produced, without burning request quota on polling.logs from a specific contract — for example Transfer events from the USDT contract at 0xc2132D05D31c914a87C6611C10748AEb04B58e8F or swap events from QuickSwap pools — as they are mined.newPendingTransactions to watch the Polygon mempool and react to transactions before they are confirmed, useful for trading bots and Polymarket order-flow tooling.| # | الاسم | النوع | مطلوب | الوصف |
|---|---|---|---|---|
| 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 Polygon 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 plain HTTP against the Polygon endpoint returns a "notifications not supported" error.eth_getLogs over the missed block range.logs notifications can arrive with removed: true. Handle these explicitly so your application rolls back state that referenced an orphaned block.المعاملات
"newHeads" | "logs" | "newPendingTransactions" | "syncing"
Required only for `logs` subscriptions. Same filter shape as eth_newFilter: `address` and/or `topics`.