Create Publication

We are looking for publications that demonstrate building dApps or smart contracts!
See the full list of Gitcoin bounties that are eligible for rewards.

Tutorial Thumbnail
Intermediate · 1 hour

Participate in Consensus from Ledger Nano S/X

In this tutorial, we show how to participate in consensus from an account stored in a Ledger Nano S or X. By participating in consensus, you help decentralize the network.

We highly recommend reading the Overview on Participating in Consensus before starting.

Requirements

  • A Ledger Nano S or X.
  • A personal computer in which the Ledger Nano will be plugged.
  • A server to participate in consensus. It is important however that as soon as you stop running your server (or as soon as your participation key expires), you mark yourself offline (see step 9). In the case where you have physical access to the server, you may use the same machine for your server and your personal computer.
  • Familiarity with Algorand accounts.
  • Familiarity with the Overview on Participating in Consensus.

Steps

1. Setup Ledger Nano

Setup your Ledger Nano and generate an Algorand account on it. First, follow the Getting Started guide from Ledger. Then install a wallet compatible with Ledger Live on your computer or smart phone, such as the Algorand Wallet and My Algo Wallet, or use the command line.

At the end of this step, you should have an Algorand account. You must add some Algos to this account. We will use MY_ADDRESS to denote the address of this account.

Note

Ensure that the Algorand application version on the Ledger Nano is 1.2.5 or above. If this is not the case, update the firmware of the Ledger Nano: See here for Nano S and here for Nano X.

2. Install the Algorand Node Software on Your Server and Your Personal Computer

Follow the instructions in the developer documentation for both your server and personal computer. In subsequent steps, we assume that goal is in the PATH , and the environment variable ALGORAND_DATA points to a valid data folder.

If you are using the Debian package and the default data folder ALGORAND_DATA=/var/lib/algorand, you will need to execute all the goal commands as the user algorand. For that purpose, you may want to run alias goal="sudo -u algorand -E goal".

3. (Optional) Enable Telemetry on the Server

Enabling telemetry provides data to Algorand to improve the software and help identify issues. See the developer documentation for details on how to configure telemetry.

4. Wait until Your Server Is Fully Synced

To check if your server is fully synced, run the command goal node status. Check that Sync time is 0s and that Last committed block matches the current round on a block explorer.

You may also want to check that you are on MainNet, by checking the Genesis ID is mainnet-v1.0.

You do not need your personal computer to be fully synced, but it is more convenient to do so.

5. Generate the Participation Key and Key Registration Transaction on Your Server

On your server, generate a participation key and a key registration transaction:

$ goal account addpartkey -a MY_ADDRESS --roundFirstValid FIRST_VALID_ROUND --roundLastValid LAST_VALID_ROUND
$ goal account changeonlinestatus --online=true -a MY_ADDRESS --fee 1000 --txfile online.tx

where MY_ADDRESS should be replaced by your address, FIRST_VALID_ROUND by the current round, and LAST_VALID_ROUND by FIRST_VALID_ROUND plus 3 million.

The participation key is generated in $ALGORAND_DATA/mainnet-v1.0 (look for *.partkey files).
The (unsigned) key registration transaction is generated in the current folder: it is the file online.tx. Transfer this file online.tx from your server to your personal computer

Your participation key will expire in 3 million rounds (i.e., about 5 months with current block speed). Recall that you must renew your participation key or register yourself offline before the round LAST_VALID_ROUND (see steps 9 and 10).

6. Connect the Ledger Nano to Your Personal Computer

Connect the Ledger Nano to your personal computer, enter the PIN, and open the Algorand application. Run goal wallet list and check to see a wallet with a name starting with Ledger-Nano-. Write down the name of this wallet: NAME_OF_LEDGER_WALLET.

On macOS, you need to ensure that the Ledger Live application is closed, as only a single application can access the Ledger Nano at a time.

If you still do not see the Ledger Nano, make sure you’ve tried the steps on the ledger website to debug potential USB issues. If the USB connection has been verified, you can check the logs in $ALGORAND_DATA/kmd-v0.5/kmd.log.

7. Sign and Send the Key Registration Transaction on your Personal Computer

On your personal computer, sign the file online.tx (that you transferred from your server), and send it to the blockchain:

$ goal clerk sign -i online.tx -o online.sig -w NAME_OF_LEDGER_WALLET
$ goal clerk rawsend -f online.sig

The first command requires you to verify the transaction on the Ledger Nano, by following the instructions displayed on the Ledger’s screen.
The second command sends the key registration transaction and registers your account online.

If your personal computer is not synced, you need to run the second command on the server (after transferring online.sig to the server).

8. Check that Your Server is Participating

Depending on your stake, wait 30min or more and run

$ grep 'VoteBroadcast' $ALGORAND_DATA/node.log

See Check that the Node is Participating.

9. (If Needed) Register Offline

If you want to stop participating in consensus (for example, if you want to decommission the serve) , you need to register offline beforehand, by sending, from the personal computer, an offline transaction:

$ goal account changeofflinestatus --online=false -a MY_ADDRESS --fee 1000 -w NAME_OF_LEDGER_WALLET

This command generates, signs, and sends the transaction. It is assuming that your personal computer is synced and the Ledger Nano is connected to it. You will need to to verify the transaction on the Ledger Nano, by following the instructions displayed on the Ledger’s screen.

If your personal computer is not synced, you will need to generate the transaction on the server, transfer the transaction to the personal computer, sign on the personal computer with Ledger Nano, transfer the signed transaction to the server, and finally send the transaction from the server (as in steps 5-7).

10. (If Needed) Renew Participation Key

It is important to renew the participation key long enough before expiration. The procedure is the same as for participating for the first time.
If you do not want to participate anymore, you must register offline (see previous step).

Note that the Algorand blockchain does not automatically register offline accounts with expired participation keys.