-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconnect.py
More file actions
32 lines (21 loc) · 882 Bytes
/
connect.py
File metadata and controls
32 lines (21 loc) · 882 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
#!/usr/bin/env python3
"""Connect to Quantova and read chain state (qweb3.py).
The simplest possible use of the Quantova tools: point the client at an endpoint
and read the chain. No keys, no signing.
Run:
export QUANTOVA_RPC=http://127.0.0.1:9933 # or https://testnet.quantova.io
python connect.py
"""
from _common import banner, connect, num, to_qtov
ADDRESS = "Qf2t7p9C5Im4waDJUgrrMqVt3Hs8=" # any Q-address to inspect
def main():
banner("Quantova: connect and read")
q = connect()
block = num(q.rpc.block_number())
print(f"Connected. Current block: {block}")
rv = q.rpc.call("state_getRuntimeVersion", [])
print(f"Runtime: {rv['specName']} v{rv['specVersion']} (tx v{rv['transactionVersion']})")
bal = num(q.rpc.get_balance(ADDRESS))
print(f"Balance of {ADDRESS}: {to_qtov(bal)} QTOV")
if __name__ == "__main__":
main()