ETH
POST
GET
Last updated on January 1, 1970
1 min read
Method eth_subscribe undefined ()
connect with WS protocol
eth_subscribe
Subscribes to a specified event type, optionally restricted to one ormany objects. This method is available via websocket only.
Parameters
type
- string
A subscription type, such as newHeads (new headers appended to the chain, including chain reorganizations), logs (logs that are included in new imported blocks and match the given filter criteria) or newPendingTransactions (hashes for all transactions that are added to the pending state and are signed with a key that is available in the node).
objects
- hex string
Optional argumants such as an address, multiple addresses, and topics.
Request
wscat -c wss://eth.getblock.io/YOUR-API-KEY/mainnet/
# wait for connection and send the request body
{"jsonrpc": "2.0",
"method": "eth_subscribe",
"params": ["newHeads", null],
"id": "getblock.io"}
Response
{
"id": 1,
"jsonrpc": "2.0",
"result": "0xe5af64ddfd365b4632988c5935cfedb7"
}
Start Building with GetBlock RPCs for Free
Previous
{ "overview": "Overview", "guides": "Guides", "get-started": "Get Started", "rpc-service": "Nodes Methods", "getblock-explorer": "Explorer API", "getblock-tracker": "Tracker API", "nodes-endpoints": "Nodes Endpoints" }
Next
{ "overview": "Overview", "guides": "Guides", "get-started": "Get Started", "rpc-service": "Nodes Methods", "getblock-explorer": "Explorer API", "getblock-tracker": "Tracker API", "nodes-endpoints": "Nodes Endpoints" }