Last active
March 14, 2018 17:30
-
-
Save emre/ffb0c8e895b0e4d9506f3f587664dd2b to your computer and use it in GitHub Desktop.
producer_rewards
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from steem import Steem | |
from steem.account import Account | |
from steem.amount import Amount | |
from steem.converter import Converter | |
import logging | |
logger = logging.getLogger('producer rewards') | |
logger.setLevel(logging.INFO) | |
logging.basicConfig() | |
def calculate_producer_rewards(steemd_instance, witness_account): | |
account = Account(witness_account,steemd_instance=steemd_instance) | |
total_vests = 0 | |
for producer_reward in account.history_reverse(filter_by=["producer_reward"]): | |
total_vests += Amount(producer_reward["vesting_shares"]).amount | |
converter = Converter(steemd_instance=s) | |
total_sp = converter.vests_to_sp(total_vests) | |
return total_vests, total_sp | |
if __name__ == '__main__': | |
s = Steem(nodes=["https://api.steemit.com"]) | |
witness_account = 'emrebeyler' | |
vests, sp = calculate_producer_rewards(s, witness_account) | |
print("Account: %s, Total Vests: %s, Total SP: %s" % ( | |
witness_account, round(vests, 2), round(sp, 2))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment