HTMLCOIN Mining Tutorial

in #htmlcoin7 years ago (edited)

I thought it will not be a bad idea to write a little tutorial on how to mine HTMLCOIN. I see almost every day posts like "How to mine with the wallet?" on the subreddit. I will go through the process of mining with the QT Wallet and with the CLI, for single and multi instance mining.

<p dir="auto">At first you need to download and install the <a href="https://github.com/HTMLCOIN/HTMLCOIN/releases/tag/v2.0.1.0" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">latest HTML Wallet. In case you are mining on CentOS, I have written another <a href="https://steemit.com/htmlcoin/@daveiano/html-coin-v2-0-1-0-update-install-centos-linux" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">tutorial on how to install the wallet since I had some problems doing so. <p dir="auto"><strong>Note: CPU only single mining is the only way to mine, there are no mining pools available to this day. <h1>Single QT Wallet Mining <p dir="auto">Just start the wallet and click on "Help" and on "Debug Window" and then "Console". Now you can type commands to run. <p dir="auto"><a href="https://s3-eu-west-1.amazonaws.com/public-images-social/help-debug-window.png" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link"><img src="https://images.hive.blog/768x0/https://s3-eu-west-1.amazonaws.com/public-images-social/help-debug-window.png" srcset="https://images.hive.blog/768x0/https://s3-eu-west-1.amazonaws.com/public-images-social/help-debug-window.png 1x, https://images.hive.blog/1536x0/https://s3-eu-west-1.amazonaws.com/public-images-social/help-debug-window.png 2x" /><br /> <em>Click on "Help" and on "Debug Window" and then "Console" to get to the console. <p dir="auto"><a href="https://s3-eu-west-1.amazonaws.com/public-images-social/help-command.png" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link"><img src="https://images.hive.blog/768x0/https://s3-eu-west-1.amazonaws.com/public-images-social/help-command.png" srcset="https://images.hive.blog/768x0/https://s3-eu-west-1.amazonaws.com/public-images-social/help-command.png 1x, https://images.hive.blog/1536x0/https://s3-eu-west-1.amazonaws.com/public-images-social/help-command.png 2x" /><br /> <em>A list of all available commands. <p dir="auto">An overview of the available commands will be shown when you type "help" (without the brackets) and hit enter. The two main commands you want to use are: <pre><code>generate 100 99999999 <p dir="auto">This will generate 100 blocks and then retries it 99999999 times. I feel it doesn't make any difference which combination you choose, but choose one that runs a while (<em>generate 100 99999999 will run approximately 3 min and <em>generate 100 999999999 will run half an hour). The reason of that is that the commands entered in the debug window will be executed one after the other. So you want to spam these commands. As a return value you will get: <pre><code>[ ] <p dir="auto">These are empty sqaure brackets, it means you found nothing, if it returns this: <pre><code>[ "0000000006b9b5aec68faf150e6cbc9ce71653a622f25b977a4835a57498a8e1" ] <p dir="auto">Then you found something! This means you found a block, and the 1250 HTML Coins block reward will be added to the balance of your wallet. The second generate command is: <pre><code>generatetoaddress 100 <YOUR ADDRESS> 999999999 <p dir="auto">This does the same as the previous command, but the block reward will be added to the balance of the specified address (replace < YOUR ADDRESS> with your receiving address). This way you can mine on a second wallet on a second computer, but transfer the rewards to your main wallet. <h1>Multiple QT Wallet Mining <p dir="auto">What you can do with one wallet, you can also do with multiple wallets. The trick is how to open multiple wallets on the same computer. It's important to understand that each wallet needs it own blockchain which also needs to be in sync. So you want to start multiple, independet wallets. <h2>Linux <p dir="auto">On a Linux computer you do can do this with these commands: <pre><code># Navigate to the directory where your htmlcoin-qt executable is located ./htmlcoin-qt -datadir=/home/<YOUR_NAME>/.htmlcoin1 -port=4891 ./htmlcoin-qt -datadir=/home/<YOUR_NAME>/.htmlcoin2 -port=4892 ./htmlcoin-qt -datadir=/home/<YOUR_NAME>/.htmlcoin3 -port=4893 <p dir="auto">This will start three different wallets, each with its own blockchain folder (-datadir argument). You will need to give each wallet a different port to listen for connections. I think this is because each instance has to communicate with the htmlcoind proccess on a different port. But 'I dont know why you dont need to do this on windows. <h2>Windows <p dir="auto">On Windows you need these commands: <pre><code># Navigate to the directory where your htmlcoin-qt.exe is located htmlcoin-qt.exe --datadir="C:\Users\<YOUR_NAME>\AppData\Roaming\HTMLCOIN_2" htmlcoin-qt.exe --datadir="C:\Users\<YOUR_NAME>\AppData\Roaming\HTMLCOIN_2" htmlcoin-qt.exe --datadir="C:\Users\<YOUR_NAME>\AppData\Roaming\HTMLCOIN_2" <p dir="auto"><em>--datadir specifies where the application saves the blockchain and the wallet file. <p dir="auto"><a href="https://s3-eu-west-1.amazonaws.com/public-images-social/html-three-wallets.png" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link"><img src="https://images.hive.blog/768x0/https://s3-eu-west-1.amazonaws.com/public-images-social/html-three-wallets.png" srcset="https://images.hive.blog/768x0/https://s3-eu-west-1.amazonaws.com/public-images-social/html-three-wallets.png 1x, https://images.hive.blog/1536x0/https://s3-eu-west-1.amazonaws.com/public-images-social/html-three-wallets.png 2x" /><br /> <em>Multiple wallets on the same computer. <p dir="auto">You can create startup one click scripts by saving this into a file called e.g. start-wallet-1.cmd, for wallet-1: <pre><code>"C:\Program Files (x86)\HTMLCOIN2\htmlcoin-qt.exe" --datadir=C:\Users\<YOUR_NAME>\AppData\Roaming\HTMLCOIN_1 <p dir="auto">For wallet two, create a file start-wallet-2.cmd: <pre><code>"C:\Program Files (x86)\HTMLCOIN2\htmlcoin-qt.exe" --datadir=C:\Users\<YOUR_NAME>\AppData\Roaming\HTMLCOIN_2 <p dir="auto">.. and so on. With multiple wallets open, you can open multiple consoles and run multiple generate commands at the same time! <p dir="auto"><a href="https://s3-eu-west-1.amazonaws.com/public-images-social/html-three-wallets-mining.png" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link"><img src="https://images.hive.blog/768x0/https://s3-eu-west-1.amazonaws.com/public-images-social/html-three-wallets-mining.png" srcset="https://images.hive.blog/768x0/https://s3-eu-west-1.amazonaws.com/public-images-social/html-three-wallets-mining.png 1x, https://images.hive.blog/1536x0/https://s3-eu-west-1.amazonaws.com/public-images-social/html-three-wallets-mining.png 2x" /><br /> <em>Multiple wallets mining on the same computer. <h1>CLI Mining <p dir="auto">Wallet mining does work, but it's a little bit stressfull to have four or more wallets open at the same time and spam all these generate commands. So the next step is to automate the mining which you can do with command line based mining. <h2>Linux <p dir="auto">For Linux you need the htmlcoind and the htmlcoin-cli executables in the src/ directory of your installation path of HTML Coin. First you want to to start htmlcoind: <pre><code>./htmlcoind <p dir="auto">When the deamon is running, synced and connected with the network, you can run the htmlcoin-cli generate commands. E.g: <pre><code>./htmlcoin-cli generate 100 99999999 <h3>Shellscripts <p dir="auto">Now we want to automate this and let the computer do the spamming for us. For this we use the <a href="https://github.com/richardjoo/HTMLCOIN/blob/master/mining/htmlcoin-cli-mining/htmlcoin-cli-mining.sh" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">script<br /> from <a href="https://github.com/richardjoo" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">richardjoo: <pre><code>#!/bin/bash # if this file is not executable, plese make sure this file is executable # copy the line below without the # sign and press enter # chmod +x htmlcoin-wallet-mining.sh # now you can run this file by typing # ./htmlcoin-wallet-miining.sh clear count=1 echo "HTMLCoin wallet mining started..." echo # change directory into wallet folder. If the folder name is different, then change to the correct folder name cd HTMLCOIN while true; do echo "$count: $(date)" echo "$count: $(date)" >> wallet-mining.log # change the address to your address src/htmlcoin-cli generatetoaddress 100 YOUR-RECEIVE-ADDRESS 7777777 >> wallet-mining.log (( count++ )) done <p dir="auto"><em>htmlcoin-cli-mining.sh, <a href="https://github.com/richardjoo/HTMLCOIN" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">scripts and instructions from <a href="https://github.com/richardjoo" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">richardjoo. You have to replace YOUR-RECEIVE-ADDRESS with your actual receiving address, <a href="https://github.com/richardjoo/HTMLCOIN/blob/master/mining/htmlcoin-cli-mining/htmlcoin-cli-mining.sh" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Source. <p dir="auto">This is very staright forward, it will simple execute "generatetoaddress 100 YOUR-RECEIVE-ADDRESS 7777777" endless times and writes the result in a log file. This is one way to automate your mining both for single and multiple instance mining. You can just start the script multiple times and it will run endless. The repo also contains a script for multiple instance mining, htmlcoin-cli-mining-multiple.sh. On startup it will ask you how many miners you want to run. <p dir="auto">Another interesting way to automate everything, including the daemon start, are the <a href="https://github.com/cl04ker/HTMLCOIN-Scripts" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">scripts from <a href="https://github.com/cl04ker" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">cl04ker. We want to take a look at the linux-start.sh script: <pre><code>#!/bin/bash # Variables RECADR="" MINERS= COUNT=0 C=1 MAIN_LOG="../HTMLCOIN-Logs/htmlcoin-miner-main.log" # Functions start_daemon(){ /usr/local/bin/htmlcoind --daemon --rpcthreads=$MINERS } check_daemon(){ echo "Checking that the daemon is up." echo while true; do /usr/local/bin/htmlcoin-cli getinfo > /dev/null 2>&1 RETVAL="$?" echo "GetInfo Return Value = $RETVAL" if [ $RETVAL -ne "0" ] then sleep 5 continue else break fi done echo echo "Checking that the daemon is in sync. Money must be higher than 0." echo while true; do MONEY="$(/usr/local/bin/htmlcoin-cli getinfo | grep moneysupply | awk '{ print $2 }' | rev | cut -c 2- | rev)" BLOCKS="$(/usr/local/bin/htmlcoin-cli getinfo | grep blocks | awk '{ print $2 }' | rev | cut -c 2- | rev)" echo "Money = $MONEY" echo "Blocks = $BLOCKS" if [ $MONEY -eq "0" ] then sleep 5 continue else break fi done echo echo "Connections must be greater than 4 to continue with mining... Please wait..." echo while true; do CONNECTIONS="$(/usr/local/bin/htmlcoin-cli getinfo | grep connections | awk '{ print $2 }' | rev | cut -c 2- | rev)" echo "Connections = $CONNECTIONS" if [ $CONNECTIONS -lt "5" ] then sleep 10 continue else break fi done } start_mining(){ while true; do shopt -s lastpipe /usr/local/bin/htmlcoin-cli generatetoaddress 100 $RECADR 88888888 | readarray -t BLOCK { echo "$2 Block Count:$C $(date)" & echo "Block Output: ${BLOCK[@]}"; } | tac | tee -a $1 $MAIN_LOG > /dev/null (( C++ )) done & } # Entrypoint... # Set up logging directory if it is not already there. mkdir -p ../HTMLCOIN-Logs # Remove any previous log files that may have been left from a previous mining session. rm -f ../HTMLCOIN-Logs/* touch $MAIN_LOG while [ -z $MINERS ] do echo echo -n 'How many miners do you want to run?' echo read MINERS done echo echo "Please enter your receive address:" read RECADR echo start_daemon echo # Check to make sure the daemon is in sync. check_daemon echo echo "Please wait while the miners are started!" echo while [ $COUNT -lt $MINERS ] do touch ../HTMLCOIN-Logs/htmlcoin-miner-$COUNT.log start_mining ../HTMLCOIN-Logs/htmlcoin-miner-$COUNT.log Miner-$COUNT (( COUNT++ )) sleep 2 done echo -e "\e[1m\e[92mStart up complete! Now run ./show-blocks.sh to check the logs for blocks.\e[0m" echo <p dir="auto"><em>linux-start.sh script from <a href="https://github.com/cl04ker" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">cl04ker, <a href="https://github.com/cl04ker/HTMLCOIN-Scripts/blob/master/linux-start.sh" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Source. <p dir="auto">I use that script myself, because it's very comfortable. It start's the daemon and waits until it is in sync and has enough connections to the network (in order to generate blocks you need four active connections). Then the script asks how many miners you want to run and what is your receiving address. However, you can comment out the "Please enter your receive address:" Block and set your address as a variable in the beginning of the script. Every return value of a generate command gets logged, it's like above, empty brackets [] mean you dont't found anything. <p dir="auto">The repo also contains scripts for watching the logs or updating the wallet, check them out! <h2>Windows <p dir="auto">For Windows you need to download the <a href="https://github.com/HTMLCOIN/HTMLCOIN/releases/download/v2.0.1.0/htmlcoind-2.0.1-win32.zip" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">source files for win. Extract them somewhere, the folder contains the same tools we already used on Linux: htmlcoind and htmlcoin-cli. It also includes a start_mining.cmd command line programm. Inside the script you need to change the line with <pre><code>htmlcoin-cli.exe generate 1 <p dir="auto">to <pre><code>htmlcoin-cli.exe generatetoaddress 100 <YOUR RECEIVING ADDRESS> 9999999 <p dir="auto">or whatever generate parameters you prefer. So the script should look like this: <pre><code>@echo off REM Start HTMLCOIN. Make sure that HTMLCOIN-Qt is not running when you start this script. echo Starting htmlcoind echo. start htmlcoind.exe REM Wait for 10 seconds to make sure the client has started. echo Waiting 10 seconds for HTMLCOIN to start. htmlcoind will open in a blank window, please leave it running. CTRL + C to terminate this script, run stop_htmlcoind.cmd to shutdown htmlcoind.exe. echo. timeout /t 10 /nobreak > NUL REM Mining loop, it will try to mine every 60 seconds which will fail until the 999999999 have been exhausted, ignore the errors. set "count=1" echo Entering mining loop. :loop echo Mining loop: %count% htmlcoin-cli.exe generatetoaddress 100 <YOUR RECEIVING ADDRESS> 99999999 set /A count=count+1 goto loop <p dir="auto"><em>satrt_mining.cmd for Windows, <a href="https://github.com/HTMLCOIN/HTMLCOIN/releases/tag/v2.0.1.0" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Source. <p dir="auto">You can start the script multiple times. Don't worry because the script tries to start the daemon multiple times, the later started daemons will close and only one htmlcoind will be started. Note: The htmlcoind daemon uses the chain data from you HTML QT wallet, so first open your wallet and let it sync. Then close the wallet and start cli mining. If you are getting errors, just wait, perhaps the client is not fully connected yet or you need to sync the last bit of data before start mining. <p dir="auto"><a href="https://s3-eu-west-1.amazonaws.com/public-images-social/html-cli-win.png" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link"><img src="https://images.hive.blog/768x0/https://s3-eu-west-1.amazonaws.com/public-images-social/html-cli-win.png" srcset="https://images.hive.blog/768x0/https://s3-eu-west-1.amazonaws.com/public-images-social/html-cli-win.png 1x, https://images.hive.blog/1536x0/https://s3-eu-west-1.amazonaws.com/public-images-social/html-cli-win.png 2x" /><br /> <em>Multiple session mining in Windows. <h1>Resources / References <p dir="auto"><a href="https://www.youtube.com/watch?v=oinNy5iMfC0" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">How to install multiple qt coin wallets, YouTube<br /> <a href="https://www.youtube.com/watch?v=xCcNfFRkDEA" title="This link will take you away from hive.blog" target="_blank" rel="nofollow noreferrer noopener" class="external_link">02 : Getting Started HTMLCOIN v2 : Generating Blocks (official), YouTube<br /> <a href="https://www.reddit.com/r/htmlcoin_community/comments/7ma7yq/html5html_coin_quick_guide_around/" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">General HTML Coin Quickguid, Reddit<br /> <a href="https://github.com/richardjoo/HTMLCOIN/blob/master/FAQ/README.md" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">General HTML Coin FAQ, GitHub<br /> <a href="https://www.reddit.com/r/htmlcoin_community/comments/7pmh9y/html_coin_mining_with_cli_for_windows/dsigq2g/" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Win CLI Mining, Reddit
Sort:  

