This guide will show you how to setup Mercury. All the steps here use Ubuntu 20.04 LTS.
Mercury can be built from source, or a precompiled binary can be used. Then the database tables must be setup, and Mercury will need to be configured. Finally, you will need to start Mercury.
Install basic dependencies.
apt install build-essential postgresql git wget curl libssl-dev pkg-config clang
Install Rust using rustup
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Clone the repository and checkout the tag of the version you intend to use. Using the dev or main branches may not be stable, so a tag is always recommended.
git clone https://github.com/nervosnetwork/mercury.git
cd mercury
git checkout v0.4.4
cargo build --release
The resulting binary will be target/release/mercury
.
Install basic dependencies.
apt install postgresql git wget curl
We will not be building from source, but there are still some valuable files. Cloning the repository is the easiest way to get everything we need. Make sure to checkout the tag that matches the version of the release you downloaded.
git clone https://github.com/nervosnetwork/mercury.git
cd mercury
git checkout v0.4.4
wget https://github.com/nervosnetwork/mercury/releases/download/v0.4.4/mercury-x86_64-unknown-linux-gnu.tar.gz
tar xzf mercury-x86_64-unknown-linux-gnu.tar.gz
Switch to the postgres
user and launch psql
as an administrative user.
sudo su -l postgres
psql
After launching psql
use the following SQL commands to create a user and database.
CREATE USER mercury WITH ENCRYPTED PASSWORD 'mercury';
CREATE DATABASE mercury;
GRANT ALL PRIVILEGES ON DATABASE mercury TO mercury;
You can then quit psql using \q
and then use exit
to return to the previous user.
Use psql
to
psql -h localhost -U mercury -f devtools/create_table/create_table.sql
Configuration files are available for the mainnet and testnet.
# mainnet
nano mercury/devtools/config/mainnet_config.toml
# testnet
nano mercury/devtools/config/testnet_config.toml
Many configuration options are available, but the options below must be changed.
Modify the database settings to match those you configured. Make sure that the port
matches your configure PostgreSQL port (default: 5432).
db_type = "postgres"
db_host = "127.0.0.1"
db_port = 5432
db_name = "mercury"
db_user = "mercury"
password = "mercury"
If you are running a CKB node on the same machine it will not need to be updated. Update as needed.
ckb_uri = "http://127.0.0.1:8114"
By default, Mercury will listen for local connections only.
listen_uri = "127.0.0.1:8116"
If you need Mercury to listen for connections from other machines, change it to the following.
listen_uri = "0.0.0.0:8116"
Running a binary you compiled from source.
target/release/mercury --config devtools/config/testnet_config.toml run
Running a precompiled binary.
./mercury --config devtools/config/testnet_config.toml run
Viewing the Mercury logs.
tail -f free-space/testnet/log/mercury.log