Posted by: Gibson Ashpool June 25, 2016 © mineZcash.com
Updated For Main-net 12/16/2016
UPDATED Feb 2017: This Tutorial is still good for learning to mine Zcash with a CPU but you will want to use a GPU for the best results. Visit my new site for the new mining tutorials: https://www.zcashcommunity.com/mining
Welcome to Part 3 of the how to mine Zcash tutorial. In Part 1 and Part 2 we covered how to install Ubuntu Linux for running Zcash and began working with some basic functionality and updated our Ubuntu install. I’m going to assume you have followed those two guides closely before beginning this Part 3.
I will be working directly off of the Zcash Sprout 1.0 Guide for this tutorial and adding my own hints and tips along the way. The Zcash Sprout guide is a great resource for those who are familiar with Linux but many of the terms can be confusing for someone with no prior Linux experience. If something in this tutorial seems wrong or possibly out of date always double check the codes here with the Zcash Sprout versions.
So lets get to it!
Downloading
First thing you will have to do is open your Terminal (explained in part 2) and begin installing what are known as dependencies that Zcash requires your Linux system to have before Zcash will run. Think of a dependency as a building block for Zcash to run on.
We begin with entering:
sudo apt-get install \ build-essential pkg-config libc6-dev m4 g++-multilib \ autoconf libtool ncurses-dev unzip git python \ zlib1g-dev wget bsdmainutils automake
You will notice that “sudo” command again which will allow you to install the packages as a superuser.
Once those dependencies have completed installing we can fetch the Zcash repository:
git clone https://github.com/zcash/zcash.git
Now once that has completed if you go into your files directory you will notice a new folder called zcash with several files inside. These files will serve as the instruction set for running the rest of our installation.
To get to these files with the Terminal we need to learn a little more about how to navigate inside the Terminal: The command “cd” is used to “change directories” in the Terminal and will allow you to begin running commands via the Terminal from inside a directory. Up until now we have been working in the Home directory so our command line looks like this:
but to get into our zcash folder/directory we need to type cd zcash then our command line will look like this:
This is a critical difference because if you are trying to run the rest of the commands below from the wrong directory you will get an error like “no such file or directory” You can Navigate into any directory this way and we can Navigate back up a level by typing cd .. lastly we can always Navigate back to the Home directory by entering cd ~
Ok, now that you understand a little about navigating in-to and out-of directories in the Terminal we need to be inside the zcash directory and enter this command:
git checkout v1.0.5 ./zcutil/fetch-params.sh
IMPORTANT: This tutorial is out-of-date, see the official guide for latest Zcash Version
This will fetch the public alpha proving and verifying keys and place them into a new folder called .zcash-params. These keys are about 950MB so they will take a while to download.
Compiling
Once those parameters have downloaded then we are ready to begin compiling. Check your VM’s settings to be sure you give the VM at least 4GB of RAM for the compilation. If you did not give your VM 4GB it may fail to compile! (running Zcash does not require 4GB but compiling does) To start Compiling enter:
./zcutil/build.sh -j$(nproc)
(Don’t forget that you needed to be in the zcash directory to run!) This build will take a while to run and will compile the dependencies and build zcashd. Zcashd is the primary program that runs Zcash. One that has successfully completed, Congratulations! You have just finished installing Zcash!
Testing before Running
Now we can Test to see if everything was installed correctly by using a few utilities that are included with Zcash. I recommend at least running the first test:
./qa/zcash/full-test-suite.sh
You can also check the build with a RPC test but it will take much longer:
./qa/pull-tester/rpc-tests.sh
Running
Before we can run Zcash we have to create a new directory and place a configuration file with some parameters in it. To do this first open your Home directory by clicking the files icon on the Launcher. Inside your home directory you see several files like pictures, documents, etc, and of course the important zcash folder. But you also need to see the Hidden Files in this directory. Use CTRL+H to show the hidden files in any directory. You will notice that Linux treats any file starting with a period “.” at the beginning of its name as a hidden folder.
Zcash looks for configurations in a hidden folder called .zcash so we can make one by Right-Clicking and create a New Folder, Now name that folder
. Next we open up that .zcash folder and create a document inside of it; Right-Click again to create New Document–>Empty Document.This document will be your primary configuration file for Zcash so we need to enter this information into the document:
addnode=mainnet.z.cash rpcuser=username rpcpassword= [choose a random password!]
Click on Save and then name that file you just created zcash.conf Now you have a configuration file for Zcash. This zcash.conf file you just made is very important since tells Zcash several things like your username, password, the node to connect to, if you are on a testnet , etc..
Or if you want to just create the zcash.conf file and a random password automatically via command line use this:
$mkdir -p ~/.zcash $ echo "rpcuser=username" >~/.zcash/zcash.conf $ echo "rpcpassword=`head -c 32 /dev/urandom | base64`" ~/.zcash/zcash.conf~/.zcash/zcash.conf
NOTE: above code is for more advanced users, run from the home directory and will overwrite any contents of the zcash.conf folder.
Now that we have a configuration file we can start Zcash:
./src/zcashd
And you should see a message saying zcash server starting; You are Now Running Zcash! This Zcash server has to be running for you to give it any commands like receiving, transferring, protecting, spending coins, etc… but with the current configuration file we are not actually mining yet.
Start Mining
I have purposely separated the Running section from the Mining section even though they are actually the same thing. The difference is that you need set up the configuration file differently to also be mining while the server is running. I wanted to show you how to stop and start the server so you can change configurations as needed and there may be times (since we are only on a testnet) that you will want to try different configurations with Zcash without the miner hogging up all of your computers resources.
When you have the server running you can use these to commands to stop and to re-start it:
./src/zcash-cli stop
./src/zcashd -daemon
Keep in mind that after issuing either of these commands it will take some time for the processes to start/stop, be patient.
Once you have stopped the server, go back into the zcash.conf file and add one more line of text:
gen=1
When you restart Zcash with the updated configuration file in place you will be officially Mining Zcash! You will notice that your CPU will begin pegging as it begins solving to find blocks on the testnet!
Additionally there are few other commands that you can add to the zcash.conf file to ensure you are mining at top performance:
genproclimit=4 equihashsolver=tromp
The genproclimit command will set the number of cores you have mining, so change the number to your CPU’s number of cores. And be sure to add the Tromp solver command because it is much faster than the default solver.
Whoo Hoo!! You Made it! You are now a Zcash Miner!
To check your mining progress you can use the command:
./src/zcash-cli getinfo
You may not see anything immediately; give your computer time to connect to the network. You can also check on your transactions and balance with these commands:
./src/zcash-cli listtransactions
./src/zcash-cli z_gettotalbalance
Any coins listed as generated are the the coins you’ve mined and you can spend. Any coins labeled as category: immature are coins you have mined but are awaiting 100 confirmations from the network before they can be spent.
UPDATED Feb 2017: This Tutorial is still good for learning to mine Zcash with a CPU but you will want to use a GPU for the best results. Visit my new site for the new mining tutorials: https://www.zcashcommunity.com/mining
Now that you have a basic understanding of how Zcash and Linux works you can head over and follow the 1.0 Sprout Guide to spend/receive your Zcash.
If you liked this guide please show me some love by sharing with your friends on twitter, facebook, reddit by linking here.
Or make a BTC donation
15VZNqUazPKoK8rJMFb5XUzuB4o6Ww6xD3
This site is only a one man operation and any good press helps keep it alive.
Please stop by the Zcash Forums if you get stuck.
Questions or Comments? Please contact me: mineZcash@gmail.com