chainlib

Generic blockchain access library and tooling
Log | Files | Refs | README | LICENSE

commit 5fa3b91c050ce900ee4945e84d114251ae1041f0
parent d85d96b32549ecf24f9a8f8034f8127cb7643644
Author: nolash <dev@holbrook.no>
Date:   Mon,  8 Feb 2021 11:25:54 +0100

Add subscribe stub (with hardcoded url)

Diffstat:
Acic_tools/eth/runnable/subscribe.py | 21+++++++++++++++++++++
Mrequirements.txt | 1+
2 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/cic_tools/eth/runnable/subscribe.py b/cic_tools/eth/runnable/subscribe.py @@ -0,0 +1,21 @@ +import json + +import websocket + +ws = websocket.create_connection('ws://localhost:8545') + +o = { + "jsonrpc": "2.0", + "method": "eth_subscribe", + "params": [ + "newHeads", + ], + "id": 0, + } + +ws.send(json.dumps(o).encode('utf-8')) + +while True: + print(ws.recv()) + +ws.close() diff --git a/requirements.txt b/requirements.txt @@ -12,3 +12,4 @@ pysha3==1.0.2 hexathon==0.0.1a2 eth-abi==2.1.1 eth-keys==0.3.3 +websocket-client==0.57.0