Claiming Discounted Hive Accounts Using Beem

in LeoFinance8 months ago


Beem is a great python library to interact with Hive Blockchain. It is created and maintained by @holger80.

Hive has discounted accounts. Anybody who has enough resource credits can claim these discounted account tokens at the cost of their available RC. At a later time new accounts can be created using these claims for free. From time to time I claim some accounts with intention to use them in the future or help other onboarding efforts.

Normally I would use peakd to claim accounts. In the wallet section, under delegate they have an option to claim accounts. They used to provide two options: single account claim, and multiple accounts claim. For some reason the multiple accounts claim option is not there anymore. Maybe it has moved somewhere else on the website. Instead of figuring out what happened to that option, I decided to see if I could achieve the same results using Beem.

As I was going looking for the ways how to write this script, I came across Holger's post from three years ago on the same topic. Holder gives a detailed explanation with the codes on how to claim discounted account and also how to create accounts using Beem in python. Here is the post:

Since the post is from three years ago, it is written for Steem blockchain. The code was so easy to follow, and I was able to repurpose it for Hive blockchain without any difficulty.

I had to make changes so that it works with Hive. The original code was written to claim one account at a time. But it was written so well, it was very easy to change it to claim multiple accounts. I left the option for claiming one account in the code as commented out lines.

Here is my final code:

from beem import Hive
from beem.nodelist import NodeList
from beem.account import Account
from beem.rc import RC
import pprint
import getpass
import time

if __name__ == "__main__":

    nodelist = NodeList()
    nodes = nodelist.get_hive_nodes()

    wif = getpass.getpass(prompt='Enter your Hive active key:')
    hive = Hive(node=nodes, keys=[wif])

    creator = hive.wallet.getAccountFromPrivateKey(wif)
    creator = Account(creator)

    rc = RC(blockchain_instance=hive)
    current_costs = hive.get_rc_cost(rc.get_resource_count(tx_size=250, new_account_op_count=1, execution_time_count=1))
    current_mana = creator.get_rc_manabar()["current_mana"]
    last_mana = current_mana
    print("Current costs %.2f G RC - current mana %.2f G RC" % (current_costs / 1e9, current_mana / 1e9))

    # if current_costs + 10 < current_mana:
    #     hive.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!")
    while current_costs + 10 < last_mana:
        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
    print("Not enough RC for a claim!")

I didn't get a chance to play with creating accounts part of Holger's guide. I will try to do that soon and if successful will share here in the future.

If you have questions or suggestions let me know in the comments. Thank You.

Posted Using LeoFinance Beta


The claim multiple is still there in the peakd wallet I just claimed 4 tokens now I have 169 not sure what I’m going to do with them but I collect it none the less

Wonder if there will ever be an internal market for it one day

For some reason multiple claim option doesn’t show up for me.

I agree.
I keep claiming but not sure what to do with them :)

Posted Using LeoFinance Beta

Wow this is very great work @geekgirl. What’s the advantage of claiming discounted accounts

By doing this we can create accounts for free. Otherwise it would cost 3 Hive to create an account.

I haven't really been keeping up with it but I don't even think I have enough HP to collect these tokens. Just for reference, how much HP or RCs are required to collect a token right now? I might go claim some in the future when I do have enough HP.

Posted Using LeoFinance Beta

When my rc is at 100% I can usually claim 8-11 accounts. I have 45k hp. So probably about 5k hp will be needed to claim one account.

Thanks for the information. I'll note it down but it will probably be quite a while till I get enough HP.

Posted Using LeoFinance Beta

This is so confusing for someone who knows nothing about code xD
You could also just use peakd xD

lol... we are on the same table.

But python is fun. :)

Python is so fun no doubt! I just dont understand it :p

I noticed I didn't have the option for claiming multiple accounts. Sometimes it's there, sometimes not. Does it depend on available HP?

I don’t know the reason why it doesn’t show up on peakd. I don’t think it has to do hp. That’s why I wanted to try with python.

I thought you needed to stake HP to be able to get resource credits. You then claim an account via RC. But I'm just claiming when I remember to, would be nice if there was an automatic way of doing it 😁

donde copio y pego ese codigo? jejeje

Posted Using LeoFinance Beta

Congratulations @geekgirl! You have completed the following achievement on the Hive blockchain and have been rewarded with new badge(s) :

You got more than 7000 replies.
Your next target is to reach 7250 replies.

You can view your badges on your board and compare yourself to others in the Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP

Check out the last post from @hivebuzz:

Feedback from the April 1st Hive Power Up Day