forked from sigwo/pywavestools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathasset_richlist.py
39 lines (33 loc) · 1.27 KB
/
asset_richlist.py
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
35
36
37
38
39
import requests
import argparse
parser = argparse.ArgumentParser(description='Waves Asset Rich List')
parser.add_argument('asset', type=str, help='asset id')
args = parser.parse_args()
assetId = args.asset
node = '127.0.0.1'
try:
issuetx = requests.get('http://' + node + ':6869/transactions/info/%s' % assetId).json()
except:
print("Asset not found!")
if issuetx['id'] == assetId:
assetName = str(issuetx['name'])
assetDec = issuetx['decimals']
states = requests.get('http://' + node + ':6869/debug/state').json()
print("-" * 64)
print(str.center(("%s Rich List") % assetName, 64))
print
print(" # Address Balance")
print("-" * 64)
n = 0
total_balance = 0
for i in sorted(states.items(), key=lambda x: -x[1]):
balance = i[1]
if i[0][-len(assetId):] == assetId and balance > 0:
address = i[0][:35]
total_balance += balance
n += 1
balance = ("%%18.%df" % assetDec) % (balance / 10.**assetDec)
print("%6d %-38s %18s " % (n, address, balance))
print("-" * 64)
total_balance = ("%%18.%df" % assetDec) % (total_balance / 10.**assetDec)
print(" %20s" % (total_balance))