Skip to main content
Ethereum API
Multichain API

eth_subscribe

Summary: Subscribes to specific Ethereum events, returning a subscription ID used to receive notifications.

Subscribes to specific events on the Ethereum network, such as new blocks, or logs. When an event occurs, a notification is sent to the client with the corresponding data. To stop receiving notifications, the client can unsubscribe using eth_unsubscribe.

Parameters

subscriptionType enum
required

The type of subscription to create. Must be one of the following: 1. newHeads - New block headers. 2. logs - Logs matching a filter object.

Enum:
"newHeads"
"logs"

filterOptions object
required

(Optional) An object containing filter options specific to the subscription type. Only applicable for the logs subscription type.

address string

(Optional) A single address or an array of addresses to filter the logs by.

topics array

An array of topics to filter the logs by.

string

Returns

A unique subscription ID that can be used to unsubscribe or identify incoming notifications.
subscriptionId string

A unique subscription ID that can be used to unsubscribe or identify incoming notifications.

Customize request
Parameter
Value
newHeadsenum
string
[]
array
Connect your MetaMask wallet to run requests successfully.
Request
await window.ethereum.request({
"method": "eth_subscribe",
"params": [
"newHeads"
],
});
Example response
"0x1b84f2cdf29a204b79e450c1939b30c1"