ethOnBlock

Name: ethOnBlock

A stream of the changes in the EVM state when a new block is mined. The stream includes the results of eth_call and other RPC requests provided by users and is restricted based on the number of calls. This Stream is only available via gateway API. Cloud-API does not support ethOnBlock stream.

Options

Key

Description

Values

include

Fields to include in the on block event stream

name, response, blockHeight, tag [Default: all]

call-params

Fields used to build an RPC call request

method - see chart below for available methods and additional fields required for each method

tag - latest, 0, or negative number. Default: 0

name - unique string identifier for call. Default: integer counter

Method

Call Documentation

Additional Fields

eth_call

https://eth.wiki/json-rpc/API#eth_call​

from, to, gas, value, data

eth_getBalance

​https://eth.wiki/json-rpc/API#eth_getbalance​

address

eth_getTransactionCount

​https://eth.wiki/json-rpc/API#eth_gettransactioncount​

address

eth_getCode

​https://eth.wiki/json-rpc/API#eth_getcode​

address

eth_getStorageAt

​https://eth.wiki/json-rpc/API#eth_getstorageat​

address, pos

eth_blockNumber

​https://eth.wiki/json-rpc/API#eth_blocknumber​

None

Examples

Gateway
Cloud-API
ethOnBlock Event
Gateway

Subscribing to the Gateway Feed in Python (line 6 creates the subscription):

import asyncio
from bloxroute_cli.provider.ws_provider import WsProvider
ws_uri = "ws://127.0.0.1:28333"
async def main():
async with WsProvider(ws_uri) as ws:
subscription_id = await ws.subscribe(
"ethOnBlock",
{"call-params": [{"name": "my_call_name",
"method": "eth_call",
"from": "0x0000000000000000000000000000000000000000",
"to": "0xd46e8dd67c5d32be8058bb8eb970870f07244567",
"gas": "0x76c0",
"value": "0x9184e72a",
"data": "0x00"},
{"name": "number",
"method": "eth_blockNumber"}]})
while True:
next_notification = await ws.get_next_subscription_notification_by_id(subscription_id)
print(next_notification) # or process it generally
await ws.unsubscribe(subscription_id)
if __name__ == '__main__':
asyncio.get_event_loop().run_until_complete(main())
​
Cloud-API

The OnBlock Event Stream is not available via Cloud-API.

ethOnBlock Event

TaskCompletedEventis received after all calls have been executed upon receipt of a block.TaskDisabledEvent is received if there is an error response to a call, indicating that the call has been disabled.

<<< {'name': 'balance', 'response': {'result': '0x1'}, 'blockHeight': 11654331, 'tag': 11654331}
{'name': 'height', 'response': {'result': '0xb1d4bb'}, 'blockHeight': 11654331, 'tag': 11654331}
{'name': 'TaskDisabledEvent', 'response': {'commandMethod': 'eth_getBalance', 'blockOffset': 0, 'callName': 'balance', 'callPayload': {'address': '0x0000000000000000000000000000000000000000'}, 'active': False}, 'blockHeight': 11654331, 'tag': 11654331}
{'name': 'number', 'response': {'result': '0x0'}, 'blockHeight': 11654331, 'tag': 11654331}
{'name': 'TaskCompletedEvent', 'response': {}, 'blockHeight': 11654331, 'tag': 11654331}}