Holding NuShares comes with a responsibility : it is in your best interest to participate to the network by submitting your votes in each block you mint.
To maximise the impact of your votes and the reward that comes with staking shares, your Nu client should be minting 24/7. A cost-efficient solution is delegating the minting to a cheap Raspberry Pi connected to the internet : unlike VPS or cloud service you will keep control over your shares, and you can finally turn off your home computer. Thanks to Nu data-feeds, you can subscribe your raspberry to an external source and control your votes without need to access the pi all the time.
The Raspberry Pi is a cheap (~40$) and efficient device with enough computational power to let you mint.
In this minimal tutorial we will see how to setup a minting machine which is different from a full node. For security reasons full nodes and minting nodes should be kept separated.
NOTE : in the examples of this tutorial we used pico
as text editor, but feel free to use any other editor (nano, vi, etc …) .
Follow the the official tutorial to install an easy operating system installer which contains Raspbian. Login with your pi
user, and connect the raspberry to the internet.
$ sudo apt-get update
$ sudo apt-get upgrade
Following one of the many tutorials you can find online, for example this;
Enter $ sudo raspi-config
in the terminal, then navigate to ssh, hit Enter and select Enable or disable ssh server
.
Follow this tutorial, or if you know what you are doing simply run (on your machines)
$ cat ~/.ssh/id_rsa.pub | ssh pi@<IP-ADDRESS> 'cat >> .ssh/authorized_keys'
Edit /etc/ssh/sshd_config
$ sudo pico /etc/ssh/sshd_config
and make sure these three parameters are set to no
Restart SSH with $ sudo /etc/init.d/ssh restart
$ sudo apt-get install checkinstall subversion git git-core build-essential
$ sudo apt-get install libssl-dev libdb++-dev libminiupnpc-dev
$ sudo apt-get install libboost-dev libboost-system-dev libboost-filesystem-dev libboost-program-options-dev libboost-thread-dev libcurl4-openssl-dev
Don’t install libdb++-dev from repository
it might be newer than 4.8 and nud compiled with libdb > 4.8 converts .dat files in ~/.nu
to a format that is not compatible with official releases that use libdb4.8
Adjusted dependencies for compiling nud with libdb4.8:
this might take a while - even on RaPi2
$ sudo ln -s /usr/lib/libminiupnpc.so.5 /usr/lib/libminiupnpc.so.10
The build process can take long. If you want to skip it and get precompiled binaries instead, skip this section and go to the next.
$ cd ~
#Go to pi user’s home directory$ git clone https://bitbucket.org/JordanLeePeershares/nubit.git
#clone NuBits repository locally$ cd nubit
#Go to root repository directory$ git tag
#Retrieve a list of tags and find the most recent stable tag–the highest number without a suffix.$ git checkout v2.0.3
#Grab a stable version of the code (replace 2.0.1 with the results of the previous step if needed).$ cd src
#Go to source directory$ sudo dd if=/dev/zero of=/swapfile bs=64M count=16
#provide some extra swap partition to speed up compilation time$ sudo mkswap /swapfile
$ sudo swapon /swapfile
$ make -f makefile.unix
#Build nud. This command can take up to 2 hours, will produce an executable file : nud
$ strip nud
#Reduce file size by stripping symbols$ sudo mv nud /usr/bin/nud && sudo chmod a+x /usr/bin/nud
#move nud and make it executable$ sudo rm -r ~/nubit/
#Remove directory with sources (optional)$ sudo swapoff /swapfile
#clean up the previously initiated swap$ sudo rm /swapfile
You can download unofficial precompiled build maintaned by the Nu community. Read the disclaimer on this repository and download nud :
$ sudo wget https://github.com/desrever-nu/nu-raspberry-unofficial/raw/master/latest/nud
$ sudo mv nud /usr/bin/nud && sudo chmod a+x /usr/bin/nud
#move nud and make it executableNow that nud is ready, we need to configure it before executing it.
$ mkdir -p ~/.nu
#Create the data folder$ touch ~/.nu/nu.conf
#Create an empty configuration file$ pico ~/.nu/nu.conf
#Edit the nu.conf fileYour nu.conf shuold look like the example below :
After editing the config, make it read only :
$ sudo chmod 400 ~/.nu/nu.conf
The nu daemon will be listening to RPC messages on the port you specified. We highly suggest not to forward that port and leave the pi protected behing the NAT, for local usage only.
Now you will be able to access nud via CLI by typing nud
followed by the rpc command you want to invoke.
The first thing you want to do is starting the daemon and let it download the blockchain. This operation can take several hours - or even days - depending on connectivity.
$ nud -daemon
#will start your nu daemon , startup can take some minutes.It is possible that you get an error related to perl and your locale
settings. If you get this error, simply execute the following command that will write an export of your locale to the bash profile your locale
setting (in the example below being en_US,
but could also be en_GB
or something else).
$ echo export LC_ALL=en_US.UTF-8 >> ~/.profile
To check how the download of the blockchain is proceeding you can run
$ nud getinfo
and read the blocks
number growing while comparing it to the current height
on the block explorer. Be patient while the blockchain is being downloaded.
You can configure nud to automatically run on startup.
$ sudo pico /etc/rc.local
and add the following line immediately before the last line (exit 0
) :Save, exit pico and reboot the pi with
$ sudo reboot
and test if the daemon started automatically :
$ nud getinfo
You have three options to transfer NuShares to your raspberry :
$ nud listreceivedbyaddress 1 true
$ nud importprivkey <yourprivkey>
and clean up bash history right after with $ cat /dev/null > ~/.bash_history
to delete all tracesscp
. Execute this command from the machine where the existing wallet is hosted :$ scp local/path/to/walletS.dat pi@<pi.ip.address>:/home/pi/.nu
Unless you go with the the third option and imported an encrypted wallet, make sure to encrypt your wallet with a sufficiently complex passphrase
$ nud encryptwallet <passphrase>
After you have a working node encrypted and funded with NuShares, you need to unlock the wallet using your passphrase to allow minting. To unlock your wallet, type the command below, press enter, then type your passphrase, press enter again and finally Control+D:
$ nud walletpassphrase `cat` 999999999 true
Alternatively, you can use this bash script so you don’t have to remember the sequence above everytime.
Now you can use data-feeds to configure your vote, so everytime you mint a new block, you will participate to Nu democratic process. You have also the option to manually configure votes via CLI, but is not reccomended.
After you created your own datafeed or chose an existing datafeed to delegate your voting power to, this tutorial will teach you how to use data feeds from the daemon. For example, to subscribe to Cybnate’s data feed you can use the following command :
$ nud setdatafeed https://raw.githubusercontent.com/Cybnate/NuNet-datafeed/master/Cybnate-datafeed.json https://raw.githubusercontent.com/Cybnate/NuNet-datafeed/master/Cybnate-datafeed.txt ShTrp9wbgnhZudk4eYXtBtcMyeBziGzUpc
Double check if the feed is set correctly by running
$ nud getdatafeed
Congrats, your minting machine is ready!
You can now interact with your node using rpc commands.