Hive accounts are not free. Currently, it costs 3 Hive to create a Hive account. The account registration fee is set by witnesses, and this can change based on what witnesses set this parameter to. As Hive prices fluctuate, the cost for creating Hive accounts in USD change too. When Hive prices are high, the USD value of account creating goes up too. In such situations witnesses can act to change to registration fee and still keep Hive account creation fees affordable.
Hive also has discounted account creation tokens. Anybody who has decent amount of RC, can claim these tokens. Transactions on Hive aren't free either. They cost resource credits. The more Hive Power the account has, the more resource credits are available for the account. Since interacting with the blockchain doesn't require too much of resource credits, most of the time resource credits get unused. One of the ways to use them is to claim account creation tokens.
Some front-end apps like peakD provide options to claim these tokens. We can also claim account creation tokens using Beem. After claiming available tokens, resource credits get depleted and takes few days for RC fully recharge. One RC is full again, we can claim tokens again. Some may choose to automate this process.
Let's take a look how we can claim accounts using Beem.
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()
nodelist.update_nodes()
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))
while current_costs + 10 < last_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
print("Not enough RC for a claim!")
The code will calculate the current resource credits and keeps claiming account creation tokens until there aren't enough resource credits left to claim a token. This way we can claim multiple account creation tokens.
After having account creation tokens in the account, we can create accounts using these tokens. Let's see how that can be done using Beem.
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 = 'mynewhiveaccount'
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()
As you can see creating claimed accounts is even easier than claiming tokens. Using discounted or free account creation tokens can help apps and front-ends with onboarding new participants without a need to spend a lot of Hive.
Posted Using LeoFinance Beta