Dev Slug

How to create a Cardano Testnet node in Linux

Posted on December 14, 2021  •  3 minutes
Table of contents

This guide will go through the step-by-step process of creating a Cardano Testnet node on Ubuntu Server 20.04 LTS.

This guide will go through the step-by-step process of creating a Cardano Testnet node on Ubuntu Server 20.04 LTS. It takes about 5-10 minutes of effort plus several hours of waiting (5 minutes to mix ingredients together + 3 hour to bake).

Why do this?

The paths we’re using

These are the paths you’ll see mentioned throughout this guide. Feel free to use whatever paths you want.

Install Ubuntu Server (Linux)

Download and install Ubuntu Server 20.04.3 LTS onto a virtual machine, such as VirtualBox .

Install OpenSSH when prompted.

Use “Bridged Adapter” in VirtualBox to make life easier.

Increase the memory and processor counts. It uses one CPU by default.

Install Cardano Node

Create a place to store Cardano-related files.

mkdir ~/cardano
cd ~/cardano

Download and extract the pre-compiled binary for the Cardano Node. The following is as of December 2021. Go to https://developers.cardano.org/docs/get-started/installing-cardano-node/ to get the latest version.

wget https://hydra.iohk.io/build/8674953/download/1/cardano-node-1.31.0-linux.tar.gz
tar zxvf cardano-node-1.31.0-linux.tar.gz

Alternatively, you could spend the whole day building the binaries from source. If you’re like me, you’ll get frustrated after the first two hours and want to quit. Using the binaries above (which were built by IOHK, the team behind Cardano) takes seconds, is less involved, and is exactly what you’d get if you built them yourself.

Copy the two main binaries to a permanent location.

mkdir -p ~/.local/bin
cp ./cardano-cli ~/.local/bin/
cp ./cardano-node ~/.local/bin/

Add that permanent location to your shell’s path.

export PATH="$HOME/.local/bin/:$PATH"

Append the above line to your ~/.bashrc file as well. For example: nano ~/.bashrc

Download the blockchain

Create a place to put the testnet blockchain.

mkdir ~/cardano/testnet
cd ~/cardano/testnet
mkdir testnet-db

Download the testnet configuration files from IOHK.

curl -O -J https://hydra.iohk.io/build/7654130/download/1/testnet-topology.json
curl -O -J https://hydra.iohk.io/build/7654130/download/1/testnet-shelley-genesis.json
curl -O -J https://hydra.iohk.io/build/7654130/download/1/testnet-config.json
curl -O -J https://hydra.iohk.io/build/7654130/download/1/testnet-byron-genesis.json
curl -O -J https://hydra.iohk.io/build/7654130/download/1/testnet-alonzo-genesis.json

Set some environment variables.

export CARDANO_NODE_SOCKET_PATH="$HOME/cardano/testnet-db/node.socket"

Connect to the testnet and download the blockchain. This may take several hours.

cardano-node run \
--topology ~/cardano/configuration/testnet/testnet-topology.json \
--database-path ~/cardano/testnet-db \
--socket-path ~/cardano/testnet-db/node.socket \
--host-addr 127.0.0.1 \
--port 3001 \
--config ~/cardano/configuration/testnet/testnet-config.json

Check to see if your node is synchronized.

cardano-cli query tip --testnet-magic 1097911063

Install Cardano Wallet

Open up a second shell window (using Alt+F2). We’ll let the node run in the other shell (switch back to it using Alt+F1). Alternatively, connect using Putty or your favorite SSH client.

Download the pre-compiled binary for the Cardano Wallet and put it in a permanent location. The following is as of December 2021. Go to https://developers.cardano.org/docs/get-started/installing-cardano-wallet/ to get the latest version.

mkdir ~/cardano/wallet
cd ~/cardano/wallet
wget https://hydra.iohk.io/build/8600272/download/1/cardano-wallet-v2021-11-11-linux64.tar.gz
tar zxvf cardano-wallet-v2021-11-11-linux64.tar.gz
cd cardano-wallet-v2021-11-11-linux64/
cp cardano-wallet ~/.local/bin/

Run the Cardano Wallet as an API server.

cardano-wallet serve \
--port 8090 \
--database ~/cardano/testnet-db \
--node-socket $CARDANO_NODE_SOCKET_PATH \
--testnet ~/cardano/configuration/testnet/testnet-byron-genesis.json

For more information, see the User guide for cardano-wallet .