How to Run Your ADAMANT Node on Ubuntu.

How to Run Your ADAMANT Node on Ubuntu.
This manual will assist in how to install, run and update an ADAMANT node on Ubuntu. You can try other Linux-based systems also, but they have not been tested.

If you want to run an ADAMANT node on Windows or Mac using Docker, please see the instructions.

Pre-reqs

You need pre-installed Virtual Machine (VM) with installed Ubuntu 16.04 LTS.

Options to get Ubuntu:

  • Any cloud service such as: DigitalOcean, OVH, Hetner, Scaleway, ArubaCloud. Almost all of these providers allow you to create a Virtual Machine in seconds.
  • VM application on Windows or Mac (Vmware, VirtualBox or anything else) with Ubuntu image installed.
  • A computer with Ubuntu installed.

Machine should have:

  • 1 GB RAM (Recommended 2 GB RAM).
  • 10 GB disk-space (less or more, depends on current block Height).

Updating OS and system packages

1) Reach your Ubuntu terminal. Admin permissions needed.

First, run your VM with Ubuntu or reach it using SSH (using SSH client like PuTTY), if cloud-service is used.

2) Upgrade your system by entering the following command:

sudo apt-get update && sudo apt-get upgrade

When asked, type y for confirmation. It may take a few minutes.

Installing prerequisites

1) Install python, git, and more:

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

2) Install Node.js:

curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash - && sudo apt-get install -y nodejs

3) Install PostgreSQL (version 9.6.2)

Add repository and repository 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 package list and install postgresql:

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

4) Install PM2 — node process manager:

sudo npm install -g pm2

5) Create new OS user.

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

adduser adamant

When prompted, type password for this user. You can leave empty all of the additional fields for user.

sudo usermod -aG sudo adamant
su - adamant

Installing ADAMANT node

1) Create database (DB) user and databases.

This command creates DB user with same as current OS user (adamant is this sample) and DB with name adamant_main.

sudo -u postgres createuser --createdb $USER && createdb adamant_main

Finally grant user privileges to create databases.

mportant! Change ‘pass123’ with other password.

sudo -u postgres psql -d adamant_main -c "alter user "$USER" with password 'pass123';"

2) Install ADAMANT node

Then, clone ADAMANT repository and install dependencies:

git clone https://github.com/Adamant-im/adamant
cd adamant
npm install

3) Make ADAMANT config changes.

nano config.json

Change DB credentials. In this example we need to change only DB password.

Change consoleLogLevel to error to check if everything alright.

To save changes, press F2, y, Enter.

Enabling API for applications

Enabling API for applications, you allow ADAMANT Messenger apps to connect to your node for sending and retrieving messages and for other functions.

is very important to support decentralisation. More nodes allowing API means more stable, anonymous and reliable messaging infrastructure.

It is a necessary step if you running a node in order to protect your anonymity. After that, you can choose this node in application settings.

To enable API for applications, run

nano config.json

Change public parameter in api/ access subsection.

To save changes, press F2, y, Enter.

If your node is already started (you’ve done with Running ADAMANT node section), then restart your node:

pm2 restart adamant

To check if API enabled, open link in browser (node should be run already):

http://:36666/api/blocks/getHeight

You should change from 80.211.177.181 to your node’s IP and protocol (if necessary). Sample is http://80.211.177.181:36666/api/blocks/getHeight

Validating if the node is installed correctly

To test that ADAMANT is built and configured correctly, run the following command:

node app.js

Normally you’ll see errors, only notices.

Once the process is verified as running correctly, press CTRL+C to return to command line.

Running ADAMANT node

Start the process with pm2. This will fork the process into the background and automatically recover the process if it fails.

pm2 start --name adamant app.js

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. Status should be online.

Stopping ADAMANT node

If you need to make changes, f. e., for updating a node, use this instructions to stop your node.

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

pm2 stop adamant

Your ADAMANT node installation is complete!

Validating node is connected to ADAMANT blockchain

Go to https://explorer.adamant.im/networkMonitor from any computer.

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

If you just installed your node, Height will be 1 — it is likely in sync process. It can take up to 1 day or more, depending on your connection and CPU.

To check the Height of your node, use command:

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

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

Updating ADAMANT node

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

Choose your adamant user.

su — adamant
cd adamant

Save config file, then update ADAMANT node, and edit Node version number in config:

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

Editor for config.json will be run, where you should change “version” to actual:

To save changes, press F2, y, Enter.

And finally re-start ADAMANT node:

pm2 restart adamant

Suggest:

Data Mining Tutorial For Beginners || Data Mining with Orange

The BEST Blockchain/Web 3.0 Project Ideas - For Developers

Blockchain Applications and Its Future

NodeJS vs PHP | Which is best for beginners

Web Scraping with Puppeteer in 10 minutes - IMDB Movie Scraping NodeJs

Scraping Reddit with Puppeteer & NodeJs - Pagination Handling