NEXUS.IO BLOCKCHAIN 101 FAQs & GLOSSARY
Home

TECHNOLOGY

USER GUIDES

DEVELOPER GUIDES

FAQs & GLOSSARY

Setup a Nexus Testnet with Mining - Linux

This guide will help to set up a standalone nexus tesnet or join the nexus public testnet with mining. Mining is required to produce blocks on testnet as it mimics the mainnet. Testnet mining is very economical as the mining difficulty is very low.

Developers can connect their testnet node to the public testnet, which gives an opportunity to test dapps extensively on testnet before porting to the main net.

To set up a standalone testnet which will mint coins for testing, a minimum of two nodes are required with mining and after some coins are mined, they can be used to add staking to the testnet. The minted coins can be used to test dapps to mimic the mainnet and also distributed test coins to other testers. The two nodes will be set up similarly except for the connect flag in configuration which will refer to each other.

The testnet miner will use the CPU to mine the hash channel. Mining for testnet is very simple, economical and will use only a single worker with a single core CPU to make it as energy efficient as possible.

This guide assumes that each wallet and miner are on one computer, and works with the stable release 5.0.5. The steps below are given for one computer, and will have to be followed on the second one. The next version which is the Tritium++ will have a lot of changes related to API’s, but the setup process is the same.

Before beginning this guide, check the things needed:

  • Two computers with dual core CPU and 2GB RAM, with a good CPU cooler and case cooling. VPS also can be used.

  • Ubuntu server 20.04 LTS for AMD/IA64 (Use any linux distribution of choice, but this guide is tailored for ubuntu).

  • USB drive or SD card to install ubuntu.

  • Etcher – To burn the OS image file to USB/SD card.

Install Ubuntu or distro of choice, Follow the below commands, copy the commands and paste it in the terminal using keys CTRL+SHIFT+v

Update and upgrade the node:

sudo apt update; sudo apt upgrade -y

Open SSH port before enabling firewall (If using SSH):

sudo ufw allow ssh

Open ports for API, RPC and mining:

sudo ufw allow 7080/tcp sudo ufw allow 8336/tcp sudo ufw allow 8325/tcp

Enable firewall:

sudo ufw enable

Check firewall status:

sudo ufw status

Set timezone:

sudo dpkg-reconfigure tzdata

Change the hostname – Not compulsory if already set during the install:

sudo hostnamectl set-hostname <newhostname>

Reboot node:

sudo reboot

Installs the dependencies required for compiling nexus core CLI, It will take some time to complete depending on the internet speed.

sudo apt-get install -y build-essential libssl-dev libdb-dev libdb++-dev libminiupnpc-dev git

Download the latest nexus core source code, and should only take a few seconds to complete: (The Nexus master branch is linked to the merging branch. For stable build or specific builds refer to the github or contact telegram support)

git clone --depth 1 https://github.com/Nexusoft/LLL-TAO

Change into the source code directory:

cd LLL-TAO

Lastly run this command to compile from source. This begins compiling the nexus core, please be patient, as this can take a very long time depending on the CPU. Replace the 1 in ‘j1’to the number of cores / threads for compiling faster:

make -f makefile.cli -j1 AMD64=1

Will show “Finished building nexus” on a successful compile.

To set up the testnet the wallet needs to be configured properly. The wallet configuration is stored in the Nexus data folder under the user's home directory.

Create the Nexus hidden data folder:

mkdir ~/.Nexus

Create the nexus.conf file

nano nexus.config

Copy the configuration below and change the values to suitable values:

#Nexus testnet with Miner config- PLEASE CHANGE THESE TO SUITABLE VALUES
#Set RPC credentials
rpcuser=<username>
rpcpassword=<password>
#Set API credentials
apiuser=<username>
apipassword=<password>
#To enable API authentication for testing
apiauth=1
#To enable API remote access
apiremote=1
#To enable debug mode
debug=1
#To enable the daemon mode
daemon=1
#To accept incoming JSON-RPC commands
server=1
#User account settings credentials for auto login & auto create. Optionally create, login and unlock directly in the wallet.
username=<username>
password=<password>
pin=<pin>
autocreate=1
autologin=1
#Enable mining
mining=1
#Enable Staking
Stake=1
#The testnet flag defaults the API port to 7080, RPC to 8336 & mining port to 8325
testnet=1
#To connect to the Nexus public testnet. Disable for standalone node
#connect=node2.nexusoft.io
#To connect to another node on a local testnet
#connect=192.168.2.29
#To run as local node, disable for public node
nodns=1
#process notifications (incoming transactions) automatically in background process
processnotifications=1

To save the config file Ctrl+s & Ctrl+x

Install the dependencies (Only required if installing miner on a separate computer)

sudo apt install build-essential libboost-all-dev libdb-dev libdb++-dev libssl-dev libminiupnpc-dev libgmp-dev -y

