[Project: Blockchain] Algorand Tutorial 1: Create Account

Desc:

Algorand Blockchain using Python to create account on TestNet.

Inspired by original tutorial here: https://developer.algorand.org/tutorials/create-account-testnet-python/

To fund accounts on TestNet go here for free algos (fake monies to work on the algorand blockchain): https://bank.testnet.algorand.network/

Branch: Main

Tag: –

Repo: –

Forked: –

The Steps:

Install Python 3

Go here and install python 3.9.x for Win, Mac or Linux here: https://www.python.org/downloads/

Install miniconda

Go here and install miniconda 3.9.x for Win, Mac or Linux here: https://docs.conda.io/en/latest/miniconda.html

Setting Python Path

Setting path is tricky.

# Mac, Linux
export PATH=”$PATH:/usr/local/bin/python”

Windows 10 is more complicated.

  • Go into “Run” prompt and enter “sysdm.cpl
  • This should open up the System Properties window. Go to the Advanced tab and click the Environment Variables button.
  • In the System variable window, find the Path variable and click Edit:
  • Position your cursor at the end of the Variable value line and add the path to the python.exe file, preceded with the semicolon character (;).
  • Example:
    • ;C:\Python\Python39

Change to Target Directory

Where u want to put the project directory and its files.

# Mac, Linux and Windows
cd <your target dir>

Clone Repo

Copy the code.

# Mac, Linux and Windows
git clone https://github.com/csalinasonline/algoPyCreateAccount.git

Change to Repo Directory

# Mac, Linux and Windows
cd algoPyCreateAccount

Activating a Virtual Environment

Close current terminal. Change directory to ‘../algoPyCreateAccount’

Turn on the sandbox.

# Mac, Linux and Windows
conda create -n algoPyCreateAccount python=3.9
# activate environment
conda activate algoPyCreateAccount

Run Pip

Install dependencies.

# Mac, Linux and Windows
pip install -r requirements.txt

Run program

Finally run the program.

# Mac, Linux and Windows
python main.py
# ******************************************************************************
# Project : algoPyCreateAccount
# Filename : main.py
# Author : csali
# Origin Date : 6/27/2021
# License : MIT
# Notes : Used example from
# https://developer.algorand.org/tutorials/create-account-testnet-python/ to
# create 4 accounts.
# ******************************************************************************
import json
from algosdk import account, mnemonic
def main():
"""
Main hook
"""
# create 4 accounts
acct = account.generate_account()
address1 = acct[1]
mnemonic1 = mnemonic.from_private_key(acct[0])
acct = account.generate_account()
address2 = acct[1]
mnemonic2 = mnemonic.from_private_key(acct[0])
acct = account.generate_account()
address3 = acct[1]
mnemonic3 = mnemonic.from_private_key(acct[0])
acct = account.generate_account()
address4 = acct[1]
mnemonic4 = mnemonic.from_private_key(acct[0])
# account info to console
print("")
print("Copy off accounts above and add TestNet Algo funds using\
the TestNet Dispenser at https://bank.testnet.algorand.network/&quot;)
print("copy off the following mnemonic code for use later")
print("")
print("Account 1\n" + str(address1))
print("mnemonic1 = \"{}\"\r\n".format(mnemonic1))
print("Account 2\n" + str(address2))
print("mnemonic2 = \"{}\"\r\n".format(mnemonic2))
print("Account 3\n" + str(address3))
print("mnemonic3 = \"{}\"\r\n".format(mnemonic3))
print("Account 4\n" + str(address4))
print("mnemonic4 = \"{}\"\r\n".format(mnemonic4))
# save accounts to file for later
print("Saving account info to file.")
file = open('ACCOUNT_INFO.txt', 'w')
file.write("Copy off accounts above and add TestNet Algo funds using"
" the TestNet Dispenser at https://bank.testnet.algorand.network/&quot;
" and copy off the following mnemonic code for use later\r\n")
file.write("Account Info:\r\n")
file.write("Account 1 = " + str(address1))
file.write("\r\nmnemonic1 = \"{}\"\r\n".format(mnemonic1))
file.write("Account 2 = " + str(address2))
file.write("\r\nmnemonic2 = \"{}\"\r\n".format(mnemonic2))
file.write("Account 3 = " + str(address3))
file.write("\r\nmnemonic3 = \"{}\"\r\n".format(mnemonic3))
file.write("Account 4 = " + str(address4))
file.write("\r\nmnemonic4 = \"{}\"\r\n".format(mnemonic4))
file.close()
if __name__ == "__main__":
main()
view raw main.py hosted with ❤ by GitHub

If all went well we should see console account info and a text file with account info.

Copy off accounts above and add TestNet Algo funds using the TestNet Dispenser at https://bank.testnet.algorand.network/ copy off the following mnemonic code for use later
Account 12DH43BSEWVQZ2XSVKWFMS5SGFDHV5EBXDSFCQHCODCPXJYIOGL7WEOID6I
mnemonic1 = "swarm transfer border digital gather wage blouse knee frozen cart taxi balance festival helmet radio ill bicycle notice fade hungry stomach shiver kidney abstract bronze"
Account 2OLOCVXHXMOLOV4BN2FHXS23S46UWJIKFDVZJ2WL3KOSX3JFRMTJWYW2OIY
mnemonic2 = "sunny dismiss buffalo sponsor gentle goose fix assist wonder young tag thank exclude decade retire onion birth horse grace album slice armor sketch absorb cereal"
Account 3HDIBUPS7F66RW5IUOEUVS7XCFS56PO6DWK37AMKVWSALMOGCYMDHSUMG3A
mnemonic3 = "erosion appear subway planet pear follow diet twice only delay adult goddess clerk keep raise bind hurdle wire mass animal frequent among month absent time"
Account 4Y3NGZ2UELKRXIV2U2PV42CIV6VD3HTKPGRFEA2UVHEWJT364JHB4YM2MOA
mnemonic4 = "muffin actor candy juice carbon balcony stone street section rival alert little typical muscle legend gallery squirrel daring awake gaze poverty license decade about almost"
Saving account info to file.

Deactivating the Virtual Environment

Turn off sandbox.

conda deactivate

About:

Medium: @csalinasonline
LinkedIn: https://www.linkedin.com/in/conrad-salinas-17a29327
Site: https://www.DeepHomebrew.com

Medium Link: https://link.medium.com/C4GXyVMkPhb
Site: https://deephomebrew.com/

Discover more from deepHomeBrew

Subscribe now to keep reading and get access to the full archive.

Continue reading