delegators list

in #steem4 years ago

Today I was quite happy to finally update and start to reuse my github.

So after the code I published this morning, this afternoon I have found the time to write few lines to help me create my delegators list.

Actually is something I had ready already but I had to update in order to work properly and to clean a bit the mess that was my original code.

The script in python that uses been library to interact both with steem and hive blockchains.

It returns the historical of an account delegations, the current active delegations and the list of the accounts that undelegated.

from beem.account import Account
from beem.instance import set_shared_steem_instance
from beem import Steem
import re

stm = Steem("https://anyx.io")#use https://api.steemit.com for steem
set_shared_steem_instance(stm)
acc = Account("[the account you want to check]",steem_instance=stm)

c_list = []
names=[]
for c in acc.history_reverse(only_ops=["delegate_vesting_shares"]):
    data=re.findall("'delegator': '(.+?)'",str(c)),re.findall("'delegatee': '(.+?)'",str(c)),re.findall("'amount': '(.+?)'",str(c))
    name=re.findall("'delegator': '(.+?)'",str(c))
    if name not in names:
        print(re.findall("'delegator': '(.+?)'",str(c)),re.findall("'delegatee': '(.+?)'",str(c)),re.findall("'amount': '(.+?)'",str(c)))
        c_list.append(data)
        names.append(name)
active=[]
removed=[]
for i in c_list:
    if str(i[2])=="['0']":
        data=i[0][0],i[2][0]
        removed.append(data)
    else:
        hive=stm.vests_to_sp(i[2][0])#.split(' ')[0]))
        data=i[0][0], hive #i[2][0]
        #print ('DATA 2', data)
        active.append(data)
for i in active:
    print (i[0],':',round(i[1]/1000000,3),'HIVE')
print ('ACTIVE:',len(active))
print ('LOST:',len(removed))
a=input ('Do you want to print the undelgator list?')
if a=='y':
    for i in removed:
        print (i[0][0],':',i[1],'HIVE')
else:
    exit

this is the repo on github:
https://github.com/digital-mine/delegators-list

Sort:  

Hello the.journal!

Congratulations! This post has been randomly Resteemed! For a chance to get more of your content resteemed join the Steem Engine Team

Coin Marketplace

STEEM 0.29
TRX 0.12
JST 0.032
BTC 63491.36
ETH 3082.44
USDT 1.00
SBD 3.86