eth_subscribe - Worldchain

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 subscription on the World Chain network for particular events using WebSocket connection.

circle-info

This method can only be access via a Websocket

Parameters

Parameter
Type
Description

subscriptionType

string

Type of subscription: "newHeads", "logs", "newPendingTransactions"

filterObject

object

(Optional) Filter options for logs subscription

Request

curl --location --request POST 'https://go.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "eth_subscribe",
    "params": ["newHeads"],
    "id": "getblock.io"
}'

Response

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

Response Parameters

Field
Type
Description

result

string

Subscription ID for managing the subscription

Use Case

The eth_subscribe method on World Chain is typically used for:

  • Real-time updates

  • Block notifications

  • Log streaming

  • Pending transaction monitoring

Error Handling

Status Code
Error Message
Cause

403

Forbidden

Missing or invalid ACCESS-TOKEN

Web3 Integration

Last updated

Was this helpful?