Skip to content

Instantly share code, notes, and snippets.

@roelandp
Created April 3, 2020 15:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roelandp/41031289224acb03bab1806916ce0037 to your computer and use it in GitHub Desktop.
Save roelandp/41031289224acb03bab1806916ce0037 to your computer and use it in GitHub Desktop.
code for Account Claiming on Hive / Steem
#!/usr/bin/python
from __future__ import division
from beem import Steem
from beem.account import Account
from beem.rc import RC
import time
import config
from beem.constants import state_object_size_info, resource_execution_time, EXEC_FOLLOW_CUSTOM_OP_SCALE
from beem.nodelist import NodeList
nodelist = NodeList()
nodelist.update_nodes()
nodessteem = nodelist.get_nodes()
nodeshive = nodelist.get_nodes(hive=True)
# hive = Steem(node=nodeshive)
# steem = Steem(node=nodessteem)
if __name__ == "__main__":
stm = Steem(node=nodeshive)
creator = APP_CONFIG['walletcreator']
creator = Account(creator, steem_instance=stm)
creator.refresh()
rc = RC(steem_instance=stm)
tresholdcreate = 0.4
current_costs = stm.get_rc_cost(rc.get_resource_count(tx_size=300, execution_time_count=resource_execution_time["claim_account_operation_exec_time"], new_account_op_count=1))
current_mana = creator.get_rc_manabar()["current_mana"]
max_mana = creator.get_rc_manabar()["max_mana"]
last_mana = current_mana
print("Current costs %.2f G RC - current mana %.2f G RC - max_mana %.2f G RC" % (current_costs / 1e9, current_mana / 1e9, max_mana / 1e9))
manabarifcreate = (current_mana - current_costs) /max_mana
currentmanabar = (current_mana / max_mana)
print(manabarifcreate)
print(currentmanabar)
if manabarifcreate > tresholdcreate:
#if True:
stm.wallet.unlock(config.APP_CONFIG['walletunlock'])
stm.claim_account(creator)
time.sleep(10)
creator.refresh()
current_mana = creator.get_rc_manabar()["current_mana"]
print("Account claimed and %.2f G RC paid." % ((last_mana - current_mana) / 1e9))
last_mana = current_mana
else:
print("Not enough RC for a claim!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment