eth_subscribe

Returns an object with data about the sync status or false.

This method will use 10 Compute Units.


Reference: Here

Parameters

subscription name - string - The type of event you want to subscribe to (i.e., newHeads or logs). This method supports the following subscription types:

  • newHeads - Fires a notification each time a new header is appended to the chain, including chain reorganizations.

  • logs - Returns logs that are included in new imported blocks and match the given filter criteria.

data - object - (Optional) - 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.

params: [
  "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675",
]

Returns

result - string - 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.

// Result
{"jsonrpc":"2.0","result":"0x3c2cda2e6eaa7a12","id":1}

//Example
{
	"jsonrpc": "2.0",
	"method": "eth_subscription",
	"params": {
		"result": {
			"author": "0x1247a0ff7a51b3613aacf292c43f8a530f2dbfdf",
			"difficulty": "0x1cee967717d",
			"extraData": "0x",
			"gasLimit": "0x3938700",
			"gasUsed": "0x0",
			"hash": "0xa4914171723201f12fd955a0190ab89d9b9eeb99439692d9d373fe36d2307565",
			"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
			"miner": "0x1247a0ff7a51b3613aacf292c43f8a530f2dbfdf",
			"number": "0x6a94587",
			"parentHash": "0xcbf352698bdb1ccf118ad479f173017aefe93862d64a2cc3ffa38148ee592c9c",
			"receiptsRoot": "0x12af19d53c378426ebe08ad33e48caf3efdaaade0994770c161c0637e65a6566",
			"sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
			"size": "0x0",
			"stateRoot": "0x380eb13f6961ce88fa133b5b57f8a6745a7be45987257e33737ec4f135b63e84",
			"timestamp": "0x6760ae12",
			"transactionsRoot": "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"
		},
		"subscription": "0x3c2cda2e6eaa7a12"
	}
}
...
wscat -c wss:///mainnet.conflux.validationcloud.io/v1/wss/<YOUR_API_KEY_HERE>
# wait for connection
{"jsonrpc":  "2.0",  "id":  1,  "method":"eth_subscribe","params":["newHeads"]}
# resulting subscription ID
{"jsonrpc":"2.0","result":"0x3c2cda2e6eaa7a12","id":1}

Last updated