RPC method

eth_subscribe on Optimism

Supported on SwiftNodes

Everything below was measured on 2026-10-13 by calling eth_subscribe on Optimism through the same endpoint customers use, and is re-measured weekly.

What eth_subscribe does

Opens a subscription over WebSocket: newHeads pushes each new block header, logs pushes matching events, and newPendingTransactions pushes mempool transaction hashes where the node exposes them. It replaces polling, and it only works over WebSocket, not HTTP.

eth_subscribe on Optimism: what we measured

newHeadssupported
First header after subscribing1.4 s
Median gap between headers2.0 s
Headers in 15 seconds7
logssupported
newPendingTransactionssupported

What this means on Optimism

Headers pushed over WebSocket are not identical to eth_getBlockByNumber over HTTP on Optimism. Only the HTTP block has withdrawals. Fetch the block over HTTP if you need those fields.

Subscriptions end when the connection drops. Reconnect with backoff and, after reconnecting, fetch the blocks you missed with eth_getBlockByNumber.

Example request

wscat -c "wss://rpc.swiftnodes.io/ws/optimism?key=YOUR_API_KEY"
> {"jsonrpc":"2.0","id":1,"method":"eth_subscribe","params":["newHeads"]}
import { createPublicClient, webSocket } from "viem";

const client = createPublicClient({
  transport: webSocket("wss://rpc.swiftnodes.io/ws/optimism?key=YOUR_API_KEY", { reconnect: true }),
});

const unwatch = client.watchBlocks({
  onBlock: (block) => console.log(block.number, block.hash),
});

// Events from one contract, pushed as they are mined
client.watchContractEvent({ address: token, abi: erc20Abi, eventName: "Transfer", onLogs: (logs) => console.log(logs) });

Other methods on Optimism

eth_subscribe on other chains

Frequently asked questions

Does Optimism support eth_subscribe?

Yes. eth_subscribe answered on the SwiftNodes Optimism endpoint when our weekly probe called it through the customer path (2026-10-13).

Does Optimism support WebSocket subscriptions?

Yes. newHeads and logs worked through wss://rpc.swiftnodes.io/ws/optimism on 2026-10-13.

Can I watch the Optimism mempool?

newPendingTransactions is supported.

Optimism endpoints, live block height and WebSocket status are on the Optimism RPC page.

One key covers every chain we serve, and SwiftNodes has a free tier.