chainlib/cic_tools/eth/runnable/subscribe.py
2021-02-08 11:25:54 +01:00

22 lines
303 B
Python

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()