1 — Launch QTUM Core

First, QTUM AMI comes with qtumd installed. It is the command used to start your QTUM Core.

Start by QTUM node on your instance:

qtumd

You can use -testnet option if you want to start testnet (by default the mainnet starts)

You can use -daemon option if you want the process to run in the background so you can run commands after. If you start it like this as daemon, if you need to stop it later on, you can use command: qtum-cli stop.

Note: you can get help for qtumd with command: qtumd -h

qtumd command will start the Qtum Core. You will see a .qtum directory appearing in /home/ubuntu. This directory is the default to store the local chain info (in Linux, which is OS AWS installed). Note that you can change this location if desired, check qtumd help if you want it.

When you start the qtumd, your local chain will automatically start synchronising.

The base command to interact with your running Qtum core is:

qtum-cli

To get help, use:

qtum-cli — help (shows help for qtum-cli)

qtum-cli (shows list of commands)

qtum-cli [command] — help (shows help for a command)

You can verify your node is connected to the QTUM network with command:

qtum-cli getnetworkinfo

You should see displayed:

“networkactive”: true, “connections”: X (>0)

How to know your node has finished synchronising with network ?

I first found it hard to know when dealing with qtumd. Solution is actually pretty simple. Run command:

qtum-cli getblockchaininfo

and check value: verificationprogress. If it’s 1, then your local chain is fully synchronised.

Note: Synchronisation can take many hours to complete, and will depends on Instance Type you chose for your EC2 instance, network, nodes…just be patient :)

qtum-cli will be your go-to command to communicate with your node locally (directly on instance). With it you can for example:

get new QTUM addresses (remember, with UTXO model a wallet has many addresses, one per transaction being ideal)

send/receive QTUM tokens,

send transactions

sign transactions

stake QTUM tokens

protect your wallet

…and so on.

This tutorial won’t cover further possibilities offered by qtum-cli. If you want to learn more about it, I suggest you to start by having a look to at official documentation: https://docs.qtum.site

If you want to use QTUM core directly from the instance only (with qtum-cli), you are good to go and can directly go to next part. However…

…what if you want to use your fresh node from outside ?

For example, from a client and/or server where your Dapp logic is ?

For this, you need some more setup to do for your QTUM AMI to be usable, and I found it difficult to find info for this …so here it is:

Let’s expose AWS EC2 3889 and 13889 Ports

First…. you have to know that by default your QTUM AMI does not expose any more ports than 5555 for QMIX (see next section), 22 for SSH connection (we used to connect to EC2 instance in previous tutorial), and 3888 Ports.

BUT, when you run qtumd or qtumd -testnet, ports used by default are 3889 and 13889. (3889 for mainnet, and 13889 for testnet)

So, follow theses steps to open these ports on AWS EC2:

1/ Go back to SERVICES > EC2: https://console.aws.amazon.com/ec2/

2/ Click on Running Instances

3/ Add the end of the line of your QTUM Instance, in Security Group Column, you will see some link looking: Qtum AMI-Qtum AMI 1–0-AutogenByAWSMP-2. Click on it

4/ At the bottom of the page, click on Inbound tab.

5/ Click on Edit

6/ A modal opens, click on Add Rule

7/ For the new Rule, select Custom TCP Rule, Port Range 3889, source 0.0.0.0/0. If you want to call testnet network too from outside your instance, do the same for port 13889. Of course, if you changed default ports for qtumd at starting time, use them (though if you followed the tutorial, just used default ports).

8/ Click on Save.

9/ Congrats, your AWS EC2 instance now accept connections to 3889 and 13889 ports.

Now, let’s restart qtumd to define authorised user / ip to call your node from outside

1/ If qtumd is running, stop it with qtum-cli stop

2/ Start it again with command:

qtumd -rpcuser=clement -rpcpassword=test -rpcallowip=XX.XXX.XX.XXX/255.255.255.0

Note that: clement should be replaced by the username you want, test by the password your want and XX.. by your IP (or IP of client calling it). username and password you set will be needed later to call your running Qtum core.

Note that you can use -rpcallowip option multiple times if you need to authorise many IPs.

3/ Time to test! From previously authorised IP, try following command:

curl — user clement:test — data-binary ‘{“jsonrpc”: “1.0”, “id”:”curltest”, “method”: “getwalletinfo”, “params”: [] }’ -H ‘content-type: text/plain;’ http://XXX.XXX.XXX.XXX:3889/

Don’t forget replacing clement:test by your username:password you just set, and XXX.XXX.XXX.XXX by your AWS EC2 instance IPV4 (not your authorised IP :).

…And you should get results ! Congrats!

Now, you have a Qtum node running and can communicate with it from the outside, with user/password you defined and from an IP you authorised.

You can now use it in your project to speak with QTUM blockchain.

For example, using QtumJS from Qtum, you can do: