How to deploy Qtum quantum chain nodes

This tutorial covers the deployment, running, and RPC calls of Qtum quantum chains.

The tutorial assumes proficiency on the Linux,Mac, or Windows command line. If you do not meet this requirement, or are only interested in how to use the Qtum Qt wallet, please refer to another Qtum Wallet tutorial.

Get the Qtum node

You can get a Qtum node program in one of four ways:

1. Download the binary file directly

If you don’t care about the Qtum source code, the most convenient way to deploy the Qtum node is to download the latest binaries from the Qtum Release page (click open). Currently supported platforms include Linux, Windows, and OSX. You are advised to download the latest version. This tutorial uses v0.14.13 as an example.

(Note that the latest version you see may have a different version number, such as 0.14.13 here, and other strings remain the same.)

  • MacUsers can download:Qtum 0.14.13 - osx64. Tar. Gz
  • LinuxUsers can download:Qtum - 0.14.13 - i686 - PC - Linux - gnu. Tar. Gz(32-bit) orQtum 0.14.13 - x86_64 - Linux - gnu. Tar. Gz(64)
  • WindowsUsers can download:Qtum 0.14.13 - win32. Zip(32-bit) orQtum 0.14.13 - win64. Zip(64)
  • Raspberry pieUsers can download:Qtum 0.14.13 - arm - Linux - gnueabihf. Tar. Gz

Qtumd and qtum-cli are the qtum node executable files used in this tutorial.

2. Linux can be installed through APT

For a full tutorial, see github.com/qtumproject… , currently supported on Ubuntu, Debian and Mint.

Raspberry PI users can also install apt via github.com/qtumproject… .

After following the tutorial, you can call qtumd and qtum-cli directly from the command line.

3. Compile from source code

If you want to compile Qtum directly from source, you can download the latest source from Github: github.com/qtumproject… .

For detailed compilation methods, see github.com/qtumproject… . The best compiler platforms currently supported include Linux and OSX. Other platforms may have different dependency environments.

/ SRC: qtumd,qtum-cli

4. Obtain the QTUM image from Docker

Please refer to the official Docker tutorial for the installation and use of Docker. This assumes that the Docker environment is installed correctly.

The official image of Qtum on Docker Hub is Qtum/Qtum, which can be obtained by running the following command:

docker pull qtum/qtum:latest
Copy the code

The qTUM executable is obtained by the above method, where the node deployment and RPC calls are related:

  • qtumd: Qtum core program, namely the real Qtum full node program
  • qtum-cli: Qtum command line interface, can interact with the Qtum core program, to achieve local RPC calls

Deploy the Qtum node

Docker containers are used in a slightly different way, but the principle is the same. Please refer to another tutorial, How to run a Qtum node with Docker.

The following uses Ubuntu as an example to deploy the Qtum node. The Mac and Windows command lines are the same as the Linux command lines.

Run Qtum full node with./qtumd:

./qtumd -daemon
Copy the code

-daemon indicates the vxconfigd process. The -logEvents option can be added when running Qtumd if the user wants to view events related to the contract from the node (such as the records of sending and receiving QRC20 tokens, etc.).

For more options, run the following command:

./qtumd -help
Copy the code

End Run:

./qtum-cli stop
Copy the code

The default data path varies from platform to platform:

  • Linux:~/.qtum/
  • Mac OSX:~/Library/Application Support/Qtum
  • Windows:%APPDATA%\Qtum

If the default path is not empty for the first time, please clear it and then run the node (clear that delete all files in the path, clear attention to backup!). . The reader can also specify the data path with the -datadir option.

All blocks need to be synchronized during the initial run. The node run log path is ~/.qtum/debug.log.

Local RPC call

After the nodes are running properly, they can interact with each other through qTUM – CLI to implement local RPC calls. Such as:

Oldclock @ raven: ~ / qtum - 0.14.3 $. / bin/qtum - cli getinfo {"version": 140300,
  "protocolversion": 70016,
  "walletversion": 130000,
  "balance": 0.00000000."stake": 0.00000000."blocks": 12126,
  "timeoffset": 0."connections": 8,
  "proxy": ""."difficulty": {
    "proof-of-work": 1.52587890625 e-05,"proof-of-stake": 886731.5868738915},"testnet": false."moneysupply": 100028504,
  "keypoololdest": 1505186997,
  "keypoolsize": 100,
  "paytxfee": 0.00000000."relayfee": 0.00400000."errors": ""
}
Copy the code

To get a list of all RPC commands, run:

./qtum-cli help
Copy the code

To obtain instructions for RPC calls, run./qtum-cli help

, for example:

./qtum-cli help getinfo
Copy the code

RPC Call Setup

/qtum-cli help getInfo We can get instructions for implementing getInfo calls through jsonRpc:

Examples:
> curl --user myusername --data-binary '{" jsonrpc ":" 1.0 ", "id" : "curltest", "method" : "getinfo", "params" : []}' -H 'content-type: text/plain; ' http://127.0.0.1:3889/
Copy the code

The detailed format of the JSON message is given in the example, but it cannot be called by default. This parameter is available only after the RPC user name and password are configured. The setting method is as follows:

Method 1: Create a configuration file ~/.qtum/qtum

rpcuser=test  # RPC user name
rpcpassword=test1234  # RPC password
The preceding two items must be set. By default, only local RPC connections are allowed,
To implement remote calls, declare all allowed IP addresses by setting rpCallowIP
Both ipv4 and ipv6 can be set, and multiple IP addresses can be set. Such as:
# rpcallowip = 192.168.77.51/255.255.255.0
# rpcallowip = 2/24
#rpcallowip=2001:db8:85a3:0:0:8a2e:370:7334/96
Copy the code

For more configuration parameters, see: qtum. Conf instance (click open)

After the configuration, restart the node to complete the configuration.

Method 2: Re-run the Qtum node and add specific parameters:

./qtumd -rpcuser=test -rpcpassword=test1234 - rpcallowip = 192.168.77.51/255.255.255.0Copy the code

The meanings of parameters are the same as those in the configuration file.

RPC call instance

After setting up and re-running the node, you can make the remote RPC call. In this article, the IP address of the server running the Qtum node is 192.168.77.188 and the default port is 3889. For example, an RPC call to the Qtum node running in Ubuntu on a macbook will return the same result as the local call:

zhongwenbins-MacBook-Pro:~ zhongwenbin$ curl --user test:test1234 --data-binary '{" jsonrpc ":" 1.0 ", "id" : "curltest", "method" : "getinfo", "params" : []}' -H 'content-type: text/plain; '{http://192.168.77.188:3889/"result": {"version": 140300,"protocolversion": 70016,"walletversion": 130000,"balance": 0.00000000."stake": 0.00000000."blocks": 12197,"timeoffset": 0."connections": 8,"proxy":""."difficulty": {"proof-of-work": 1.52587890625 e-05,"proof-of-stake": 650787.7561123729},"testnet":false."moneysupply": 100028788,"keypoololdest": 1505186997,"keypoolsize": 100,"paytxfee": 0.00000000."relayfee": 0.00400000."errors":""},"error":null,"id":"curltest"}
Copy the code

Use tools like Postman to get a more intuitive look:

The deployment of this Qtum node and the setup of RPC calls are complete.

Nginx Configuration Examples (Optional)

As shown in the example above, the RPC command must contain the RPC user name, password, and specified port number 3889. If you want to deploy generic apis that avoid entering user passwords and port numbers, consider using Nginx instead. In this way, the user name and password can be hidden. When the user name, password, or even port number changes, the API is not affected. In addition, external RPC calls can be properly filtered to ensure security. Search for tutorials on Nginx installation and basic usage.

For example,

  • The server IP address of the Qtum node is192.168.77.188, the node is running properly
  • The API proxy IP address is192.168.77.51, Nginx has been installed

The setting steps are as follows:

1. Set the RPC configuration file of the Qtum node on the server (see above), add the IP address of the API proxy to the RPcallowIP, and restart the node, for example:

rpcuser=test
rpcpassword=test1234 rpcallowip = 192.168.77.51/255.255.255.0Copy the code

2. Configure proxy Nginx:

server { listen 80; server_name localhost; The location / {proxy_pass http://192.168.77.188:3889;Reverse generation to port 3889
            proxy_set_header Authorization "Basic dGVzdDp0ZXN0MTIzNA==";  In this example, the base64 encoding of test:test1234 is used}}Copy the code

3. After the configuration is complete, you can directly access the proxy to make RPC calls (without entering the user name, password, or port number), for example:

zhongwenbins-MacBook-Pro:~ zhongwenbin$ curl  --data-binary '{" jsonrpc ":" 1.0 ", "id" : "curltest", "method" : "getinfo", "params" : []}' -H 'content-type: text/plain; '{http://192.168.77.51/"result": {"version": 140300,"protocolversion": 70016,"walletversion": 130000,"balance": 0.00000000."stake": 0.00000000."blocks": 12250,"timeoffset": 0."connections": 8,"proxy":""."difficulty": {"proof-of-work": 1.52587890625 e-05,"proof-of-stake": 651324.7815933984},"testnet":false."moneysupply": 100029000,"keypoololdest": 1505186997,"keypoolsize": 100,"paytxfee": 0.00000000."relayfee": 0.00400000."errors":""},"error":null,"id":"curltest"}
Copy the code

The above Settings are for reference only, readers can make more Settings according to their own needs, or choose other tools to replace.

Utility commands and documentation

Readers who have problems deploying nodes or RPC calls may first refer to the following practical commands or documentation:

  • Compilation questions reference document: github.com/qtumproject… .
  • View all options for Qtumd:./qtumd -help
  • View all RPC commands:./qtum-cli help
  • View the usage description of an RPC command, such as getInfo:./qtum-cli help getinfo
  • Example configuration file: qtum.conf (click to open)