By default, an Algorand installation is configured to run on MainNet. For most users, this is the desired outcome. Developers, however, need access to our TestNet or DevNet networks. This guide will walk you through connecting to one of these other networks.
Every Algorand node has a data directory that is used to store the ledger and other configuration information. As part of this configuration, we use a genesis.json file.
The genesis.json file specifies the initial state of the blockchain - its ‘genesis block’. This is a JSON formatted file with the schema for the blockchain. It contains the network name and id, the protocol version and list of allocated addresses to start the chain with. Each address contains a list of things like their status and the amount of Algos they own.
As part of the installer, a genesisfiles directory is created under the node's installed location for binaries. In this directory is an additional directory for each of the Algorand networks; DevNet, TestNet, and MainNet. These directories contain the genesis.json file for each of the Algorand networks (eg
~/node/genesisfiles/mainnet/genesis.json). [Note that the genesis files are stored under
/var/lib/algorand/genesis/ for DEB and RPM installs] These genesis files can be used to create a new data directory for the specific network. Assume you have installed your node in the
~/node directory and your data directory is
~/node/data. You can switch to TestNet using the following steps [If you are running a DEB/RPM install of the node, you can replace the genesis file in the current data directory which should be
First create a new data directory for TestNet, in this case, we are using testnetdata. Stop the currently running node and copy the genesis.json file for TestNet to this new directory.
cd ~/node ./goal node stop -d data mkdir testnetdata cp ~/node/genesisfiles/testnet/genesis.json ~/node/testnetdata
Start the node with its data directory set the new location.
./goal node start -d ~/node/testnetdata
The node will restart and begin communicating with the TestNet network. It will need to sync with the network which will take time. You can run the following command to check the current sync status.
./goal node status -d ~/node/testnetdata