eth_subscribe - Tempo

Example code for the eth_subscribe JSON-RPC method. Complete guide on how to use eth_subscribe JSON-RPC in GetBlock Web3 documentation.

Creates a real-time subscription over a WebSocket connection. Available subscription types are newHeads (new block headers), logs (matching contract events), and newPendingTransactions (mempool). Only available over WebSocket transport — use wss://go.getblock.io/<ACCESS-TOKEN>/.

WebSocket-only method. Available only over the WebSocket transport at wss://go.getblock.io/<ACCESS-TOKEN>/. Calling it over HTTP POST returns an Invalid Request error.

Parameters

Parameter
Type
Required
Description

subscriptionType

string

Yes

One of "newHeads", "logs", "newPendingTransactions"

filterObject

object

No

For "logs": filter with address and/or topics

Request Example

# WebSocket-only method. Use wscat (or similar) to connect first:
wscat -c 'wss://go.getblock.io/<ACCESS-TOKEN>/'

# Then send:
{"jsonrpc": "2.0", "method": "eth_subscribe", "params": ["newHeads"], "id": "getblock.io"}

Response Example

{
    "jsonrpc": "2.0",
    "id": "getblock.io",
    "result": "0x9cef478923ff08bf67fde6c64013158d"
}

Response Parameters

Field
Type
Description

result

string

Subscription ID, used to match incoming eth_subscription notifications and to call eth_unsubscribe

Use Cases

  • Real-time payment notifications for merchant integrations

  • Live TIP-20 transfer feeds for wallets

  • Streaming indexers that react to new Tempo blocks instantly

Error Handling

Status Code
Error Message
Cause

403

Forbidden

Missing or invalid <ACCESS-TOKEN>

-32602

Invalid params

Request parameters are missing or malformed

429

Too Many Requests

Rate limit exceeded for your plan

-32600

Invalid Request

eth_subscribe was called over HTTP; use a WebSocket connection instead

SDK Integration

Last updated

Was this helpful?