This directory (/infrastructure
) provides an example setup for a private-net, which you can use for local testing. It creates a single node, fully functional Algorand blockchain with:
- one wallet:
Wallet1
- one address full of Algos (100% of total supply). We call that account a
master-account
.
Use make
to run tasks to create
, start-private-net
, stop-private-net
.
If you want to create a local network without using our scripts then you can follow this [tutorial](https://developer.algorand.org/tutorials/create-private-network/**.
TL;DR: Make sure you have Algorand Node (algod
and goal
) and make
installed. Then cd infrastructure; make setup-private-net
. To reset use recreate-private-net
.
-
Install the latest Algorand node. Use one of the options described in the Algorand installation documentation.
-
Make sure the algorand node is installed correctly. You can disable algorand service if you installed algorand node using a package:
algod -v [optional] systemctl stop algod
-
Clone this repository
-
Then:
cd infrastructure make create-private-net
-
Check the access token and network address. You will need them in your config file to correctly connect to a node. When using
make create-private-net
the script will set the network configuration (PrimaryNode/config.json) and token for you to match thealgob.config
used in all our examples. Don't expose the node externally - otherwise you will need to setup a firewall and generate a new token. You can see the network and a port by opening the following files:cat node_data/PrimaryNode/algod.net cat node_data/PrimaryNode/algod.token
-
To start and stop the the chain use the following commands:
make start-private-net make stop-private-net
-
To set up master account (the account with hardcoded key we use in all our examples):
make setup-master-account
The command below will combine all the steps above (create network, start network, setup master account and show network status):
make setup-private-net
To recreate the private net (stop the current instance, remove all data and re-setup):
make recreate-private-net
We can connect to an algob
node either using goal
command or REST. goal
is only able to use a local node (need to have an access to the node data directory). So each use of goal
will require specifying --datadir
flag or ALGORAND_DATA
environment variable. It's useful to define the former one (we are doing it in the Makefile):
export ALGORAND_DATA=`pwd`/node_data/PrimaryNode
To connect from SDK or REST we need to know the network address and authorization token. This are stored in:
cat $ALGORAND_DATA/algod.net
cat $ALGORAND_DATA/algod.token
Algorand Sandbox is a fast way to create and configure an Algorand development environment with Algod and Indexer. To quickly bring up a private network with algorand sandbox and use it within algob, following jobs are provided (in /infrastructure
) :-
NOTE: Please make sure to have Docker Compose installed (with non root privilages) before running sandbox.
-
sandbox-up
- Clones the sandbox git repo in~/.algorand-sandbox
and setups the network (this might take a while). -
sandbox-setup-master-account
- After starting the network usingsandbox-up
, we can use this job to create the master account present in algob config. -
sandbox-algod
- Use this command to enter the algod's docker container. To exit usectrl + D
. -
sandbox-down
- Bring down the sandbox network i.e stop docker containers running algod, indexer and indexer-db. -
sandbox-clean
- Clean up the env by removing stopped container and unused images.
Few Points to be noted :
-
To use goal commands within sandbox environment, we need to use the sandbox executable file (present in ~/.algorand-sandbox). eg. To list accounts using goal, use
~/.algorand-sandbox/sandbox goal account list
(where~/.algorand-sandbox
is the directory and~/.algorand-sandbox/sandbox
is the executable file). If you want to usegoal
directly, you can execute these commands from within the algod's container. To enter usesandbox-algod
. -
Algod port is set to
8081
and kmd port is set to8082
. Make sure to update the port inalgob.config
before running the examples.
To learn more about sandbox, click here.
Private Net
curl http://$(cat $ALGORAND_DATA/algod.net)/v1/block/31538 -H "X-Algo-API-Token: $(cat $ALGORAND_DATA/algod.token)"
Purestake:
curl -X GET "https://testnet-algorand.api.purestake.io/ps1/versions" -H "x-api-key:<api-key>"
KMD is not started by default (with make start-private
). You need to run it separately with make start-kmd
. Similarly to algob
, we can check the running kmd network address and token in the following files:
cat $ALGORAND_DATA/kmd-v<version>/kmd.net
cat $ALGORAND_DATA/kmd-v<version>/kmd.token