How to install and configure a Waves Platform full node and payout scripts

WavesGo
WavesGo
Sep 15, 2018 · 7 min read

This article was originally posted on cryptin.eu with the hope to encourage fellow Wavesters to set up a node and help us further decentralizing the network. We rewarded this post with a contribution from our WavesGo Education Fund.

In this extensive guide I will go through how to install and configure a Waves Platform full node and to configure the payout scripts for the payments to lessors. Also some known errors and workarounds will be discussed. Links to other documentation and guides are also included in the end of this article.

Server and OS I used:

Ubuntu 18 VPS

3 cores

4GB RAM

150GB SSD

All commands are issued as root. If you do not use your root account most commands would probably require ‘sudo’ to work. Eg. “sudo apt update”.

After installation of the Ubuntu OS is complete, login with the root account (or a user account and use sudo).

Commands

Step 1
Update all packages to the latest one.
Command:
apt update

Step 2
Add extra functionality and software to Ubuntu (it could already be installed on some occasions)
apt install -y software-properties-common
apt install -y build-essential
apt install -y nano

Step 3
Install Java development kit (I use openjdk but this one is recommended).
sudo add-apt-repository -y ppa:webupd8team/java
sudo apt update
sudo apt -y install oracle-java8-installer

Check if you have the latest version (openjdk 10.0.2 2018–07–17 at time of writing)
java –version

Step 4
Download the latest fullnode from Waves repository.

Link: https://github.com/wavesplatform/Waves/releases/

Command:
wget https://github.com/wavesplatform/Waves/releases/download/v0.14.4/waves_0.14.4_all.deb

Step 5
Install the downloaded .deb file:
dpkg -i waves_0.14.4_all.deb

Step 6
Create a new Waves wallet either on;
https://waveswallet.io/ (contains encoded base 58 seed)

or

https://wavesplatform.com/ (does not contain encoded base58 seed) You can encode your seed yourself by using a base58 encode tool.

Store credentials of your new wallet in a safe place.

Step 7
Open the Waves config file with an editor like nano or vim (usually /usr/share/waves/conf/waves.conf)

Command:
nano /usr/share/waves/conf/waves.conf

Step 8
Configure waves.conf

Remove the comment from node name by deleting the #

Example:
# Node name to send during handshake. Comment this string out to set random node name.

node-name = “waves.cryptin.eu”

Set the declared address to the external IP address of your node:

Example:
# String with IP address and port to send as external address during handshake. Could be set automatically if uPnP is enabled.

declared-address = “200.200.200.200:6868”

Set your wallet settings (set a local password and use the base58 string of your wallet.

# Wallet settings
wallet {
# Password to protect wallet file
password = “FILL_IN_LOCAL_PASSWORD_HERE”

# Wallet seed as BASE58 string
seed = “yourbase58stringofyourwallethere_thisis_a_very_long_string”
}

Set your node REST API.
Change “enable = no” to “enable = yes”

Set bind address to your IP (this could also be your internal IP if you’re not connecting from the outside)

Example:
# Node’s REST API settings
rest-api {

# Enable/disable node’s REST API
enable = yes

# Network address to bind to
bind-address = “200.200.200.200”

# Port to listen to REST API requests
port = 6869

# Hash of API key string
api-key-hash = “API KEY HASH HERE”
}

Set features you wish to support by voting for it (if there’s a vote ongoing).
features {
supported = [4, 5, 6, 8] }

Step 9
Make sure the Waves node starts automically as the server boots
systemctl enable waves.service

Start the Waves node
service waves start

Watch the Wavesnode log live (press ctrl+c to cancel)
journalctl -u waves.service -f

The Waves node is now downloading the blockchain. This process could take quite some time. Once you see the Blockheight is the same as on https://wavesexplorer.com/ you are fully synced.

Check if your node is showing up at (use ctrl+f to find your IP)
http://dev.pywaves.org/nodes/

Step 10
Set api-key-hash. The password is the password you used in # Wallet settings. You can replace ‘localhost’ with your IP if the command is not working.

You can find your API key hash by issueing the following command:
curl -X POST –header ‘Content-Type: application/json’ –header ‘Accept: application/json’ -d ‘YOURPASSWORDHERE’ ‘http://localhost:6869/utils/hash/secure’

Open waves config and set API key hash:
nano /user/share/waves/conf/waves.conf

# Hash of API key string
api-key-hash = “API KEY HASH HERE”
}