Clone the NexusMiner repository

git clone --branch v1.1 https://github.com/Nexusoft/NexusMiner

Change into the source code folder

cd NexusMiner

To precompile the binary use cmake. (cmake version 3.19 or higher only) <pathtosource> is the path to the NexusMiner folder and <pathtobuildfolder> is the path to NexusMiner/build

cmake -S <pathtosource> -B <pathtobuildfolder> -DCMAKE_BUILD_TYPE=Release

To change into the prebuilt binaries folder

cd build

To compile use:

make

This will create the NexusMiner executable.

Cmake Problems

Nexus miner uses the latest version of cmake, if the system has a version lower than 3.19, then do the following

Go to the cmake downloads page (link below) and download the linux cmake script files with .sh extension

https://cmake.org/download/

cd Downloads
./<cmakefilename.sh>

cmake install

cmake install complete

First you will get the licence, use “Enter” to scroll down or “spacebar” to scroll to the end, accept licence and then accept the location to extract, which will install the cmake binarie. Change into the cmake/bin folder

cd cmake-3.21.2-linux-x86_64/bin/ - Change the camke folder name accordingly

Run cmake. <pathtosource> is the path to the NexusMiner folder and <pathtobuildfolder> is the path to NexusMiner/build

./cmake -S <pathtosource> -B <pathtobuildfolder> -DCMAKE_BUILD_TYPE=Release

cmake building the prebuilt make binaries

To change into the prebuilt binaries folder

cd ~/NexusMiner/build

To compile use:

make

NexusMiner compiling

This will create the NexusMiner executable.

For the proper functioning of the miner, it needs to be configured; create a configuration file named miner.conf in the same folder as the executable.

cd NexusMiner/build

Create the miner.conf file

nano miner.conf

Copy the miner configuration given below to the file, it uses the JSON format. Change the settings as per needs. Testnet mining will use the port 8325 as default. This config uses four workers, for a testnet just one worker can get the job done.

{
"wallet_ip" : "127.0.0.1",
"port" : 8325,
"local_ip" : "127.0.0.1",
"mining_mode" : "HASH",
"connection_retry_interval" : 5,
"get_height_interval" : 2,
"use_pool" : false,
"pool" :
{
"username" : "Nexus_payout_address_for_pool_mining_only"
},
"logfile" : "miner.log",
"stats_printers" :
[
{
"stats_printer" :
{
"mode" : "console"
}
},
{
"stats_printer" :
{
"mode" : "file",
"filename" : "stats.log"
}
}
],
"print_statistics_interval" : 10,
"workers" :
[
{
"worker1" :
{
"id" : "cpu1",
"mode" :
{
"hardware" : "cpu"
}
},
"worker2" :
{
"id" : "cpu2",
"mode" :
{
"hardware" : "cpu"
}
},
"worker3" :
{
"id" : "cpu3",
"mode" :
{
"hardware" : "cpu"
}
},
"worker4" :
{
"id" : "cpu4",
"mode" :
{
"hardware" : "cpu"
}
}
}
]
}

To save the config file Ctrl+s & Ctrl+x

This is a sample miner.config with one worker

For the miner to mine blocks, a user account is to be created, logged in and unlocked for mining, this also works to bootstrap a new network. Create two separate user accounts for the two nodes.

Start the wallet. Wait for a few minutes for the wallet to be loaded:

cd LLL-TAO
./nexus

If a user account is not configured, auto create and auto login in the wallet configuration, then create an user account, login and unlock for mining.

To create a new user account:

./nexus users/create/user username=<username> password=<password> pin=<pin>

Login to the user account:

./nexus users/login/user username=<username> password=<password> pin=<pin>

Unlock the user account for mining:

./nexus users/unlock/user pin=<pin> mining=1 notifications=1

Wallet started, create a user account , login and unlock for mining

Start the miner:

cd NexusMiner
./NexusMiner

Miner started with one worker - Blocks Accepted

Check the messages the miner prints out, every 10 secs there is a miner statistics printed on the screen (Time set in miner.config). Check for the “Submitting Block ...” and “Block Accepted By Nexus Network”

Warning- Block Rejected By Nexus Network

In the image above check the “Submitting Block ...” and “Block Rejected By Nexus Network”

Stop the miner:

Ctrl+c

Wallet- Check the mining info

To check the mining information on the wallet:

./nexus ledger/get/info - 5.1.0-rc1 and above
./nexus ledger/get/mininginfo - Below 5.1.0-rc1

To check the total wallet balance of the logged in user account:

./nexus finance/get/balances

To check the account details of the logged in user account:

./nexus finance.list/accounts

In account details the newly minted testnet coins are shown in the balance. These can be transferred similar to main net coins to other users for testing purposes

This is the two wallets and miners running side by side

Hope you enjoyed the guide!!