setup morpheus network validator node vps

Setting Up and Maintaining a Morpheus.Network VPS Masternode: The Ultimate CLI Guide

picture of author thomas cosiallsThomas Cosialls
linkedin-logogithub-logowebsite-logo

If you've ever been intrigued by the world of blockchain and wanted to dive deeper, you're in the right place. Today, I'll guide you through setting up and maintaining a Morpheus Network validator node on your VPS using CLI commands. Don't worry; I've got you covered, even if you're a beginner!

Introducing the Morpheus.Network Project

morpheus network logo

Morpheus.Network is a groundbreaking blockchain platform designed to optimize and automate global supply chain operations. With a primary focus on digitization, the platform aids businesses and government organizations in eliminating barriers that hinder efficient supply chain processes.

By leveraging the power of blockchain technology, Morpheus Network not only ensures secure and transparent transactions but also addresses complex challenges associated with legacy supply chain systems. The project's commitment to fostering effective, equitable, and streamlined global trade solutions positions it as a frontrunner in the blockchain-powered supply chain revolution.

What you need to participate in the Masternode program

The conditions to get the 18% APY rewards in the Beta Masternode program are simple: staking 1800 MNW tokens and then maintaining a 99% uptime for your node during the staking phase.

I won't dwell on that step in that article, but you can basically buy MNW on Ethereum using Uniswap and then use the official Polygon bridge to send them to Polygon.

You can have a look to the first two parts of this video for detailed instructions.

The guided path to build your Masternode on a VPS

1. Setup and Secure your VPS on DigitalOcean

You can get a DigitalOcean droplet (VPS) for as low as 4$ for 1G RAM, 10GB of disk space, and Ubuntu 22.04 as a Linux distribution. This is enough at the moment to run one masternode. If you intend to run several masternodes, you can upgrade to the 6$ droplet; it currently works perfectly for me with 2 active masternodes.

Read this beginner article to set up your VPS on DigitalOcean and configure SSH access to it.

Then, I can only strongly recommend you to make sure you go through all the steps in this article to secure your VPS before starting. You need a 99% uptime to be eligible for MNW rewards, it all starts with basics security precautions!

2. Install npm and nvm

Once you're in your terminal, connect first with your admin user (non root):

su newadmin cd ~

You can read this article to create a new user with admin rights.

Let's begin by installing npm. Simply type in:

sudo apt install npm

You might be prompted for permission as the npm installation will use some space. Just type 'Y' and hit enter.

NVM (Node Version Manager) is essential as it serves as the engine running the CLI. To install it, use:

curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash source ~/.bashrc nvm install v14.21.2

Ensure you enter the node version is set to 14.21.2 by typing nvm ls.

3. Install and start TrustMNW CLI Daemon

With npm installed, it's time to fetch the MNW package. Enter the following command:

npm install @morpheusnetwork/trustmnw-cli -g

Once the installation is complete, you can view a list of useful commands with:

trustmnw-cli help

To start your masternode daemon, log in into the TrustMNW using:

trustmnw-cli login

Enter your email when prompted, and you'll receive a verification code. Input the code, and the Daemon will start. You can check its status with:

trustmnw-cli status

If your node is running, a similar message will be blinking:

✓ Daemon running with PID: 111111 Account: youremail@email.com Wallet: 0x25CbC56e1D205036E3cf8fe08a6EcD62c1 Status: connected Node: staked Node Address: 0x444466bE137d11c84e217065c84562C04D453A3

To exit, just type CTRL+C. No worries, it won't stop the daemon. To stop it, type:

trustmnw-cli logout


4. Stake your MNW tokens on the TrustMNW Dashboard

Once you got your precious 1800 MNW tokens, head to the TrustMNW dashboard. Sign up, login with email, connect your wallet (forget about Metamask and use Rabby instead!) and you should land on this screen:

trustmnw finish setup

Click "Ready to stake". Then, click "Setup Active Node":

trustmnw setup active

You will be prompted to enter an invitation code. If you are not on the waiting list yet, click the link to request an invitation code. Be patient, you will receive the invitation code on your email within 24h. Once you get it, go back to that screen, and select the number of nodes you are going to run depending on your amount of MNW tokens.

trustmnw place stake

After clicking "Continue", you will be able to visualize the dashboard of your masternode, with the Active Node status. Wait a few minutes and you will start getting some statistics in the Uptime section. Congrats!

trustmnw dashboard

4. Ensure 100% Uptime with Auto-restart Script

You have done a great job so far but stay focus, this is probably the most important part of this tutorial!

So... your node is now active on your great secured DigitalOcean VPS. In a perfect world, you would passively observe the Current Earnings go up every day smoothly. Unfortunately our little daemon can be quite stubborn some time and one day, it will stop running without any prior notice! You won't get any alert from DigitalOcean since it has nothing to do with the health of your VPS.

We need to use the power of Cron jobs coupled with a specific bash script to restart our daemon whenever it goes down. First thing first, let's create that bash script (make sure you are connected as the non root user) :

cd ~ mkdir script && cd script nano mnwdaemonstart.sh

Copy paste that content in the text editor:

#! /bin/bash #check if node is running if [ $(ps -e -o uid,cmd | grep $UID | grep node | grep daemon.js | grep -v grep | wc -l | tr -s "\n") == 0 ] then # Load nvm export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" nvm use default date >> log.txt 2>&1 ${HOME}/.nvm/versions/node/v14.21.2/bin/trustmnw-cli restart >> log.txt 2>&1 fi

Save and exit with CTRL+S, CTRl+X, CTRL+O (Windows) or Control+X, then Y (Mac).

Let's change the access rights of the script to make it executable:

chmod +x mnwdaemonstart.sh -v

Then, let's create a Cron job to execute the file every minute:

* * * * * ${HOME}/script/mnwdaemonstart.sh >>${HOME}/script//log.txt 2>&1

Save and exit again as before. Finally type:

source ~/.bashrc

You can test if it works well by manually stopping the trustmnw-cli with:

trustmnw-cli stop

trustmnw-cli status should display the blinking message again after a minute!

5. Bonus: script to automatically check for required updates

Let's create a script that will help us know quickly if there is anything to update (npm or trustmnw-cli). Type the following in the terminal:

sudo nano ./latest.sh

Copy paste that content:

#!/bin/bash clear echo Checking current trustmnw-cli version trustmnw-cli --version echo echo echo Checking latest trustmnw-cli version npm view @morpheusnetwork/trustmnw-cli@latest version echo echo echo Checking current npm version npm -v echo echo echo Checking latest npm version npm show npm version echo ------------------------------------------------------------------------- echo "Update npm: npm install -g npm (do not install 10.0.0+ version of npm)" echo "Update trustmnw-cli: npm install -g @morpheusnetwork/trustmnw-cli@latest" echo -------------------------------------------------------------------------

Save and exit like explained before and make the script executable:

chmod +x ./latest.sh

That's it! Now when you type ./latest.sh in your terminal you will know if there are any available updates required for your masternode:

update script

Conclusion

That's it! You've successfully set up a Morpheus Network validator node on your VPS. If you face any challenges, remember, the blockchain community is always here to help. Reach out, learn, and grow. Cheers!

Credits

https://www.youtube.com/watch?v=0wsNnpHtH8s

https://docs.google.com/document/d/1GS4femARdagjiYgfHU7qgaOZQxMN9XF5IgAns5vaGdo/edit

https://news.morpheus.network/trustmnw-masternodes-new-cli-version-walkthrough-17507070393