Restart Waves node:
service waves restart

DONE! Your Waves Platform full node is up and running. I you want to better security for your node I encourage reading: https://medium.com/wavesgo-educationfund/how-to-configure-your-server-for-a-secure-waves-node-58558bec02f1

Starting, restarting, stopping or get the status of the node:

  • service waves start
  • service waves restart
  • service waves stop
  • service waves status

Setting up Waves Platform full node payout scripts

Step 1
Install nodejs and npm
apt install nodejs npm

Step 2
Create a node_module directory
mkdir node_modules

Step 3
Install npm and dependencies
npm install

Check nodejs and npm versions (I currently use nodejs v8.10.0 and npm 6.2.0)
nodejs -v
npm -v

Step 4
Getting the payout scripts
Hawky’s payout scripts
https://github.com/jansenmarc/WavesLPoSDistributer

W0utje’s fork of Hawky’s payout scripts (includes automated MRT distribution and generates html file)
https://github.com/w0utje/WavesLPoSDistributer

Git clone the repository or download the scripts you wish to use.
You can use wget to get the link of the zip file by clicking Clone or download -> rightclick Download ZIP -> Copy linkaddress

Then issued the command:
wget (insert link of zipfile here)

Unzip the zipfile
unzip master.zip

Step 5
Now we need to setup the scripts for your node. There’s an extensive readme. You can open it with:
less README.md (press q to close again)

If you’re lazy or do not understand the readme this is the way to go (I used W0utje fork of Hawky’s scripts);

Open appng.js with
nano appng.js

  • Set address to the address of your node
  • Set startBlockHeight to the height of the block before you got your first lease.
  • Set endBlock to the last block you wish to use for payout
  • Set distributableMrtPerBlock to the amount of MRT you wish to payout per block mined
  • NOTE: Waves only pays MRT for the first 70 blocks you mine. Check the payment before overpaying!
  • Set filename to the filename you wish to give your payment file
  • Set paymentid to the number of the payout it is (1, 2, 3 etc.)
  • Set node to the IP address of your node (internal or external depends on settings in wave.conf)
  • I commented out assetFeeId: by using // because this is no longer necessary with sponsored transactions. I also removed all lines with assetFeeId further along in the file but you can also just leave it here.
  • Set feeAmount: 100000,
  • Use a base58 encoder to set your payment attachment (message). Copy the base58 string of the message you want here.
  • Set percentageOfFeesToDistribute to the amount of Waves (percentage) your wish to distribute to lessors

Example
var config = {
address: ‘yourWavesAddressofyournode’,
startBlockHeight: 1154538,
endBlock: 1164700,
distributableMrtPerBlock: 9.6, //MRT distribution
filename: ‘payment’, //.json added automatically
paymentid: “2”,
node: ‘http://200.200.200.200:6869’,
//assetFeeId: “5BK9HPKmSkxoMdqvDzneb2UaW2NzDRjoMpMvQWfB4NcK”,
feeAmount: 100000,
paymentAttachment: “mXtED5Hg4Lv6QMzeVeWA1NyQMWQj29GtxYstSRXEaujKnxRLVTArhfz77FdkkwV8kBHY6UgJnF2K57i”, // thx 4 leasing 2 cryptin.
percentageOfFeesToDistribute: 90
};

Step 7
You can now execute the script and generate a payment file with:
nodejs appng.js

Step 8
Check if the payment is correct by editting and running checkpayout.js.

