Deploy Htmlcoincore Node

Web Server

with Explorer and RPC API

Server Setup on Ubuntu 20.04 LTS

SSH into the server

ssh USER@URL

Create new sudo user

adduser NEWUSER

usermod -aG sudo NEWUSER

su - NEWUSER


Add Swap Space

free -h

df -h

sudo fallocate -l 4G /swapfile

ls -lh /swapfile

sudo chmod 600 /swapfile

sudo mkswap /swapfile

sudo swapon /swapfile

echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab


Install Nginx

sudo apt update

sudo apt upgrade

sudo apt install nginx

sudo ufw allow 'Nginx Full'

sudo ufw allow 'OpenSSH'

sudo ufw allow 4888

sudo ufw enable

Secure Nginx with HTTPS

sudo apt-get update

sudo apt-get install python3-certbot-nginx

sudo nano /etc/nginx/sites-available/default


server_name DOMAINURL;


location / {

proxy_pass http://localhost:8000;

proxy_http_version 1.1;

proxy_set_header Upgrade $http_upgrade;

proxy_set_header Connection 'upgrade';

proxy_set_header Host $host;

proxy_cache_bypass $http_upgrade;

}

location /api {

proxy_pass http://localhost:8000/api;

proxy_http_version 1.1;

proxy_set_header Upgrade $http_upgrade;

proxy_set_header Connection 'upgrade';

proxy_set_header Host $host;

proxy_cache_bypass $http_upgrade;

}

sudo nginx -t

sudo systemctl restart nginx.service

sudo certbot --nginx -d DOMAINNAME

Install node.js

cd ~

curl -sL https://deb.nodesource.com/setup_12.x -o nodesource_setup.sh

sudo bash nodesource_setup.sh

sudo apt install nodejs

sudo apt install build-essential

Install nvm

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash


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" # This loads nvm


Install mongo database

wget -qO - https://www.mongodb.org/static/pgp/server-5.0.asc | sudo apt-key add -


echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/5.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-5.0.list


sudo apt-get update

sudo apt-get install -y mongodb-org

sudo systemctl start mongod

sudo systemctl enable mongod


Install Dependencies

Ubuntu 18 - sudo add-apt-repository ppa:bitcoin/bitcoin

Ubuntu 20 - sudo snap install bitcoin-core


sudo apt-get install libzmq3-dev gcc g++ build-essential libtool autotools-dev automake pkg-config bsdmainutils python3 libgmp3-dev libdb5.3-dev libdb5.3++-dev screen libssl-dev libevent-dev libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-test-dev libboost-thread-dev autotools-dev automake libtool pkg-config python-is-python3


Deploy Htmlcoind

git clone --recursive https://github.com/htmlcoin/htmlcoin.git --branch=htmlinfo

cd htmlcoin/depends/

make

git submodule update --init --recursive

cd ..

./autogen.sh

./configure --disable-shared --enable-cxx --enable-static --enable-bitcore-rpc --prefix=`pwd`/depends/x86_64-pc-linux-gnu --without-gui --without-miniupnpc

make clean

make

Install htmlcoincore-node

nvm i v6

npm install -g https://github.com/denuoweb/htmlcoincore-node.git#master

htmlcoincore-node create mynode

cd mynode

htmlcoincore-node install https://github.com/denuoweb/htmlcoin-api.git#master

htmlcoincore-node install https://github.com/denuoweb/htmlcoin-explorer.git#master


Edit htmlcoincore-node.json

sudo nano htmlcoincore-node.json


{

"network": "livenet",

"port": 8000,

"services": [

"htmlcoin-api",

"htmlcoin-explorer",

"htmlcoind",

"web"

],

"servicesConfig": {

"htmlcoind": {

"spawn": {

"datadir": "/home/USER/.htmlcoin",

"exec": "/home/USER/HTMLCOIN/src/htmlcoind"

}

},

"htmlcoin-explorer": {

"apiPrefix": "api",

"routePrefix": ""

},

"htmlcoin-api": {

"disableRateLimiter": true,

"routePrefix": "api",

"db": {

"host": "127.0.0.1",

"port": "27017",

"database": "htmlcoin-explorer",

"user": "",

"password": ""

},

"erc20": {

"updateFromBlockHeight": 0

}

}

}

}


Edit ~/.htmlcoin/htmlcoin.conf

mkdir ~/.htmlcoin

nano ~/.htmlcoin/htmlcoin.conf


rpcuser=USERNAME

rpcpassword=PASSWORD

port=4888

rpcport=4889

rpcallowip=127.0.0.1

whitelist=127.0.0.1

zmqpubrawtx=tcp://127.0.0.1:28333

zmqpubhashblock=tcp://127.0.0.1:28333

server=1

txindex=1

addressindex=1

timestampindex=1

spentindex=1

addrindex=1

dbcache=8192

checkblocks=144

maxuploadtarget=1024

logevents=1

gen=0

maxconnections=500

rpcworkqueue=300

Run htmlcoincore-node on a screen session

screen -t htmlcoind -S htmlcoind

htmlcoincore-node start

CTRL-a + CTRL-d to exit the screen session