Make your own NKM (New Kind of Miner) out of a Raspberry pi


NKN (New Kind of Network) is probably the most exciting blockchain project in the year 2018. With NKN blockchainizing the whole network layer it reaches out to be the third pillar of internet structure besides computing and storageing.

In terms of mining that means that NKN tokens could be earned just by providing your internet bandwidth to the network. On the contrary to many other tokens you don’t need any big server farms or masses of storage — just a network device with an OS and a little bit of configuration. The NKN mining introduction video is a very good point to get started:

Now what’s important to run a node? Obviously you don’t need much computing power and only some space for storing the NKN blockchain on your device — so why don’t use a low-power consuming computer like the raspberry pi? This tutorial describes how to turn it into a NKM (New Kind of Miner).

What you’ll need

  • A Raspberry pi with a network interface (Raspberry pi 1 Model B and up) or Raspberry pi zero W with a suitable Micro SD Card (16GB+)
  • A personal computer with some sort of SSH Terminal (on Windows I recommend Putty
  • A way to format your micro SD card with the Raspian Image (recommended: Etcher
  • Your internet connection

Getting started

Before we can start configuring our miner we have to get our raspi ready. The next part describes how to get your device running with the latest Raspberry OS (Raspian) and enable all needed things so you are able to connect to it through SSH.

1. Install Raspian OS

Installing an OS to your Raspberry is very easy. First of all we need to download the OS Image. In this tutorial we are using the latest Raspian Stretch Lite Image. You can get it at Store it to the directory of your choice.

After download is finished put the micro SD card to your computer and start up your formatting software. Choose the downloaded image, flash it to your card and wait until it’s finished. Some software like Etcher automatically eject your device. Because we’re not finished yet you need to reinsert it in that case.

If everything went right an external device named “Boot” appears in your file explorer. Depending on the model of your pi continue to the according headless installation step.

2a. Headless installation on Raspberry pi 1 Model B and up

Probably the easiest step of this tutorial. If you got a Raspberry pi 1 Model B and up just copy an empty file called “ssh” (without any file extension) to your micro SD card.
If you got problems creating a file without file extension on windows check out

2b. Headless installation on Raspberry pi zero W

Headless installation on Raspberry pi zero W is basically the same as on other Raspberries except for an additional file for WiFi configuration.
Two files have to be copied to your SD card:

  • Empty file called “ssh” (without any file extension)

  • file called “wpa_supplicant.conf” with the following code. Adjust country code, ssid and psk to your needs.

      ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev

Alright, now we can get started! Safely eject your micro SD card from your PC and put it into your pi. Power it on and wait about 1 minute for it to start. You can access it via SSH-Software by connecting to the following:

Host: raspberrypi
User: pi
Password: raspberry

All went fine? Okay! Then we can finally get our hands on setting up our miner!

Installation on a Raspberry

If you skipped the previous step make sure you are connected to your raspberry via ssh and changed in your pi home directory. In short: if you see

[email protected]:~ $

on your screen you are fine :wink:

3. Installing newest version of Golang

By default Raspian comes with an old version of go — way too old to use it with NKN. So we first need to install the newest version. Copy and paste the following lines to your terminal:

Look up the latest version of go and store the download path in “url”:

url="$(wget -qO- | grep -oP 'https:\/\/dl\.google\.com\/go\/go([0-9\.]+)\.linux-armv6l\.tar\.gz' | head -n 1 )"
wget ${url}

Extract go environment to /usr/local :

sudo tar -C /usr/local -xvf echo ${url} | cut -d '/' -f5

Finally set your environment variables correctly: Please enter line by line with pressing RETURN.

cat >> ~/.bashrc << 'EOF
'export GOPATH=$HOME/go
export PATH=/usr/local/go/bin:$PATH:$GOPATH/bin

Good job! Now we only need to re-source our bash with:

source ~/.bashrc

and everything should be done! Confirm that by typing

go version

Now your pi should be on a go version of 1.11 or up . Therefore we could start downloading an building the NKN executables.

4. Download and build your NKN node

At the time of writing NKN has to be built in a pre-defined folder structure. Let’s create that and finally jump into it:

mkdir -p ~/go/src/ && cd ~/go/src/

From now on we’re following the official guide to build NKN under, but though git is not installed on Raspian Stretch Lite we have to install it:

sudo apt-get install git

Now we can clone the NKN repository:

git clone

Change directory to new folder:

cd nkn

Build the source code with make


Easy, isn’t it? Now you’ve built the main two executables nknc and nknd and are ready for some mining work!

5. mainnet config and wallet creation

Before starting your node you have to rename the right configuration file and create a wallet.

The configuration of a NKN Node is stored in the config.json file. Fortunately NKN already has a testnet configuration file for you which has only to be copied. Just type

cp config.mainnet.json config.json

and you’re done!

By default the earned mining rewards are transferred to the node’s wallet. If you don’t want that (maybe because you want them to be transferred to an offline wallet) you can do this by editing the recently created file. Type

nano config.json

to open that file and fill in your wallet address like so:

"BeneficiaryAddr": "YOUR_NKN_WALLET_ADDRESS",

Regardless if you put in a different address in your config or not you need to create a wallet:

./nknc wallet -c

choose a safe password. If you need this wallet in the future make sure you save your given walletaddress, the fresh created wallet.json in the current folder and your password at a safe place!

6. Test mining

Wow, you did it! Everything is set up and you can start mining! Start your node with


and test if your node successfully connects to the network. If that’s not the case you probably forgot to forward ports 30000 to 30003 in your router. This is very specific to your model so make sure you check out to help you get started.

If your node has connected properly you can terminate it by pressing CTRL+C because there is one last thing to do: Configure your NKM to be completely Plug’n’Play — autostart on system load and restart on crash.

7. Plug’n’Play NKM

Switch back into your home directory with

cd ~

Then open a new file called “nkn.service” in nano

nano nkn.service

copy and paste this content. Don’t forget to replace your wallet password :


ExecStart=/home/pi/go/src/ -p YOUR_WALLET_PASSWORD

That creates a service file that automatically creates a process that starts a node and restarts it 3 seconds after it exited unexpectedly.

Copy this file into /etc/systemd/system as root:

sudo cp nkn.service /etc/systemd/system/nkn.service

And now the great final : make the service start on boot.

sudo systemctl enable nkn.service

reboot your device and you’re done!

sudo reboot

8. (NEW) Auto updating NKM

Since NKN is in early development stage it is necessary to update your node regularly. For that you have to repeat some steps under section 4 again — named stopping your currently running node, updating your nkn-files with git pull and then running make again.

Wouldn’t it be nice to make the node updating itself regularly so that we don’t have to take care of it?

As always we start from our home directory. So if you don’t see

[email protected]:~ $

flashing at your screen change to your home directory by typing

cd ~

First of all we have to create a script that updates the NKN files. So let’s create it by directly jumping into our text editor (cool kids could use vi, I prefer nano)

nano nkn-updater

copy and paste the following contents to it:

cd $HOME/go/src/ fetch &>/dev/nullLOCAL=$(git rev-parse HEAD)
UPSTREAM=$(git rev-parse @{u})if [ $LOCAL != $UPSTREAM ]
systemctl stop nkn.service;
git merge;
make deepclean;
chown -R pi:pi $HOME/go;
systemctl restart nkn.service;

Then exit the file by pressing CTRL+X and Y. To make this file executable we quickly run

chmod +x nkn-updater

Last thing to do is to tell Debian to run our script daily at 12 AM. For this we have to edit our crontab list. Start it by running

sudo crontab -e

accept nano as your default editor by pressing RETURN and now you will get to the crontab file. Then append the following line to the end of the file:

00 12 * * * /home/pi/nkn-updater >/dev/null 2>&1

Again exit and save your file by pressing CTRL+X and Y. And you’re done — no more configuration needed!

Now you can lean back and enjoy your new automated miner — A true New Kind of Miner!

If there are any questions don’t hesitate to ask me about it. I will update and expand this tutorial regularly. You can reach me on the NKN discord channel ( as well on twitter (@ChristianoBusch) or the NKN telegram channel (#ChrisT).

1 Like

I always wanted to ask someone who had experience with RaspPi

So if I start a small miner farm of 20-25 rasp pi in my home, what kind of precautions I can take to reduce the overheading problems? I assume they’ll be running 24x7x365, what kind of electricity bill I can expect?


First of all and most importantly, you need one public IPv4 addresses for each Raspberry Pi. This might be challenging for most home users.

I won’t worry too much about heat: at least my Raspberry 3 B+ with cheap small heatsink is lukewarm when running NKN software. With load, it consumes about 6.4 watts as measured in this article:

1 Like

This is informative. Thank you for taking the time out to reply.

I never thought getting a static public IP would be this much of a pain…
Is there any solution to get static public IP? Seems like my ISP consider it as a business plan feature.