Creating Claimed Hive Accounts Using Beem

avatar

hive.png

In my previous post I wrote about claiming discounted Hive accounts using Beem in python. Today, I would like to share how to create new Hive accounts using claimed account tokens. I used @holger80's older guide that was written for Steem, and repurposed for creating claimed accounts on Hive.

I decided to try this, just out of curiosity to see how account creation works, but also wanted to create myself a separate account for a tribe. I have seen many people using separate accounts for curating purposes for tribes. I am not sure if I will do the same yet, but thought it is a good reason to create one as an experiment. For this example I will be creating a new account called geekleo, which potentially may become my account to hold leo power.

In the future I would like to be able to integrate account creation feature in one of my apps, so I can also contribute onboarding new users to Hive. For that I will need to gain more skills and knowledge on how to do it properly and securely.

While writing the code, I have couple questions in mind. One of them was what happens if I try to create an existing account, which I tried to do. Beem throws an exception with an error message account already exists. Alternatively, I was thinking to add HiveSQL code to check if chosen new account name already exists.

Along with providing new account name, we also need to provide a password which will serve as seed password to generate other account keys. After account was created the result of the transaction only returned public keys along with other information. It didn't return the private keys.

I am not sure if there a way to get the private keys within python code in Beem yet. If you know how to do that please let me know.

After the account was created, I tried to login on Hive.blog and it gave me the message saying I was trying to login with a non-posting key and offered to download my private keys as pdf. That was nice. I downloaded the file and it showed me all of the private keys.

Message from Hive.blog login page:

login.jpeg

I still need to figure out how to obtain private keys without relying on other front ends.

Following is the full code to create claimed account:

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__":

    new_account_name = 'geekleo'
    new_account_pass = 'XXXXXXXXXXXXXXXXXXXXXXXXX'

    #if account already exists, throws account exists exception.

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

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

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

    result = hive.create_claimed_account(new_account_name, creator=creator, password=new_account_pass)
    print(result)

    time.sleep(10)

    new_account = Account(new_account_name)
    new_account.print_info()
    

I wrote in the new account name and the seed password variables within the code. The way Holder did it was by giving an option to pass the new account name as an argument, then asking for the password and password confirmation in the terminal (command prompt). I did this just for simplicity purposes. Everything else is self-explanatory. The main method that creates the account is .create_claimed_accounts() which takes new account name, account creator name and password as parameters.

I believe this will only work with claimed accounts. There must be another method for creating accounts by paying in Hive, which I have not tried yet. Creating new accounts currently costs 3 Hive.

Posted Using LeoFinance Beta



0
0
0.000
2 comments
avatar

Very cool. I usually just use the thing that is built into PeakD, but that is creating new accounts I think. Not ones that have already been claim. Very impressive what you have done here!

Posted Using LeoFinance Beta

0
0
0.000