ethOnBlock
Name: ethOnBlock
ethOnBlock is a stream of 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 is a Gateway-API only 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
from, to, gas, value, data
eth_getBalance
address
eth_getTransactionCount
address
eth_getCode
address
eth_getStorageAt
address, pos
eth_blockNumber
None
Examples
Gateway
Cloud-API
ethOnBlock Event
Subscribing to the ethOnBlock stream via the Gateway-API in Python (Line 6 creates the subscription):
1
import asyncio
2
from bloxroute_cli.provider.ws_provider import WsProvider
3
ws_uri = "ws://127.0.0.1:28333"
4
async def main():
5
async with WsProvider(ws_uri) as ws:
6
subscription_id = await ws.subscribe(
7
"ethOnBlock",
8
{"call-params": [{"name": "my_call_name",
9
"method": "eth_call",
10
"from": "0x0000000000000000000000000000000000000000",
11
"to": "0xd46e8dd67c5d32be8058bb8eb970870f07244567",
12
"gas": "0x76c0",
13
"value": "0x9184e72a",
14
"data": "0x00"},
15
{"name": "number",
16
"method": "eth_blockNumber"}]})
17
while True:
18
next_notification = await ws.get_next_subscription_notification_by_id(subscription_id)
19
print(next_notification) # or process it generally
20
await ws.unsubscribe(subscription_id)
21
if __name__ == '__main__':
22
asyncio.get_event_loop().run_until_complete(main())
23
​
Copied!
The ethOnBlock stream is not available via Cloud-API.
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.
1
<<< {'name': 'balance', 'response': {'result': '0x1'}, 'blockHeight': 11654331, 'tag': 11654331}
2
{'name': 'height', 'response': {'result': '0xb1d4bb'}, 'blockHeight': 11654331, 'tag': 11654331}
3
{'name': 'TaskDisabledEvent', 'response': {'commandMethod': 'eth_getBalance', 'blockOffset': 0, 'callName': 'balance', 'callPayload': {'address': '0x0000000000000000000000000000000000000000'}, 'active': False}, 'blockHeight': 11654331, 'tag': 11654331}
4
{'name': 'number', 'response': {'result': '0x0'}, 'blockHeight': 11654331, 'tag': 11654331}
5
{'name': 'TaskCompletedEvent', 'response': {}, 'blockHeight': 11654331, 'tag': 11654331}}
Copied!
Last modified 1mo ago
Copy link