Creating a New Account and a Participation Key

This tutorial works with a private network. 

Prerequisites tutorials: 

1) creating private network tutorial

2) creating a new Wallet tutorial 

Create the Private Network

goal network create -r ~/net1 -n private -t <path_to_template.json>

Start the Network

goal network start -r ~/net1

You can check that the status of the network is working by running the following command:

goal network status -r ~/net1

Create a New Account

Creating an account will create a new address and add it to the existing wallet that was created on the node when the network started. To create the account run the following goal command if you have not done this already:

goal account new -d ~/net1/Primary

This will create an account on the Primary node in the private network. This command will also return the newly created account. You can list the accounts on the Primary node by running the following goal command:

goal account list -d ~/net1/Primary 

If you used the template referenced in the private network tutorial this command will list out two accounts. Note both are offline and both have 0 microAlgos

[offline] Unnamed-0 673GRF6NA7HRVWG4E5NIHOPCC4MBFDYZOUQ6KLYBPYWC34HTHVCX7FMZYM	0 microAlgos	*Default

Now list the account for the unencrypted-default-wallet and note the account is online and has a balance.

goal account list -d ~/net1/Primary -w unencrypted-default-wallet
5000035000000000 microAlgos

Check the status and note the last committed block number

goal network status -r ~/net1

Add a Participation Key

As covered in the protocol overview guide, in order for an account to participate in consensus an account must have a participation key.  This key can be generated using the goal command line tool for a new account, which is either offline accounts above. Note the current block number must be in the range of roundFirstValid and roundLastValid.

goal account addpartkey -a [NewlyCreatedAccount] --roundFirstValid 50 --roundLastValid 4000 -d ~/net1/Primary 

In addition to a participation key an account, it needs to have funds (ie stake) and the account must be placed online. In this tutorial, we can simply use goal to send tokens from an account, which is the online one above on the Primary node, to the newly created account. Use the address here for the Unnamed-0 account

goal clerk send -a 102000 -f [ExistingAccount] -t [NewlyCreatedAccount] -d ~/net1/Primary -w unencrypted-default-wallet

If you list the accounts again on the primary node the newly created account should now have 102000 tokens less the fee. Note that this may take a few seconds to be reflected as the block has to be approved in consensus and written to the blockchain.

Also, the TestNet dispenser only transfers funds to TestNet accounts, not Private Network accounts, so the goal clerk command needs to be used to transfer funds in a private network.

Finally, you can put the newly created account online by running:

goal account changeonlinestatus -a [NewlyCreatedAccount] -o=true -d ~/net1/Primary 

This will create a transaction and will go through consensus, like any other transaction. Once the transaction is approved and written to the blockchain, running goal account list should show the account is online. Additionally when this transaction above is submitted there is a 320 round delay before the account will actually go online. To see the current block number use this command:

goal node status -d ~/net1/Primary 

Shutdown and Delete the Private Network

In order to prevent multiple copies of the Algorand processes from running, you may want to shut down and delete the private network when you are finished testing. To do this run the following commands:

goal network stop -r ~/net1
goal network delete -r ~/net1