Skip to content

Bitcanna Node Guide

Requirements

This guide is written for Ubuntu 22.04.

User setup

Best practice is to run node software on an isolated unprivileged user. We'll create the bcna user in this guide; if your username is different change it wherever it appears.

Create the bcna user

sudo useradd -m -s /bin/bash bcna

Build environment setup

Install build packages

sudo apt install -y build-essential git unzip curl

Install go toolchain

  1. Download and extract go 1.18.5.
    curl -fsSL https://golang.org/dl/go1.18.5.linux-amd64.tar.gz | sudo tar -xzC /usr/local
    
  2. Login as bcna.
    sudo su -l bcna
    
  3. Configure environment variables for bcna.
    cat <<EOF >> ~/.bashrc
    export GOROOT=/usr/local/go
    export GOPATH=\$HOME/go
    export GO111MODULE=on
    export PATH=\$PATH:/usr/local/go/bin:\$HOME/go/bin
    EOF
    source ~/.bashrc
    go version  # should output "go version go1.18.5 linux/amd64"
    

Build node binary

  1. Login as bcna (skip if you're already logged in).
    sudo su -l bcna
    
  2. Build and install the binary as the user that will run it.
    git clone https://github.com/BitCannaGlobal/bcna.git
    cd bcna
    git checkout v1.5.3
    make install
    bcnad version  # should output "1.5.3"
    

Configure chain

This section is written for mainnet (bitcanna-1); modify the ID, genesis, and seeds as needed.

  1. Login as bcna (skip if you're already logged in).
    sudo su -l bcna
    
  2. Initialize config files and dirs. Replace <moniker> with a public name for your node.
    bcnad init --chain-id bitcanna-1 <moniker>
    
  3. Download the bitcanna-1 genesis.json.
    curl -fsSL -o $HOME/.bcna/config/genesis.json https://raw.githubusercontent.com/BitCannaGlobal/bcna/main/genesis.json
    
  4. Set the chain-id. This will save it in client.toml so you won't need --chain-id again.
    bcnad config chain-id bitcanna-1
    
  5. (Optional) Configure some seeds. This will help your node find peers.
    sed -i 's/^seeds =.*/seeds = "[email protected]:26656,[email protected]:26656"/' $HOME/.bcna/config/config.toml
    

Start the node

Congrats! You're ready to go.

  1. (Optional) Statesync if you want a head start over syncing from scratch.
  2. Start syncing blocks!
    bcnad start
    

Create a service

A systemd service will keep bcnad running in the background and restart it if it stops.

  1. Create the service file with sudo using your favorite text editor.
    /etc/systemd/system/bcnad.service
    [Unit]
    Description=bcnad
    After=network.target
    
    [Service]
    Type=simple
    User=bcna
    ExecStart=/home/bcna/go/bin/bcnad start
    Restart=on-abort
    LimitNOFILE=65535
    
    [Install]
    WantedBy=multi-user.target  
    
  2. Reload systemd to pick up the new service.
    sudo systemctl daemon-reload
    
  3. Start the service.
    sudo systemctl start bcnad
    
  4. Tail your service logs.
    sudo journalctl -fu bcnad
    
  5. (Optional) Enable the service. This will set it to start on every boot.
    sudo systemctl enable bcnad