Setting up a NKN Miner in 5 Minutes and run it free for 2 months with DigitalOcean


After my very successful tutorial about turning your raspberry pi into a NKM (new kind of miner)( I got asked multiple times if there is an easy way to deploy a node on some kind of cloud platform like AWS or GoogleCloud. To provide you a short answer to this: Yes, it is possible!

There are many cloud platforms out there. The one I’m using for development work the most is DigitalOcean. It is easy to use, got a “pay-per-use” billing and the UI is just gorgeous.

But first things first: What the hell is NKN and what is it all about?

What is NKN?

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 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 — that’s just perfect for a little server with high bandwith!

…And what is this Ocean-Thingy?!

DigitalOcean is a cloud platform which allows you to create virtual servers with several clicks. These systems are called “Droplets” and can be configured to have different specifications regarding computing power, storage volume or operating systems.

Billing at DigitalOcean is really simple — you only pay for the time your server is existing. That means you can delete it every time you like and after that you wont be charged until you create another droplet. The price of the smallest droplet is 5$/month (or 0.007$/hour).

…Okay, dude, you told me I get my miner 2 months for free — how do I do that?!

Well… that’s really simple. DigitalOcean offers a referral-program that grants everybody who signs up under my personal link 10$ instantly — isn’t that nice? And as a side effect: If you decide to continue after that and deposit your first 25$ I will get the same amount as a referral bonus! In that way you can support my work and provide more stability for the whole NKN Network as I can continue supplying nodes! Here’s the link:

If you don’t want to get your starting bonus or support my work that’s totally fine! You could go on in this tutorial and register your account referral-free under!

Everybody’s ready? Okay, let’s start!

What you’ll need

  • A personal computer with some sort of SSH Terminal (on Windows I recommend Putty
  • An Account at DigitalOcean (see above)
  • …yeah, that’s really it :slight_smile:

Getting started

Before we can start configuring our miner we have to get our droplet ready. In the next part we’re going to set up our droplet on DigitalOcean.

1. Spin up the Droplet

After we logged in to our DigitalOcean account we are provided with the Dashboard. From here we can click the “create” button in the upper right corner and head up to “Droplets”.

Now we can start configuring our droplet. As NKN doesn’t need much computing power let’s choose the latest Debian operating system on the smallest droplet available.

Since we don’t need any backups or block storage we only need to pick a region. For this tutorial I choose the Bangalore region but please feel free to choose any region you prefer.

After that we only have to choose a name for our droplet and we’re done by clicking on “create”

Now we can watch the node being set up. Don’t think about getting a coffee — it only takes 10–20 seconds to finish. After everything is done check your mail — DigitalOcean sent you an email containing your droplet name, IP address, username and password. That’s everything we need to connect to our new instance. Fire up your Terminal (or Putty if you’re on windows) and do so. If you’re connecting to your droplet for the first time you are asked to accept the ECDSA key fingerprint by typing “yes” into the terminal. Additionally you’re forced to change your password for the user “root”. Do so by typing in your current password (that one sent to you via email) and double-typing your new one.

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


If you skipped the previous step make sure you are connected to your droplet or virtual server via ssh with the root-user and changed to your home directory. In short: if you see

[email protected]_DROPLET_NAME:~#

on your screen you are fine :wink:

1. Updating Debian and installing dependencies

Every Droplet is like a new-born child. So we have to teach it how things are going. First of all we’re updating our list of available software:

apt-get update

Just to be sure we’re on the latest version of all installed packages we run

apt-get upgrade

If the system asks us to continue we do that by typing “Y” followed by RETURN.

As time of writing there is an update to the config of sshd available. If you are asked what you want to do with it just stick with “keep the local version currently installed”

After the updating process finished we can start to install the executables we need. In our case the necessary ones are make, curl and git.

apt-get install make curl git

Again accept it by typing “Y”.

2. Creating the NKN-User

Thought NKN is in testnet stage and there aren’t many security issues it is still a good idea to not run our processes with root-access. Because of that we will create a new user called “nkn” who has rights to run executables as a super user.

adduser nkn

now you’re asked to set some details for the newly created user like password (which is required) and optional informations like Full Name, Room Number, Work Phone, Home Phone and Other.

After that is done we give the user the right to use the “sudo” (run as super user) command by adding him to the sudo-group:

usermod -aG sudo nkn

Our user is created, so why don’t we test it? Disconnect from your current ssh session by typing CTRL+D or just exiting the terminal. Then reconnect to your droplet with the new credentials. You should now see the following input:

[email protected]_DROPLET_NAME:~#

A small step for a human, a giant leap for NKN! Now we can continue installing Go and configuring our miner.

3. Installing newest version of Golang

By default Debian 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=`curl | grep linux-amd64 | sort --version-sort | tail -1 | grep -o -E "[0-9]+\.[0-9]+((\.[0-9]+)?).linux-amd64.tar.gz"`

Download the file:

wget ${url}

Extract go environment to /usr/local — The sudo password is the same password as for the nkn user:

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 droplet 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

Clone the NKN repository:

git clone

Change directory to new folder:

cd nkn

Install glide package management:

make glide

Download dependencies for building

make vendor

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. Testnet 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.testnet.json config.json

and you’re done!

If you want to create a new wallet for NKN type:

./nknc wallet -c

choose a password and store all of your data on a safe place.

If you already got a wallet on another machine just copy the wallet.dat with a sftp-client (same credentials as ssh) to /home/nkn/go/src/ .

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 your node has connected properly you can terminate it by pressing CTRL+C because there is one last thing to do: Configure your Droplet to be completely Plug’n’Play — autostart on system load and restart on crash.

7. Plug’n’Play Droplet

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/nkn/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 droplet and you’re done!

sudo reboot

Now you can lean back and enjoy your new automated miner — A true New Kind of Miner — all on a DigitalOcean Droplet!

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]_DROPLET_NAME:~#

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/

git fetch &>/dev/null

LOCAL=$(git rev-parse HEAD)
UPSTREAM=$(git rev-parse @{u})

if [ $LOCAL != $UPSTREAM ]
systemctl stop nkn.service;
git merge;
make deepclean;
make glide;
make vendor;
chown -R nkn:nkn $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

and we’re finished with this file.

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. Then append the following line to the end of the file:

00 12 * * * /home/nkn/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 — all on a DigitalOcean Droplet!


Email: [email protected]








NKN Mining FAQ
求助:win10 x86 i386的程序不会安装