Running a Whive node on a Raspberry Pi

Running a Whive node on a Raspberry Pi

Introduction

Whive, is a peer-to-peer blockchain protocol that is incentivizing the building of sustainable energy solutions through Trustless Rewards.

The Protocol was developed by Bithub Africa and a team of global contributors. Bithub Africa is a commercial Blockchain Accelerator that is focused on driving Financial and Energy access across Africa.

The protocol achieves this through a hybrid Proof-of-Work(POW) & Proof-Of-Stake(POS) consensus algorithm that favours devices with CPU(small) processors & are located in regions with a high solar reliability index.

This means by becoming a network participant you shall be able to earn Trustless Rewards that are mined when you run the whive software.

In this tutorial, I will be walking you through on how to set up and run the whive protocol on a Raspberry Pi. You can also run the protocol on a desktop machine or a laptop, unix or linux or windows but with a Raspberry Pi, you get more rewards from it's algorithm.

Prerequisite

The following background knowledge will come in handy

  • Linux bash shell
  • Familiarity with Raspberry Pi in general

Components

The following components are needed

  • Raspberry pi with wifi capability.
  • SD card with more than 8GB space
  • Internet access, whether it's through wifi or ethernet cable, if your Raspberry Pi supports WiFi or Ethernet.

I personally used a Raspberry Pi 2 Model B.

1. Setting up the Raspberry Pi

Running a node in Raspberry Pi, the first step was to download raspbian from the Raspberry Pi website here.

With the software in hand, the next step is to download and install balena etcher software. The software is available here

The next step was to install raspbian on to the sd card. The software we installed, balena etcher will assist us with this. Ensure the SD card is inserted into the machine using an SD Card reader. Select the image rasbpian OS from the machine, select the target, in this case, it's our SD card and finally flash the operating system on to the SD card.

Ufafanuzi 2020-02-11 175431.png

I wanted to access the Raspberry Pi remotely. To do this, I had to create a SSH file in the boot directory. With this file, it will enable one to access the Raspberry Pi via SSH.

Ufafanuzi 2020-02-09 172841_LI (2).jpg

I then connected the SD card reader back into the Raspberry Pi and then connected it to a router via a physical ethernet cable.

smaller-2020-02-12T01_41_12.726Z.jpeg

You can also connect the Raspberry Pi to a wireless network as shown in the tutorial here.

The next step was to identify the IP address that was assigned to the Raspberry Pi. This involved logging in to the router and checking the mac address online of the network devices to find out which one belongs to a Raspberry Pi.

Ufafanuzi 2020-02-09 172842 (2).png

Once I had the Raspberry Pi, I downloaded https://www.putty.org/. Using the IP Address assigned to the Raspberry Pi, I used it as the hostname. The username I used was pi and the password as raspberry.

Ufafanuzi 2020-02-09 172843.png

Ufafanuzi 2020-02-09 172845 (2).png

2. Getting the Whive Repository

After successfully login in, the first step was installing git. To install git I ran the command.

sudo apt-get install git

With git installed, this enabled me to be able to clone the whive repository by running

Ufafanuzi 2020-02-09 172848.png

git clone https://github.com/whiveio/whive.git

3. Installing the dependencies

The instructions I used to install the dependencies can be found https://github.com/whiveio/whive/blob/master/doc/build-unix.md . This was running the commands:

sudo apt-get install build-essential libtool autotools-dev automake pkg-config bsdmainutils python3

And then running:

sudo apt-get install libssl-dev libevent-dev libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-test-dev libboost-thread-dev

Upon running the second command, I ran into the error:

Ufafanuzi 2020-02-09 172849.png

Then I had to run the following command to fix the error I got.

sudo apt-get update --fix-missing

After the fix by apt, I reran the command and was able to fix the errors.

sudo apt-get install libssl-dev libevent-dev libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-test-dev libboost-thread-dev

After successfully installing the packages, I ran:

sudo apt-get install software-properties-common

Trying to add the repository

sudo add-apt-repository ppa:bitcoin/bitcoin

I was unsuccessful because the ppa for bitcoin does not exist, I needed to add the ppa entries manually. The tough bit was installing BerkeleyDB. To install it, I had to manually add the bitcoin library. The link can be found https://launchpad.net/~bitcoin/+archive/ubuntu/bitcoin

To do this I had to run:

sudo nano /etc/apt/sources.list

And add the following list to the file

deb http://ppa.launchpad.net/bitcoin/bitcoin/ubuntu cosmic main 
deb-src http://ppa.launchpad.net/bitcoin/bitcoin/ubuntu cosmic main

To keep the changes, I needed to save and exit by:

  • Ctrl + O to save
  • Ctrl + X to exit

The next step is to add the key, to do that, I ran the command

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys C70EF1F0305A1ADB9986DBD8D46F45428842CE5E

Then update by running:

sudo apt-get update

This enabled me to install BerkeleyDB by running:

sudo apt-get install libdb4.8-dev libdb4.8++-dev

4. Building whive

I entered the whive folder:

cd  whive

And then ran the following commands one after a time.

./autogen.sh
./configure
make

5. Running whive

After all the build processes completed, I entered the src folder and ran the ./whived software which launches the whive daemon that allows one to start mining the whive tokens.

cd src
./whived

6. Ensuring whive runs even on startup

A way to ensure that the software runs even if the raspberry pi goes on or off is to edit the /etc/rc.local file using nano

sudo nano /etc/rc.local

And add the following line

/home/pi/whive/src/whived &

As shown in the photo below

Ufafanuzi 2020-02-10 003815 (2).png

To keep the changes, I needed to save and exit by typing:

  • Ctrl + O to save
  • Ctrl + X to exit

To check if whived is running, I typed

htop

And then searched for whived by typing F3 on the keyboard and searching for whived. It popped up in the first line as shown below.

Ufafanuzi 2020-02-10 003837 (2).png

7. Checking if your node is in the whive network

To check if your node is in the network, you need to identify if your public IP address (your IP address facing the internet). This involves running the command

curl ifconfig.me

It will display an IP address, you can then go to the site here

Then look for your IP address among the list

Ufafanuzi 2020-02-11 162552.png

Conclusion

With this walkthrough, I was successfully able to:

  • Install raspbian os on a Raspberry Pi,
  • Access the Raspberry Pi via ssh, installed dependencies for the whive protocol,
  • Cloned the whive repository from github
  • Build it
  • Ran the whive daemon and set up the Raspberry Pi such that when the power goes off and comes back on, the Raspberry Pi still runs the whive daemon.

The next step would probably be checking the balance from mining rewards and probably transferring the coins from one node to another in the network.

References

Contact Us

Whive Telegram Chat

Melanin Academy Blockchain Training Program

Melanin Academy Whatsapp Chat Group