Beem: claiming and creating account, HP delegation

in Česky!4 years ago
Do you need Hive account for your friend? You can claim free discount account from your RC / crate account and you can do it with some automation ;)
ENGLISH:

There are several ways to create a new account on Hive. But real account creation will cost something anyway. You can pay a 3 hive registration fee for it, which will be burned, or contact a user who has a large enough Resource credit. There is a possibility to claim a free account only by consuming part of the RC. The costs of claiming is 5670.80 G RC at the moment. To see transactions costs, look at beempy.com.

When you claim an account, you are not creating it yet. You will only receive a voucher for future account creation. Only when you actually create an account, you will need to know the future name of the account. So I claim free accounts for future needs, mainly in #cesky community.

There are 3 Python scripts using the beem library from @holger80. The script for claiming and creating an account is also based on the work @holger80 and the original version for Steem can be found here.

I made some small modification of the original scripts for use on Hive.

Because the account created in this way has zero HP, it is necessary to make a small delegation in case the new user interaction with the blockchain. The third script is used for that.

I made some test and claimed/created account @chleba. Everything run well, so I could create account @kreur.voter today. I also send 10 HP as delegation using beem.

ČESKY:

Způsobů jak vytvořit nový účet na Hive je několik. Reálný vznik účtu, ale vždy něco stojí. Můžete za něj zaplatit registrační poplatek 3 hive, které se spálí, nebo se obrátit na uživatele, který má dostatečně veliký Resource credit. Je zde totiž možnost "claimnutí" (a zde opravdu nevím jestli je rozumné to překládat jako nárokování, ale proč ne;) ) volného účtu jen a pouze spotřebováním části právě RC. V tuto chvíli je potřeba cca 6 miliard RC. Pokud se chcete podívat, jaká transakce spotřebuje jaké množství RC, podívejte se na beempy.com.

Při claimnutí účtu ho ještě nezakládáte, pouze obdržíte jakousi poukázku na budoucí vytvoření účtu. Až při opravdovám vytvoření účtu je potřeba znát budoucí název účtu. Volné účty tedy claimuji do zásoby pro budoucí potřeby hlavně #cesky komunity.

Následují 3 Python scripty s použitím knihovny beem od @holger80. Script pro claimnutí a vytvoření účtu vychází také z díla @holger80 a původní verzi pro Steem najdete zde.

Původní scripty jsem upravil pro použití na Hive a nějakou omáčku ;)

Protože takto vytvořený účet je na nule, je potřeba mu dopřát nějakou malou delegaci, aby nováček zvládl základní interakci s blockchainem. K tomu slouží třetí script.

Včera jsem trošku testoval a ladil a podařil se claim účtu a vytvoření účtu @chleba. Dnes jsem už jen víceméně na jisto vytvořil účet @kreur.voter a pomocí beem mu delegoval 10 HP.

Následující text pouze anglicky. Myslím, že tomu porozumí i neangličtináři ;) Kdyby přeci byl problém, tak se ptejte v komentáři.

For next three transactions was used Python version 3.7.1 and beem version 0.23.3.

Claim a discount account from RC

The first one will ask for your private active key, from which will determine your account name. Then will check the RC and actual claim account costs. If you have enough RC, the account is claimed.

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

if __name__ == "__main__":
    wif = getpass.getpass(prompt='Enter your active key:')

    hive = Hive("https://api.pharesim.me", keys=[wif])

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

    rc = RC(steem_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!")

If you don't have enough RC, you will see this error message. I didn't make a printscreen when the discount account was claimed.

py_claim.png

Create a discount account

The second script will ask for name of new created account and print it for check it. Then will ask for your private active key and determine your account, it't the same like above. The 3rd step is write down password for new created account twice. From that password are keys generated.

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

if __name__ == "__main__":

    parser = argparse.ArgumentParser(description='Creating a claimed account.')

    new_account_name = input("Enter new account name: ")
    print(f"The Hive account {new_account_name} will be created.")

    wif = getpass.getpass(prompt='Enter the active key of the account creator:')
    password = getpass.getpass(prompt='Enter the new password for the new account:')
    password2 = getpass.getpass(prompt='Re-Enter the new password for the new account:')
    if password != password2:
        raise ValueError("Password do not match!")

    hive = Hive("https://api.pharesim.me", keys=[wif])

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

    print(hive.create_claimed_account(new_account_name, creator=creator, password=password))
    time.sleep(10)

    print("Account info:")

    new_account = Account(new_account_name)
    new_account.print_info()

Script waits 10s after creation and writes info about new account.

py_create.png

And the result is:

hive_created.png

Delegation small amount of HP

To delegate some HP needed for basic interactions with blockchain I used the third script. It will ask for delegates name, your private active key. When the delegator account is determined, script asks for HP amount to be delegated, converts HP to vests a cast transaction.

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

if __name__ == "__main__":


    delegatee = input("Enter account to delegate: ")
    print(f"The Hive account {delegatee} will be delegated.")

    wif = getpass.getpass(prompt='Enter the active key of the delegator account:')

    hive = Hive("https://api.pharesim.me", keys=[wif])

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

    amount = int(input("Write HP amount to be dlegated: "))
    vests_to_delegate = hive.hp_to_vests(amount)

    delegator.delegate_vesting_shares(delegatee, vests_to_delegate, delegator)
    print(f"{vests_to_delegate} delegated to delegatee")

    print(f"{delegatee} Hive on! / Směle bzuč!")

py_delegate.png

And the result of delegation:

hive_delegate.png

Be sure you store the account password, it cannot be restored!

If you have free votes, you can vote for me as Hive witness. If you want, of course ;)

Thank you for stopping by.
Thank you for your votes.

Sort:  

Super článek, díky za návod. Taky už mám nasyslené tokeny, uvidíme, kdy je budu moci využít.

Taky syslím... V peakd.com teď je možnost claimnout více účtů najednou.

A scripty příště zkusím sloučit, tzn. jeden script, kam zadáš svůj klíč, jméno nového účtu a kolik mu delegovat a enter ;)

Díky za vytvoření alt účtu! Do budoucna se určitě bude hodit a už mám pár plánů jak ho zrobotizovat :) Mile mě překvapilo, že když jsem četl postup tak to vůbec nevypadá tak složitě.

Změna hesla (master password) automaticky zruší všechna povolení, takže pokud budete chtít měnit heslo u hlavního účtu doporučuju si prvně sepsat čemu všemu budete muset udělit znovu oprávnění postovat. Co se týče auto hlasování, tak tam to vypadá, že je nějaký limit na HP, při 20 mi to ještě nefungovalo, ale při 35 už to běží.

Dokud s novým účtem nebudu mít jiný plán, tak bude tím drobkem HP kopírovat hlasy Taziho, mě a českého kurátora. Ještě jednou díky za vytvoření účtu.

Není zač. Jsem rád, že jsem to mohl takto otestovat na reálném účtu a budu mít připraveno až bude zase potřeba.

Thanks for sharing this knowledge on the many ways to create accounts and adapting the script to use it at home ;)

Yes, scripts are ready to use. I would like to create some tutorial for running Python with beer for beginners. Beempy CLI is very useful too for people who are familiar with command line ;)