How to start a Qtum node and deploy contract on it?
From zero to hero
Requirements:
OS: MacOS
Docker
Qtum-CLI
Setup Envirement
Let’s using Docker image to start a Qtum node:
Pull the latest image version
$ docker pull hayeah/qtumportal:latest
johnnyhsieh@Johnnyde-MacBook-Pro-3:~$ docker pull hayeah/qtumportal:latestlatest: Pulling from hayeah/qtumportalDigest: sha256:6f4744b1ec4eaa4763617b1d32413c2ac61669778ca551a8e0023c8d95c8c91eStatus: Image is up to date for hayeah/qtumportal:latest
Now we can using the latest image version start a node ( testnet )
johnnyhsieh@Johnnyde-MacBook-Pro-3:~$ docker run -it --rm \--name myapp \-e "QTUM_NETWORK=testnet" \-v `pwd`:/dapp \-p 9899:9899 \-p 9888:9888 \-p 3889:3889 \-p 13888:13888 \hayeah/qtumportal
As soon as we start a node, our log will looks like this
03:43:22 qtumd | Starting qtumd on port 500003:43:22 portal | Starting portal on port 500103:43:22 portal | time="2018-09-04T03:43:22Z" level=info msg="DApp service listening 0.0.0.0:9888"03:43:22 portal | time="2018-09-04T03:43:22Z" level=info msg="Auth service listening 0.0.0.0:9899"03:43:23 qtumd | 2018-09-04 03:43:2303:43:23 qtumd | 2018-09-04 03:43:23 Qtum version mainnet-ignition-v0.15.203:43:23 qtumd | 2018-09-04 03:43:23 InitParameterInteraction: parameter interaction: -whitelistforcerelay=1 -> setting -whitelistrelay=103:43:23 qtumd | 2018-09-04 03:43:23 Assuming ancestors of block 39ffa0c5924550db0e75030ff8513c3145d491dff2e17b8e3ea1cea7b4662ff0 have valid signatures.03:43:23 qtumd | 2018-09-04 03:43:23 Setting nMinimumChainWork=00000000000000000000000000000000000000000000000d6e528bcf5a3a556f03:43:23 qtumd | 2018-09-04 03:43:23 Using the 'standard' SHA256 implementation03:43:23 qtumd | 2018-09-04 03:43:23 Using RdRand as an additional entropy source03:43:23 qtumd | 2018-09-04 03:43:2303:43:23 qtumd | 2018-09-04 03:43:23 Default data directory /root/.qtum03:43:23 qtumd | 2018-09-04 03:43:23 Using data directory /dapp/.qtum/testnet303:43:23 qtumd | 2018-09-04 03:43:23 Using config file /dapp/.qtum/qtum.conf03:43:23 qtumd | 2018-09-04 03:43:23 Using at most 125 automatic connections (1048576 file descriptors available)03:43:23 qtumd | 2018-09-04 03:43:23 Using 16 MiB out of 32/2 requested for signature cache, able to store 524288 elements03:43:23 qtumd | 2018-09-04 03:43:23 Using 16 MiB out of 32/2 requested for script execution cache, able to store 524288 elements03:43:23 qtumd | 2018-09-04 03:43:23 Using 2 threads for script verification03:43:23 qtumd | 2018-09-04 03:43:23 scheduler thread start03:43:23 qtumd | 2018-09-04 03:43:23 HTTP: creating work queue of depth 1603:43:23 qtumd | 2018-09-04 03:43:23 Config options rpcuser and rpcpassword will soon be deprecated. Locally-run instances may remove rpcuser to use cookie-based auth, or may be replaced with rpcauth. Please see share/rpcuser for rpcauth auth generation.03:43:23 qtumd | 2018-09-04 03:43:23 HTTP: starting 4 worker threads03:43:23 qtumd | 2018-09-04 03:43:23 init message: Verifying wallet(s)...03:43:23 qtumd | 2018-09-04 03:43:23 Using BerkeleyDB version Berkeley DB 4.8.30: (April 9, 2010)03:43:23 qtumd | 2018-09-04 03:43:23 Using wallet wallet.dat03:43:23 qtumd | 2018-09-04 03:43:23 CDBEnv::Open: LogDir=/dapp/.qtum/testnet3/database ErrorFile=/dapp/.qtum/testnet3/db.log03:43:23 qtumd | 2018-09-04 03:43:23 Cache configuration:03:43:23 qtumd | 2018-09-04 03:43:23 * Using 2.0MiB for block index database03:43:23 qtumd | 2018-09-04 03:43:23 * Using 8.0MiB for chain state database03:43:23 qtumd | 2018-09-04 03:43:23 * Using 440.0MiB for in-memory UTXO set (plus up to 286.1MiB of unused mempool space)03:43:23 qtumd | 2018-09-04 03:43:23 init message: Loading block index...03:43:23 qtumd | 2018-09-04 03:43:23 Opening LevelDB in /dapp/.qtum/testnet3/blocks/index03:43:23 qtumd | 2018-09-04 03:43:23 Opened LevelDB successfully03:43:23 qtumd | 2018-09-04 03:43:23 Using obfuscation key for /dapp/.qtum/testnet3/blocks/index: 000000000000000003:43:23 qtumd | 2018-09-04 03:43:23 LoadBlockIndexDB: last block file = 003:43:23 qtumd | 2018-09-04 03:43:23 LoadBlockIndexDB: last block file info: CBlockFileInfo(blocks=0, size=0, heights=0...0, time=1970-01-01...1970-01-01)03:43:23 qtumd | 2018-09-04 03:43:23 Checking all blk files are present...03:43:23 qtumd | 2018-09-04 03:43:23 LoadBlockIndexDB: transaction index disabled03:43:23 qtumd | 2018-09-04 03:43:23 LoadBlockIndexDB: log events index disabled03:43:23 qtumd | 2018-09-04 03:43:23 Initializing databases...03:43:23 qtumd | 2018-09-04 03:43:23 Pre-allocating up to position 0x1000000 in blk00000.dat03:43:25 qtumd | 2018-09-04 03:43:25 Opening LevelDB in /dapp/.qtum/testnet3/chainstate
Take a look of our docker
$ docker ps
johnnyhsieh@Johnnyde-MacBook-Pro-3:~$ docker psCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESa33867ebe8a3 hayeah/qtumportal "/bin/sh -c 'mkdir -…" 42 seconds ago Up 42 seconds 0.0.0.0:3889->3889/tcp, 0.0.0.0:9888->9888/tcp, 0.0.0.0:9899->9899/tcp, 3888/tcp, 0.0.0.0:13888->13888/tcp myapp
Our NAMES is “myapp” using exec -it
$docker exec -it myapp sh
johnnyhsieh@Johnnyde-MacBook-Pro-3:~$ docker exec -it myapp sh/dapp #
Now we can use qcli to operate
/dapp # qcli getinfo{"deprecation-warning": "WARNING: getinfo is deprecated and will be fully removed in 0.16. Projects should transition to using getblockchaininfo, getnetworkinfo, and getwalletinfo before upgrading to 0.16","version": 150200,"protocolversion": 70016,"walletversion": 139900,"balance": 0.00000000,"stake": 0.00000000,"blocks": 71371,"timeoffset": 0,"connections": 8,"proxy": "","difficulty": {"proof-of-work": 1.52587890625e-05,"proof-of-stake": 1551162.284585649},"testnet": true,"moneysupply": 0,"keypoololdest": 1536032607,"keypoolsize": 2000,"paytxfee": 0.00000000,"relayfee": 0.00400000,"errors": ""}
Lets open a new wallet and request some testnet token first in order to deploy a contract
# qcli getnewaddress
/dapp# qcli getnewaddressqRX4jHmjR5X3y2xkMYMF6fuZ2H2M1dP11m
We open a new wallet with address: “qRX4jHmjR5X3y2xkMYMF6fuZ2H2M1dP11m”
Now we can use this address to request testnet token
http://testnet-faucet.qtum.info/#!/

paste your address on it, and faucet will send their testnet token to you, you can only request once in 24hr.
wait for a while then you can check your balance
# qcli getbalance
/dapp# qcli getbalance96.00000000

Deploy contract
Qtum using Solar to deploy contract
Because all the move on blockchain need to spend token, so we chose the address with 96 tokens inside it.
# export QTUM_SENDER=”your address here”
/dapp # export QTUM_SENDER=qRX4jHmjR5X3y2xkMYMF6fuZ2H2M1dP11m
Using solar to deploy contract
# solar deploy ”your contract”.sol — force
/dapp # solar deploy QNSRegistry.sol --force
if success our log will look like this:
🚀 All contracts confirmeddeployed QNSRegistry.sol => 4d4b1c4a5111cb7c1fd469596204b841754c8497
We can use #solar status to see the detail of this contract
/dapp/qtoken/qns/QNSRegistry # solar status✅ QNSRegistry.soltxid: 4b0c1fc1ce8528820a3ce104263174523ac323daaa37bde252d8ca7720ee1065address: 4d4b1c4a5111cb7c1fd469596204b841754c8497confirmed: trueowner: qRX4jHmjR5X3y2xkMYMF6fuZ2H2M1dP11m
Now we can use abiplay to interact with your contract
http://localhost:9899/abiplay/
After deploy our contract with solar, solar will generate a json file name “solar.development.json” as a abi interface.
chose “solar.development.json” from abiplay

When you send the transcation the apiplay will show wait for autherizing,
You need go to http://localhost:9899 to aprove the transaction.

And the result will be like this:

Now you can direct interact with contract just like remix of ethereum.