Congratulations @daveiano! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

<p dir="auto"><a href="http://steemitboard.com/@daveiano" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link"><img src="https://images.hive.blog/768x0/https://steemitimages.com/70x80/http://steemitboard.com/notifications/posts.png" srcset="https://images.hive.blog/768x0/https://steemitimages.com/70x80/http://steemitboard.com/notifications/posts.png 1x, https://images.hive.blog/1536x0/https://steemitimages.com/70x80/http://steemitboard.com/notifications/posts.png 2x" /> Award for the number of posts published<br /> <a href="http://steemitboard.com/@daveiano" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link"><img src="https://images.hive.blog/768x0/https://steemitimages.com/70x80/http://steemitboard.com/notifications/voted.png" srcset="https://images.hive.blog/768x0/https://steemitimages.com/70x80/http://steemitboard.com/notifications/voted.png 1x, https://images.hive.blog/1536x0/https://steemitimages.com/70x80/http://steemitboard.com/notifications/voted.png 2x" /> Award for the number of upvotes received <p dir="auto">Click on any badge to view your own Board of Honor on SteemitBoard. <p dir="auto">To support your work, I also upvoted your post!<br /> For more information about SteemitBoard, click <a href="https://steemit.com/@steemitboard" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">here <p dir="auto">If you no longer want to receive notifications, reply to this comment with the word <code>STOP <blockquote> <p dir="auto">Upvote this notification to help all Steemit users. Learn why <a href="https://steemit.com/steemitboard/@steemitboard/http-i-cubeupload-com-7ciqeo-png" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">here!

Your Post Has Been Featured on @Resteemable!
Feature any Steemit post using resteemit.com!
How It Works:
1. Take Any Steemit URL
2. Erase https://
3. Type re
Get Featured Instantly � Featured Posts are voted every 2.4hrs
Join the Curation Team Here | Vote Resteemable for Witness