Skip to main content
Creates a real-time event subscription over a WebSocket connection. Returns a subscription ID; events are pushed as eth_subscription notifications without the client needing to poll.
Flashblocks: On wss://mainnet-preconf.base.org, newHeads emits every ~200ms (once per Flashblock) instead of every ~2 seconds. Three additional subscription types are also available: newFlashblockTransactions, pendingLogs, and newFlashblocks.

Parameters

subscriptionType
string
required
The event type to subscribe to.
filterOptions
object
Optional filter options. Only applicable for the "logs" subscription type.

Subscription Types

TypeDescriptionNotification payload
newHeadsFires for each new block appended to the chainBlock header object (~200ms on Flashblocks endpoints)
logsFires for each new log matching filter criteriaLog object
newPendingTransactionsFires for each new transaction hash added to the mempoolTransaction hash string

Returns

result
string
A hex-encoded subscription ID. All event notifications from this subscription include this ID in params.subscription.
Event notifications arrive as unsolicited JSON-RPC messages:
{
  "jsonrpc": "2.0",
  "method": "eth_subscription",
  "params": {
    "subscription": "0x1887ec8b9589ccad00000000000532da",
    "result": { ... }
  }
}

Example

{"jsonrpc": "2.0", "method": "eth_subscribe", "params": ["newHeads"], "id": 1}