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.

At first you need to download and install the latest HTML Wallet. In case you are mining on CentOS, I have written another tutorial on how to install the wallet since I had some problems doing so.

Note: CPU only single mining is the only way to mine, there are no mining pools available to this day.

Single QT Wallet Mining

Just start the wallet and click on "Help" and on "Debug Window" and then "Console". Now you can type commands to run.


Click on "Help" and on "Debug Window" and then "Console" to get to the console.


A list of all available commands.

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:

generate 100 99999999

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 (generate 100 99999999 will run approximately 3 min and 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:

[
]

These are empty sqaure brackets, it means you found nothing, if it returns this:

[
  "0000000006b9b5aec68faf150e6cbc9ce71653a622f25b977a4835a57498a8e1"
]

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:

generatetoaddress 100 <YOUR ADDRESS> 999999999

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.

Multiple QT Wallet Mining

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.

Linux

On a Linux computer you do can do this with these commands:

# 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

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.

Windows

On Windows you need these commands:

# 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"

--datadir specifies where the application saves the blockchain and the wallet file.


Multiple wallets on the same computer.

You can create startup one click scripts by saving this into a file called e.g. start-wallet-1.cmd, for wallet-1:

"C:\Program Files (x86)\HTMLCOIN2\htmlcoin-qt.exe" --datadir=C:\Users\<YOUR_NAME>\AppData\Roaming\HTMLCOIN_1

For wallet two, create a file start-wallet-2.cmd:

"C:\Program Files (x86)\HTMLCOIN2\htmlcoin-qt.exe" --datadir=C:\Users\<YOUR_NAME>\AppData\Roaming\HTMLCOIN_2

.. and so on. With multiple wallets open, you can open multiple consoles and run multiple generate commands at the same time!


Multiple wallets mining on the same computer.

CLI Mining

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.

Linux

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:

./htmlcoind

When the deamon is running, synced and connected with the network, you can run the htmlcoin-cli generate commands. E.g:

./htmlcoin-cli generate 100 99999999

Shellscripts

Now we want to automate this and let the computer do the spamming for us. For this we use the script
from richardjoo:

#!/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

htmlcoin-cli-mining.sh, scripts and instructions from richardjoo. You have to replace YOUR-RECEIVE-ADDRESS with your actual receiving address, Source.

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.

Another interesting way to automate everything, including the daemon start, are the scripts from cl04ker. We want to take a look at the linux-start.sh script:

#!/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

linux-start.sh script from cl04ker, Source.

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.

The repo also contains scripts for watching the logs or updating the wallet, check them out!

Windows

For Windows you need to download the 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

htmlcoin-cli.exe generate 1

to

htmlcoin-cli.exe generatetoaddress 100 <YOUR RECEIVING ADDRESS> 9999999

or whatever generate parameters you prefer. So the script should look like this:

@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

satrt_mining.cmd for Windows, Source.

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.


Multiple session mining in Windows.

Resources / References

How to install multiple qt coin wallets, YouTube
02 : Getting Started HTMLCOIN v2 : Generating Blocks (official), YouTube
General HTML Coin Quickguid, Reddit
General HTML Coin FAQ, GitHub
Win CLI Mining, Reddit

Sort:  

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

Award for the number of posts published
Award for the number of upvotes received

Click on any badge to view your own Board of Honor on SteemitBoard.

To support your work, I also upvoted your post!
For more information about SteemitBoard, click here

If you no longer want to receive notifications, reply to this comment with the word STOP

Upvote this notification to help all Steemit users. Learn why 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