eth_subscribe - Base
eth_subscribe. Subscribe to real-time updates for events like new blocks or logs
eth_subscribe - base [Value: 10CU]
Creates a subscription to receive real-time updates for various events on the blockchain
Use cases
- Subscribe to new block headers for monitoring
- Track blockchain head changes in real-time
- Receive updates when new blocks are mined
Constraints
- newPendingTransaction subscription is not supported
- Requires continuous WebSocket connection to the node
- Node must support eth_subscribe method
Unlock Access to 50+ chains
Boost your app's speed and reliability with dRPC - get your access API key
Language
Request
Examples
wscat -c wss://base.drpc.org
{"jsonrpc":"2.0","id": 2, "method": "eth_subscribe", "params": ["newHeads"]}'
Response
200
{
"jsonrpc": "2.0",
"id": 1,
"result": "0x1234567890abcdef1234567890abcdef"
}
Request params
idinteger
jsonrpcstring
methodstring
array of strings
subscription_namestring
Specifies the event type for subscription. Supported types include:
array of strings
newHeadsstring
Triggers a notification for each new block header added, including chain reorganizations.
logsstring
Returns logs matching filter criteria in newly imported blocks.
dataobject
Is specifically used for logs subscriptions. Arguments like address, multiple addresses, and topics.
Response
200
The subscription ID, represented as a hexadecimal string. Response params
object
idinteger
jsonrpcstring
resultstring