Skip to main content

eth_subscribe RPC Method

Starts a subscription to a specific event.

Updated on
Oct 4, 2023

eth_subscribe RPC Method

Parameters

subscription name
string
The type of event you want to subscribe to (i.e., newHeads, logs). This method supports the following subscription types:
newHeads
It fires a notification each time a new header is appended to the chain, including chain reorganizations
logs
It returns logs that are included in new imported blocks and match the given filter criteria
data
object
The arguments such as an address, multiple addresses, and topics. Note, only logs that are created from these addresses or match the specified topics will return logs

Returns

result
object
The hex encoded subscription ID. This ID will be attached to all received events and can also be used to cancel the subscription using eth_unsubscribe
parentHash
The hash of the parent block
sha3Uncles
The SHA3 of the uncles data in the block
miner
The address of the beneficiary to whom the mining rewards were given
stateRoot
The root of the final state trie of the block
transactionsRoot
The root of the transaction trie of the block
receiptsRoot
The root of the receipts trie of the block
logsBloom
The bloom filter for the logs of the block. null if pending
difficulty
The integer of the difficulty for this block encoded as a hexadecimal
number
The block number of the requested block encoded as hexadecimal. null if pending
gasLimit
The maximum gas allowed in this block encoded as a hexadecimal
gasUsed
The total used gas by all transactions in this block encoded as a hexadecimal
timestamp
The UNIX timestamp for when the block was collated
extraData
The “extra data” field of this block
mixHash
A string of a 256-bit hash encoded as a hexadecimal
nonce
The hash of the generated proof-of-work. null if pending
baseFeePerGas
A string of the base fee encoded in hexadecimal format. Please note that this response field will not be included in a block requested before the EIP-1559 upgrade
withdrawalsRoot
The withdrawal root and null if pending
hash
The block hash of the requested block. null if pending
Request
1
wscat -c \
2
# wait for connection
3
{"id":1,"jsonrpc":"2.0","method":"eth_subscribe","params":["newHeads"]}
Don't have an account yet?
Create your QuickNode endpoint in seconds and start building
Get started for free