How to Run Your ADAMANT Node on Ubuntu

ADAMANT Messenger
Jun 13, 2018 · 8 min read

ADAMANT use Fair dPoS for making consensus in the blockchain system. To get more information on Fair dPoS and the advantages of running your own node, read .

This manual will explain to you how to install, run and update an ADAMANT node on Ubuntu 16 or 18. You can also try other Linux-compatible systems but they have not been tested yet. If you want to run an ADAMANT node on Windows or Mac using Docker, have a look at .

Note: Basic IT and Linux knowledge needed.

Pre-reqs

You need a pre-installed Ubuntu-compatible VM (Virtual Machine), version 16.04 LTS or 18.

Ways to get Ubuntu:

  • Any cloud service such as: DigitalOcean, OVH, Hetzner, Scaleway, ArubaCloud. Almost all of these providers allow you to create a Virtual Machine in no time.
  • VM application on Windows or Mac (VMWare, VirtualBox or anything else) with Ubuntu image installed.
  • Ubuntu-compatible PC.

Virtual Machine requirements:

  • 1 GB RAM (2 GB RAM recommended).
  • 10 GB disk-space (depends on current block Height).

Two ways of the installing ADAMANT node

There are two ways to install an ADAMANT node, the first way requires only a ready-to-go script and is suitable for first-timers. The second way requires control over the whole process and is suitable for advanced users.

If you are a first-timer, do the following

All you have to do after logging in is to run a simple Bash script:

bash -c "$(wget -O - https://adamant.im/install_node.sh)"

If you agree with the notification message, type “yes”, or abort the installation. After that, you need to set a new password for the database user and a password for the new system user.

Note: password characters are not visible during input.

Now you only have to wait for 7–15 minutes and it is all done.

Your node is running and configured. You can .

If you are an advanced user, do the following

1) Launch your Ubuntu terminal

Firstly, run your VM with Ubuntu or launch it using a SSH client like or for Windows. If you use GNU/Linux or OS X, type in ssh root@IP_address.

Note: Admin permissions needed.

2) Upgrade your system by entering the following command:

sudo apt update && sudo apt upgrade -y

If you will be asked like on picture below, press Enter for confirmation default configuration. It may take a few minutes.

3) Installing prerequisites.. Install python, git, etc.:

sudo apt install -y python build-essential curl automake autoconf libtool git

4) Install PostgreSQL (version 11.1)

Add the repository and its key:

sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" > /etc/apt/sources.list.d/pgdg.list' && wget -q https://www.postgresql.org/media/keys/ACCC4CF8.asc -O - | sudo apt-key add -

Update the package list and install postgresql:

sudo apt update && sudo apt install -y postgresql postgresql-contrib libpq-dev

Next few commands create DB user (e.q. adamant) and DB entitled adamant_main.

cd /tmpsu postgres -c psql
CREATE ROLE adamant LOGIN PASSWORD 'HardPass111';

I Note! Think of a new password instead of “HardPass111”.

CREATE DATABASE adamant_main;

Type \q to exit from psql

\q

5) Create new OS user

You can pick any username, this sample creates user adamant, and grants him the necessary permissions to choose.

adduser adamant

Then type а password and confirm. You do not have to fill in the additional gaps.

sudo usermod -aG sudo adamantsu - adamant

6) Install Node.js via nvm

When you login as adamant you can install nodejs.

wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash

Then, log out and login again

exit
su - adamant

To install nodejs v10.9, type the following

nvm i 10.9

7) Install PM2 — node process manager:

npm install -g pm2

8) Install an ADAMANT node

Then, clone the ADAMANT repository and install the following dependencies:

git clone https://github.com/Adamant-im/adamantcd adamantnpm i

9) Change the ADAMANT configurations

nano config.json

If nano editor is not installed, install it with command

sudo apt install nano

Change the DB credentials. Right now, according to the following example, we need to change only the DB password (“HardPass111” in this sample, change to yours one).

If you want to have access to some API commands in browser, change api/access/public to true.

Change consoleLogLevel to error to see if everything is alright.

To save changes, press F2, y, Enter.

10) Download ADAMANT Blockchain database image

It is not obligatory. To be honest, if you really want to support the decentralization, you should skip this step.

