Getting started with QTUM staking for advanced users

Adrian Barwicki
Oct 6, 2018 · 7 min read
Qtum combines the Bitcoin UTXO model with Ethereum Virtual Machine based smart contracts.

Qtum is a decentralized blockchain project built on Bitcoin’s UTXO model, with support for Ethereum Virtual Machine based smart contracts, and secured by a proof of stake consensus model. Staking QTUM coins is the process of securing the network with your coin weight, which in turn rewards you with new QTUM.

Staking economics and risks

In order for the staking to make sense, you need to generate more staking rewards than it costs to generate them.

Minimal QTUM staking amount

Cost-based: At the moment you should cover all the infrastructure costs by staking at least 160 Qtums. Beware that this number changes based on how many QTUM are currently staked.

Qtum Staking Calculator: https://qtumexplorer.io/qtum-staking-calculator, required staking amount for covering the infrastructure costs.

Payout frequency based: With the assumption that the rewards are received on average monthly, you should stake 640 Qtums.

Qtum Staking Calculator: https://qtumexplorer.io/qtum-staking-calculator, required QTUM staking amount for monthly rewards

Return on investment

Depending on how much you stake, the expected return may be around 7% per year. It may seem like a good deal, but there is a risk that the QTUM cryptocurrency will fall in value by more than this amount. Currently, the price of 1 QTUM coin is around $4 USD, while at its peak, it was $102. The price is very volatile, which makes it a very risky investment, and can only be justified if you hold a sizeable amount of QTUM tokens anyway.

Tax implications

Depending on your tax jurisdiction, it may be that you are obliged to pay tax for every reward that you receive. Personally, I would at least liquidate the number of received rewards, so that the future tax liabilities can be covered.

Recommended infrastructure setup

AWS and instance type

We can provision a Linux machine on AWS. For testing purposes, we can use an on-demand EC2 instance at minimal cost. EC2 instance t2.micro with 1GB RAM should and 8GB storage should be fine.

After downloading the whole QTUM blockchain we have still around 36% of the disk space left, which should suffice for the next 2–3 years.

Reserved instances instead of on-demand EC2

If you plan to stake long-term, it’s much cheaper to reserve an instance for a longer period. Normally, a t2.micro costs 15 USD a month. By reserving it for 36 months, you may pay only ~4USD a month.

Cheapest AWS regions

We can also save a lot of money by provisioning the infrastructure in the cheapest AWS regions, such as N. Virginia, Ohio or Oregon.

Pricing comparison for QTUM node infrastructure hosted on AWS

Amazon Linux

CentOS-based Amazon Linux is around 20% cheaper than the standard Ubuntu. It is not my favorite flavor of Linux, but if it saves some money, that’s great!

Total costs

If you commit to run a node for 3 years applying the above guidelines, the total cost should be around $126 USD or $3,5 per month.

Setting up the QTUM node

Firstly, we want to download the newest release of the QTUM node:

wget https://github.com/qtumproject/qtum/releases/download/mainnet-ignition-v0.17.6/qtum-0.17.6-i686-pc-linux-gnu.tar.gz

You can download the latest version of the QTUM node here:
https://github.com/qtumproject/qtum/releases

Next step is to unpack the downloaded package:

tar -xzf qtum-0.17.6-i686-pc-linux-gnu.tar.gz

WTF: qtumd, qtum-cli, qtum-qt?

I was firstly a little confused by the different executables, so I thought I’d write a little explanation about the relevant ones.

Executables in the QTUM node

qtumd is a headless daemon. It also bundles a testing tool for the same daemon. It provides a JSON-RPC interface, allowing it to be controlled locally or remotely which makes it useful for integration with other software. Various commands are made available by the API.

qtum-cli is a command line interface to interact with qtumd. we can use qtum-cli and make local RPC calls.

qtum-qt is graphical interface. It is not interesting for us.

The QTUM protocol for remote procedure call (RPC) is strongly inspired by Bitcoin.

Launching the QTUM deamon (qtumd)

Now, let’s spin it up:

# we navigate to the folder with executables
cd qtum-0.17.6
cd bin/
# we start the qtum deamon
./qtumd -daemon

The deamon will launch and start downloading the QTUM blockchain.

You will be able to check if the blockchain has been completely downloaded by calling the getblockchaininfo procedure with the qtum-cli:

./qtum-cli getblockchaininfo
The result of getblockchaininfo remote procedure call.

The interesting properties in the response are verificationinprocess and initialblockdownload:

The property verificationinprogress indicates what part of the existing blocks have been downloaded (from 0 to 1), and the initialblockdownload says if we are still synchronizing the blockchain for the first time.