Step 9
Run the payout by editting and running massPayment.js

In the file the “apiKey” should be the password you stated in waves.conf in plain text.

Known issues
If the scripts runs at fist but quits with an error its most likely because the server runs out of RAM. You can tackle this problem with several workarounds;

Workaround 1
Issue the nodejs command with some parameters. Increase stack size and issue 4096 MB of RAM to nodejs.

nodejs –stack-size=65536 –max-old-space-size=4096 appng.js

Workaround 2
Set startblockheight higher in appng.js (if you had no prior leases)

nano appng.js

Edit variable:
var currentStartBlock = 1146000;

Workaround 3
Configure more swapspace (not recommended because this slows down performance of node)

fallocate -l 4G /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
swapon -s
echo “/swapfile none swap sw 0 0” >> /etc/fstab

Workaround 4
Stop your node to free up RAM and use another node to connect to for calculating the payout.

Edit appng.js config and set:

node: ‘http://OTHER_NODE_IP_HERE:6869’,

Upgrading Waves node to newer version

Step 1
You can either download the blockchain binary provided by Waves or resync the blockchain. I chose to download the blockchain binary to speed up the process.

Download blockchain binary (link is the one used for the 0.14.4 release)
wget http://blockchain.wavesnodes.com/mainnet-1164473

Step 2
Get new Waves Node executables in deb file;
wget https://github.com/wavesplatform/Waves/releases/download/v0.14.4/waves_0.14.4_all.deb

Step 3
Make a backup of your waves config to your homefolder file just to be sure:

cd /usr/share/waves/conf
cp waves.conf ~
cd ~

Step 4
Stop Waves node:
service waves stop

Step 5
Install latest version of node:
dpkg -i waves_0.14.4_all.deb

If you need to resync the entire blockchain because this is mandatory (skip this step otherwise);
Another possibility is to resync the entire
blockchain from scratch.

Step 6
Remove waves data folder;
rm -rdf /var/lib/waves/data

Move blockchain binary from where you downloaded it to to /usr/share/waves:
mv mainnet-1164473 /usr/share/waves/

Import blockchain to your Waves node:
sudo -u waves importer /etc/waves/waves.conf /usr/share/waves/mainnet-1164473

Remove blockchain binary file (;
rm /usr/share/waves/mainnet-[some height]

Step 7
Start Waves node
service waves start

Check if Waves node is running and syncing the last blocks;
journalctl -u waves.service -f

Links and documentation

Setting up a Waves Platform full node on digital ocean by the Applicationist
https://www.youtube.com/watch?v=CDmMeZlzKbk

Official Documentation
https://docs.wavesplatform.com/waves-full-node/how-to-install-a-node/how-to-install-a-node.html

https://docs.wavesplatform.com/waves-full-node/how-to-configure-a-node.html

Setting up additional security
https://medium.com/wavesgo-educationfund/how-to-configure-your-server-for-a-secure-waves-node-58558bec02f1

Waves explorer
https://wavesexplorer.com/

PYwaves
http://dev.pywaves.org/nodes/

Hawky’s payout scripts
https://github.com/jansenmarc/WavesLPoSDistributer

W0utje’s fork of Hawky’s payout scripts (includes automated MRT distribution and generates html file)
https://github.com/w0utje/WavesLPoSDistributer

Hoshingens fork from w0utje’s payout script (only Waves as fee, other tokens no longer in payout)
https://github.com/Hoshingen/WavesLPoSDistributer

WavesGo EducationFund

Submissions to the WavesGo Education Fund. Articles aiming at educating the Waves Community, written by Community members

WavesGo

Written by

WavesGo

Making blockchain accessible to the masses. WavesGo.com is the official Waves blockchain explorer & biggest Waves Mining Pool.

WavesGo EducationFund

Submissions to the WavesGo Education Fund. Articles aiming at educating the Waves Community, written by Community members

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade