forked from itzmeanjan/harmony
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsubscribe_3.py
More file actions
34 lines (27 loc) · 846 Bytes
/
subscribe_3.py
File metadata and controls
34 lines (27 loc) · 846 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/python3
from python_graphql_client import GraphqlClient
from json import dumps
import asyncio
def prettyPrint(data):
print(dumps(data, sort_keys=True, indent=2))
try:
client = GraphqlClient(endpoint="ws://localhost:7000/v1/graphql")
query = """
subscription {
newPendingTxFrom(address: "0x63ec5767F54F6943750A70eB6117EA2D9Ca77313") {
from
to
nonce
gasPrice
queuedFor
pendingFor
pool
}
}
"""
print('Listening for any new tx, entering pending pool, from `0x63ec5767F54F6943750A70eB6117EA2D9Ca77313`')
asyncio.run(client.subscribe(query=query, handle=prettyPrint))
except Exception as e:
print(e)
except KeyboardInterrupt:
print('\nStopping')