Specify configuration

Now we want to specify the configuration for our node. We will create a new file .qtum.conf in the .qtum/ folder. It should be placed in your user folder:

touch /home/ec2-user/.qtum/qtum.conf
Example of QTUM configuration file: qtum.conf

Specify your username and password for the RFC. If you want to expose the the RPC functions over web, you’ll need to define it here as well. We will now adjust the rpc username and password for our QTUM deamon:

./qtumd -daemon -rpcuser=test -rpcpassword=test1234

Encrypt and backup your wallet

For security reasons, we want to encrypt the wallet that has been newly generated by the qtumd deamon. Even if your machine gets compromised, the attacker will not be able to steal your funds without the password.

./qtum-cli encryptwallet yourpassword

Remember each time to remove the command containing passwords from the history after entering your password in the console:

rm ~/.bash_history

Now we will secure your wallet file as well as the private key. Let’s get an address. Note that the wallet can have many addresses and each address has its own private key!

./qtum-cli getnewaddress

In order to see the corresponding private key for the address:

# it will unlock your wallet for 60 seconds
./qtum-cli walletpassphrase yourpassword 60
# it will show the corresponding private key:
./qtum-cli dumpprivkey "address"

Be sure to save both the public and private key. The best option is to write it down on paper.

Next, we also want to secure the whole wallet file. Log out from the shell of the remote machine and run it on your local computer.

scp -i /path/to/your/key.pem ec2-user@ipAddress:/home/ec2-user/.qtum/wallets/wallet.dat ./wallet.dat

It will copy the wallet file onto your local machine. This is already encrypted file and relatively secure. Keep a copy of it in a cold storage, e.g on a pen drive.

Setup your wallet for QTUM staking

Firstly wait until the whole blockchain database has been synchronized. Then you can send QTUM tokens to the address generated by getnewaddress.

It is strongly recommended to send a small amount first, like 0.1 QTUM for test purposes. Once the blockchain is fully synchronized and the transaction is confirmed, you should see the amount by calling the getbalance method:

# shows a balance of an account (all address agreggated)
./qtum-cli getbalance ""
Example call of the getbalance method of qtum-cli

Now you should unlock your wallet for staking purposes. Without this, the QTUM staking will not be possible:

/qtum-cli walletpassphrase passphrase 999999 true

You’re all set up! Remember that the QTUM tokens need to mature first before they can be used for QTUM staking. This process takes +500 confirmations, which is around 20h.

After this time, you can verify if everything works well:

./qtum-cli getstakinginfo

The output should be:

Staking is enabled (->enabled: true), and there are some mature coins (->staking: true)

If the staking field is false, it means that you are currently not staking i.e. your coins have not yet matured.

Useful commands

# dumps your wallet file
./qtum-cli dumpwallet "filename"
# displays relevant information about your wallet, among others if the staking is enabled and if the coins are actually being staked
./qtum-cli getwalletinfo
# displays relevant information about your wallet, among others the balance and stake amounts.
./qtum-cli getstakinginfo
# gets new address for your wallet (wallet can have many addresses)
./qtum-cli getnewaddress
# displays all the addresses generated by the method "getnewaddress"
./qtum-cli getaddressesbyaccount ""
# displays the private key for an address
./qtum-cli dumpprivkey "address"
# unlocks wallet for staking
./qtum-cli walletpassphrase "passphrase" 999999 true
# shows balance of an account (all address agreggated)
./qtum-cli getbalance ""

Any Questions?

If you have any other questions feel free to contact us on any of the channels below or by email at contact@alphateamhackers.com.

Are you from Germany and are you interested in joining a shared staking pool? Write to us as well!

If this content helped your project or you just like the work we do and would like to help us grow the content and products we have available, please consider giving us a tip…

ETH: 0x61063208393BAd596a10be2EE5Fe04e2Ad681B35
QTUM: QPLeUdM9AFn5Ahxcf3WK7LZAoh5JDAao5r

Coinmonks

Coinmonks is a non-profit Crypto educational publication. Follow us on Twitter @coinmonks Our other project — https://coincodecap.com

Adrian Barwicki

Written by

IT Consultant and Creator of Honest.Cash. You’ll find more about me here: https://adrianbarwicki.com.

Coinmonks

Coinmonks

Coinmonks is a non-profit Crypto educational publication. Follow us on Twitter @coinmonks Our other project — https://coincodecap.com

More From Medium

More from Coinmonks

Jia Yung Lee
Feb 6 · 5 min read

1.2K

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade