Algorand Testnet Account
Create an Account on TestNet with Python
Generate a new standalone account, fund it with the TestNet faucet, and check your balance using the Python SDK.
Requirements
- Python SDK
- A TestNet node address and token
Background
To send any type of transaction, you must first have an account. This tutorial focuses on generating a Standalone Account. To learn more about Accounts on Algorand visit the Accounts Overview page in the docs.
Steps
1. Generate an Algorand Key Pair
Import the account
module from the Python sdk.
1 |
|
Generate a public/private keypair with the generate_account
function.
1 |
|
Print the private key an Algorand address so you can see what they look like.
1 |
|
The private key is the base64 representation and the Algorand address is the base32 checksummed version of the public key.
2. Retrieve the Private Key Mnemonic
Transform this key into a mnemonic that you can save for later use. To do this, first import the mnemonic
module. Then export the private key as a mnemonic.
1 |
|
Note that the mnemonic will be different set of 25 words each time you run this tutorial. Because we are on TestNet and demonstrating an example, we are openly sharing this private key. You should never do this in real life; especially when your private key represents an account with real-value assets.
With this mnemonic, anyone can sign spend transactions from the corresponding account.
3. Send Algos to the New Account
Let’s send Algos to the new account by visiting the TestNet faucet linked here.
Enter the Algorand Public Address in the textbox, complete the recaptcha, and click “Dispense”. If you receive a 200 status code, your account should now be funded with 100 Algos.
4. Completed Code
The following code generates 3 accounts. It is sometimes useful to have multiple accounts. Three accounts will be needed for ASA tutorials for example. Be sure to fund each generated account using the TestNet Dispenser as described above.
1 |
|
5. Check Your Balance
You can check your balance with any block explorer connected to TestNet.
You can also connect to a node through the Python algod client. Make sure to first retrieve an IP address and access token through one of the methods described in the Workspace Setup.
1 |
|
Reference: https://developer.algorand.org/tutorials/create-account-testnet-python/