It saves time on node sync but you must completely trust the image. If you skip this step, your node will check every single transaction, which takes time (up for several days). However it proves the consistency of the Blockchain.

If you still want to proceed, you should stop the ADAMANT node:

pm2 stop adamant

Next download the image

wget https://explorer.adamant.im/db_backup.sql.gz

https://explorer.adamant.im/db_backup.sql.gz is the latest daily image by ADAMANT Team.

Unzip the image:

gunzip db_backup.sql.gz

Where db_backup.sql.gz is downloaded image file name.

Finally load the image into the node’s database:

psql adamant_main < db_backup.sql

Note: you must not run any nodes that you have registered before. Otherwise, you should create а new adamant_main database using dropdb and createdb commands.

Finally, it is all done and you can proceed further.

Enabling API for applications

If you did not enable API on step 9, you can do it any time.

API allows the ADAMANT messenger apps to connect to your nodes and send and retrieve messages.

It is very important to support decentralisation. The more nodes there are, the more anonymous and secure the messaging infrastructure becomes.

If you run a node in order to protect your anonymity, you have to enable API. After that, you can choose a node in the “Settings” section of messaging application.

To enable API for applications, run the following command

nano config.json

Change public parameter in api/ access subsection.

To save changes, press F2, y, Enter.

If your node is already running, then restart your node:

pm2 restart adamant

To check if API is enabled, open the following link in browser (your node should be active):

http://<IP>:36666/api/blocks/getHeight

You should change <IP> from 80.211.177.181 to your node’s IP and protocol (if necessary). For example,

Verifying your node is installed correctly

In order to check that ADAMANT is built and configured correctly, run the following command:

node app.js

Normally you willl see errors and notices.

Once you make sure that the process is running correctly, press CTRL+C to return to the command line.

Running ADAMANT node

To launch your ADAMANT node, use pm2. This will fork the process into the background. If the process fails, it will be recovered automatically.

pm2 start --name adamant app.js
cd

After the process is started, its run-time status and log location can be retrieved by issuing the following command:

pm2 show adamant

Use it anytime you want to see your Node status. It should be online.

Stopping ADAMANT node

If you need to make changes, e.g. for updating a node, use these instructions to stop it.

To stop ADAMANT after it has been started with pm2, issue the following command:

pm2 stop adamant

Verifying your node’s connection

In order to check if the node is properly connected to the messenger’s blockchain system, follow this link .

Find your node in the Nodes list by your node’s IP address. Please note, it may take up to several minutes for your node to appear on the list.

If you have just installed the node but it has not synchronized yet, its Height will be marked with “1”. It can take up to 1 day or more for the node to synchronize, depending on your connection and CPU.

To check the Height of your node, use the following:

curl -k -X GET http://localhost:36666/api/blocks/getHeight

When sync completes, Height will be the same as for other nodes.

Autostart ADAMANT node on system reboot

As it is a common issue that VPS provider may restart your machine, it it will be a good idea to add the ADAMANT node process in crontab. However, if you prefer to control the VPS manually, this step is not necessary.

Be sure to run commands under adamant user:

su - adamant

Next, open the crontab editor:

crontab -e

The choice of the editor depends on you. As for me, I prefer nano.

Add string to the end:

@reboot cd /home/adamant/adamant && pm2 start --name adamant app.js

Press Ctrl+x to exit editor, y to confirm saving file, Enter to save changes.

That’s it.

Updating your ADAMANT node

Firstly, check Stopping ADAMANT node section to stop your node.

Choose your adamant user.

su - adamantcd adamant

Save the configuration file, then update your ADAMANT node, and, finally, edit Node version in config:

mv config.json config3.json && git pull && mv config3.json config.json && nano config.json

When config.json opens, you should change the number of “version” to an up-to-date.

To save changes, press F2, y, Enter.

Update dependencies:

npm update

Now, you can restart your ADAMANT node:

pm2 restart adamant

What’s next?

You can become a Blockchain delegate, start forging, and receive rewards. If you are interested, have a look at the following article — .

adamant.im

Relax. You are safe now.

ADAMANT Messenger

Written by

The most secure and anonymous messenger, encrypted with Blockchain

adamant.im

Relax. You are safe now.