If you are holding THC coins, did you know that you can stake your coins to make your balance grow? Armed with some command line tools and a Linux prompt and you can start raking in staking rewards by harvesting tx fees and block rewards as thanks for helping to secure the THC blockchain. This guide applies to THC after it became a KMD assetchain.
You will need a Machine, Coins and Komodo Builds before you can get started:
- MACHINE An always on and online Windows 10 PC with the Windows Linux Subsystem installed (:https://docs.microsoft.com/en-us/windows/wsl/install-win10) OR your own Linux machine OR
You can rent an Ubuntu VPS (Virtual Private Server) in the cloud for a $5/month (please use this referral code if you choose this option: https://m.do.co/c/06f18d7439fd)
- COINS Some number of THC coins ready to transfer into a new wallet. If you have THC coins in an old HempCoin QT wallet you can import those coins into the KMD asset chain by following the steps here: https://hempcoin.org/migration-thc.html OR you can wait until the supported exchanges start accepting THC on the new KMD asset chain.
- KOMODO BUILDS The EASY way: Grab the binaries built by @whatever using gitlab directly from here: http://whatever-chain.de/thc-wallet/ and copy them onto your staking machine OR The HARD way:you can download the komodo source from github at https://github.com/jl777/komodo by following the steps from @exile13 here: https://hempcoin.org/migration-thc.html
Got all of that put together? Great — Let’s get started.
You will need to install Python if you haven’t already. Open a command line prompt and run these commands one by one to get that up and running with the right dependencies
sudo apt-get install python3-dev
sudo apt-get install python3 libgnutls28-dev
sudo apt-get install libcurl4-openssl-dev libssl-dev
sudo apt-get install python3-pip
pip3 install setuptools
pip3 install wheel
pip3 install base58 slick-bitcoinrpc python-bitcoinlib
Before we can get the THC Blockchain up and running, we have to create a configuration file with set of mostly preset options. Start by creating the expected folders and navigating to the folder where this file needs to live and creating a blank file at this location with the
Copy this text…
…and paste into the nano editor in your command prompt.
Next challenge: think of a unique username and password for the daemon to use when running local RPC calls. The password here is written in *clear text* so don’t reuse an important password. And don’t overthink this. Just use some random, long phrase with no spaces instead of the placeholders shown here
passwordChangeThis. There’s little need to have to ever type this in again — you are likely never going to need to recall this again once you set it.
Once you’ve finished,
Ctrl+X to exit.
nano will ask you if you want to Save modified buffer? type
Yand once you hit enter, the THC.conf file will appear on disk ready to go. Type
ls to see that file listed in the directory if you want to make doubly-sure.
Next you need to run the Komodo daemon called
komodod and leave that running in a separate window for now. A big gnarly command that lists out all of the parameters of the chain is required to launch it.
First figure out where your komodo binaries are and switch to that directory:
and then paste this into your command line prompt to kick things off:
./komodod -ac_name=THC -ac_supply=251253103 -ac_reward=360000000,300000000,240000000,180000000,150000000,90000000,0 -ac_staked=100 -ac_eras=7 -ac_end=500001,1000001,1500001,2000001,2500001,4500001,0 -ac_perc=233333333 -ac_cc=2 -ac_ccenable=229,236,240 -ac_script=2ea22c8020987fad30df055db6fd922c3a57e55d76601229ed3da3b31340112e773df3d0d28103120c008203000401ccb8 -ac_founders=150 -ac_cbmaturity=1 -ac_sapling=1 -addnode=126.96.36.199 -addnode=188.8.131.52 -earlytxid=7e4a76259e99c9379551389e9f757fc5f46c33ae922a8644dc2b187af2a6adc1
A bunch of messages will start flying by. This is normal and expected. You’ve now started the daemon and want to leave that running without disturbing it. I suggest you move this window off to the side and open a new command prompt to start sending commands to your daemon.
Another binary called
komodo-cli is needed to execute blockchain commands. The cli will only work properly if the
komodod daemon is up and running. One way to check up on how your chain is running is to check how much of the blockchain has been downloaded by running this command:
./komodo-cli -ac_name=THC getinfo
you should see a nice plump JSON response with all sorts of mostly useless data in it. The important properties are these two numbers:
once these two numbers are equal, that means that you have downloaded and processed all blocks in the blockchain that presently exist.
Next up: look up your default wallet address with this command:
./komodo-cli -ac_name=THC getaccountaddress ""
Your address should start with R and be 30+ characters long. Believe it or not this is the *compact* notation for your wallet address. Copy/paste this address somewhere as you’ll need it later.
You can validate your address with the following command:
./komodo-cli -ac_name=THC validateaddress <your_R_Address_here>
and look through the output to find your pubkey which is a long hexadecimal string. This pubkey which is the *expanded* notation for your address. You should copy/paste this somewhere for later too.
Now you will need fill that wallet with THC coins, by sending those coins to <your_R_address> via whatever other mechanism you desire. Once that is complete and the transactions have been given enough time to get confirmed, you can check your balance with:
./komodo-cli -ac_name=THC getbalance
And you should see a nonzero balance. This is a great time to shut down the daemon:
./komodo-cli -ac_name=THC stop
and do a quick backup of your
wallet.dat file. Your
wallet.dat file is what contains your private keys. If you lose this file, you lose your wallet and you lose your coins. If your hard drive crashes on this machine, you lose your wallet and you lose your coins. If someone steals this file from you, they can steal your coins. It is wise to keep it backed up. It lives in the
~/.komodo/THC folder. I suggest you copy it to a USB drive (or two!) and keep that in a separate location.
If you’re using Linux, you first need to mount a USB drives: https://linuxconfig.org/howto-mount-usb-drive-in-linux and then run a copy command to move your wallet.dat into into the drive.
If you’re using Win10 WSL, it is probably easier to just copy your wallet.dat out of the Linux filesystem place and into the Windows 10 filesystem place so you can simply drag and drop the wallet.dat onto your USB drive(s)
cp ~/.komodo/THC/wallet.dat /mnt/c/Users/<your username/Desktop
Now let’s get on to the business of staking. The staking mechanism in Komodo is not very intuitive. The algorithm goes to great lengths to make sure that staking rewards get distributed evenly to a wide variety of addresses. It does this by sorting all addresses into 64 buckets, and assigning a number to each bucket called a segID. (You can see which segID your address is assigned to if you look closely at the validate address output). To maximize the odds of Your Wallet getting a staking reward, it is in your best interest for your wallet to have 64 distinct Addresses — one address in each of the possible 64 segID buckets. Then you should distribute your coins evenly throughout these 64 addresses. Imagine trying to manage this yourself, what a hassle!
Thankfully there is an automated tool provided by KMDLabs that manages this for you called pos64staker. It is a set of python scripts that generates the 64 addresses you will need, distributes your coins to these addresses, allows you to partially withdraw some number of coins, and channels your staking rewards into the address with the smallest balance — ensuring that you are maintaining roughly the same balance across your 64 addresses.
Here’s how you get pos64staker set up on your machine:
git clone https://github.com/KMDLabs/pos64staker
git checkout restart
The script expects the komodo binaries to be in the same folder as the python scripts. So you need to move your
fetch-params.sh files into the pos64staker folder. A set of commands like this, using forward slashes, will work fine at the command line of either Linux or the Win10 WSL:
cd /<absolute_path_to_komodo-binaries>mv komodod /<absolute_path_to>/pos64staker
mv komodo-cli /<absolute_path_to>/pos64staker
mv fetch-params.sh /<absolute_path_to>/pos64stakercd /<absolute_path_to>/pos64staker
NOTE: you only need to move komodod to the pos64staker folder, however I recommend moving these 3 files together as a unit so that you never find yourself in a situation during a future upgrade where you only update some of the binaries. Just a personal preference. Mileage may vary.
Now let’s start up the THC blockchain again. Now that we know the pubkey for your address we should pass that in along with the other chain parameters. This step ensures that the staking rewards actually get sent to your wallet and not someone else’s. After pasting <your_pubkey>into the following komodod command, run:
./komodod -ac_name=THC -ac_supply=251253103 -ac_reward=360000000,300000000,240000000,180000000,150000000,90000000,0 -ac_staked=100 -ac_eras=7 -ac_end=500001,1000001,1500001,2000001,2500001,4500001,0 -ac_perc=233333333 -ac_cc=2 -ac_ccenable=229,236,240 -ac_script=2ea22c8020987fad30df055db6fd922c3a57e55d76601229ed3da3b31340112e773df3d0d28103120c008203000401ccb8 -ac_founders=150 -ac_cbmaturity=1 -ac_sapling=1 -addnode=184.108.40.206 -addnode=220.127.116.11 -earlytxid=7e4a76259e99c9379551389e9f757fc5f46c33ae922a8644dc2b187af2a6adc1 -pubkey=<your_pubkey>
Now we can generate the other 63 addresses, one for each segID. The simplest way to do this is to use pos64staker’s TUI (Textual UI):
The first time you launch this, you will have to select the <add/remove chain> option and tell it to add ‘THC’. This will bring you to a prompt that looks something like this:
Keep in mind that you can Ctrl+C at any time to just quit the TUIstaker.py UI at anytime.
Select THC from the list to access to pos64staker’s useful commands:
Run the ‘genaddresses’ command. It may take a minute or two to complete. Once that has completed, you should see an ‘Success!’ banner across the top. Upon success, pos64staker will have created a THC.json file in the current directory. This file has the 64 private keys for each of your 64 addresses. This is another file you should copy over to your USB stick safe place along with your wallet.dat file.
Next you’ll want to run ‘RNDsendmany’.
This command will ask you a series of annoying questions. The questions are annoying because it is not clear what constitutes a sensible value. It will ask:
Please specify the amount of UTXOs to send to each segid:
Your response must be a whole number 3 or larger. This number tells you how many transactions will get sent to each of your 64 addresses. There is probably some science here as to what a good answer is that maximizes the odds of successfully staking, but I can tell you that it will all work out just fine if you pick a number between 4 and 8.
Next it will tell you something like:
Total number of UTXOs: 256
Average utxo size: 2.2804631656640626
Enter percentage of variance:
This is more helpful, as it tells you how much is sent in each of transactions. But it then asks you another annoying question that implies that it isn’t sending EXACTLY 2.28 coins in each transaction, it is some sort of average and there is some variance in this number. Again, there may be some science to employ here, but I can tell you that it will all work out just fine if you pick a ‘percentage of variance’ of 5. Response:
Min size: 2.17
Max size: 2.39
Are you happy with these?(y/n):
The min/max transaction size makes sense. And you are given a chance to back out if you don’t like the min/max size is has calculated. If you select n, it will keep asking you these annoying questions from the start again. Let’s presume that you like this, and select y.
As long as you have enough coins in your wallet to pay for this, it should succeed. Now you can quit out of TUIstaker.py (type q at the menu) and see for yourself how this worked out by running:
./komodo-cli -ac_name=THC getbalance64
and you will get this crazy long list of numbers. The output will look something like this:
"immature": <total count of your coins>,
this command shows you how your coins are distributed amongst your 64 segID addresses. These numbers are in satoshis (to get actual number of coins just put a decimal point 8 places from the right end of the number). The balances should all be very similar, with maybe one address containing a remainder that didn’t divide equally into the addresses. All of your balances should be ‘immature’ since you just moved them and there are rules about letting a balance mature before they can qualify for staking. All of your balances should be ‘notstaking’ at this point.
Now you need to restart the blockchain with an important extra parameter that calls pos64staker when new blocks are found. This ensures that if you win a staking reward, that the rewards will be rebalanced correctly amongst your 64 addresses.
There are two ways to go about this:
- Use option #7 in THC’s TUIstaker.py menu OR
- Restart the chain from the command line and launch it with a special -blocknotify parameter like this:
./komodo-cli -ac_name=THC stop./komodod -ac_name=THC -ac_supply=251253103 -ac_reward=360000000,300000000,240000000,180000000,150000000,90000000,0 -ac_staked=100 -ac_eras=7 -ac_end=500001,1000001,1500001,2000001,2500001,4500001,0 -ac_perc=233333333 -ac_cc=2 -ac_ccenable=229,236,240 -ac_script=2ea22c8020987fad30df055db6fd922c3a57e55d76601229ed3da3b31340112e773df3d0d28103120c008203000401ccb8 -ac_founders=150 -ac_cbmaturity=1 -ac_sapling=1 -addnode=18.104.22.168 -addnode=22.214.171.124 -earlytxid=7e4a76259e99c9379551389e9f757fc5f46c33ae922a8644dc2b187af2a6adc1 -pubkey=<your_pubkey> '-blocknotify=/<absolute_path_to>/pos64staker/staker.py %s THC'
If you go this route, be sure to replace <absolute_path_to> with the correct path to the staker.py script. (something like
/home/username/thc-staking/pos64staker/staker.pyif on Linux OR something like
/mnt/c/thc-staking/pos64staker/staker.py if on Windows 10 using WSL).
Now, you simply need to Start Staking! like this:
./komodo-cli -ac_name=THC setgenerate true 0
and if you’ve done everything right you are now staking.
To Verify You Are Actually Staking
- Make sure your 64 segID balances now all report as ‘staking’ instead of ‘notstaking’. NOTE: you may have to wait for your balance to ‘mature’ before this will start working. Success looks like:
"mature": <total count of your coins>,
2. In your komodod output, you should see this messages like this:
3. And finally, if you just check your balance every few hours or so, you should start to see your balance slowly creeping upwards!
Hopefully this guide helped you through the topsy-turvy, confusing world of pos64staking. It has a learning curve, but it really does work and helps you rake in significantly better staking rewards than if you simply Start Staking with all of your coins in one nice and tidy address.
If you liked this guide, send me dogracer some crypto love!