Zcash and Mining

2016-11-04

zcash

A simple guide to Zcash mining on Linux. Personally I use a flavor or Debian/Ubuntu and the guide will follow that setup.

Reference: https://z.cash/

Requirements

Currently, you will need:

  • Linux (easiest with a Debian-based distribution)
  • 64-bit
  • 4GB of free memory

We’ll build the binaries from git, so let’s get started here.

  1. Get git
  2. Get the source code for Zcash
  3. Get the source code for the miner

1 Git

sudo apt-get install git
mkdir ~/git
cd ~/git
git clone https://github.com/zcash/zcash.git

git clone https://github.com/sarath-hotspot/nheqminer

2 Zcash

Build Zcash

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
cd zcash/
git checkout v1.0.1
./zcutil/fetch-params.sh
./zcutil/build.sh -j$(nproc)

Configuration

Create the ~/.zcash directory and place a configuration file at ~/.zcash/zcash.conf using the following commands:

mkdir -p ~/.zcash
echo "addnode=mainnet.z.cash" >~/.zcash/zcash.conf
echo "rpcuser=username" >>~/.zcash/zcash.conf
echo "rpcpassword=`head -c 32 /dev/urandom | base64`" >>~/.zcash/zcash.conf

Note that this will overwrite any zcash.conf settings you may have added from testnet. You can retain a zcash.conf from testnet, but make sure that the testnet=1 andaddnode=betatestnet.z.cash settings are removed; use addnode=mainnet.z.cash instead. We strongly recommend that you use a random password to avoid potential security issues with access to the RPC interface.

Enabling CPU mining:

If you want to enable CPU mining, run these commands:

echo 'gen=1' >> ~/.zcash/zcash.conf
echo "genproclimit=$(nproc)" >> ~/.zcash/zcash.conf

The default miner is not efficient, but has been well reviewed. To use a much more efficient but unreviewed solver, you can run this command:

echo 'equihashsolver=tromp' >> ~/.zcash/zcash.conf

Note, you probably want to read the Mining-Guide to learn more mining details.

Running Zcash:

Now, run zcashd!

./src/zcashd

To run it in the background (without the node metrics screen that is normally displayed) use./src/zcashd --daemon.

You should be able to use the RPC after it finishes loading. Here’s a quick way to test:

./src/zcash-cli getinfo

Now, get your t-address so you can mine to it in the next step:

./zcash-cli listreceivedbyaddress 0 true
[
 {
 "address" : "t1QaK1YLzaqw9m42eFrUTk5SUPn1RFnkhpE",
 "account" : "",
 "amount" : 0.00000000,
 "confirmations" : 0,
 "txids" : [
 ]
 }
]

Copy the address from your terminal output.

3 Mining

The default miner is not the best one, the “nheqminer” is much more efficient.

You should have CMake installed (2.8 minimal version), boost (install from the repositories or download boost manually build and install it manually), download the sources manually or via git. Under Ubuntu open a terminal and run the following commands:

sudo apt-get install cmake build-essential libboost-all-dev
cd nheqminer/nheqminer
mkdir build

cd build
cmake ..
make

Run instructions:

If run without parameters, miner will start mining with 75% of available virtual cores on NiceHash. The memory requirements for mining efficiently are around 1 GB of RAM (#856), so you will need that much free memory per mining thread. Use parameter -h to learn about available parameters:

    -h              Print this help and quit
    -l [location]   Location (eu, usa, hk, jp)
    -u [username]   Username (bitcoinaddress/t-zcashaddress)
    -p [password]   Password (default: x)
    -t [num_thrds]  Number of threads (default: number of sys cores)
    -d [level]      Debug print level (0 = print all, 5 = fatal only, default: 2)
    -b [hashes]     Run in benchmark mode (default: 100 hashes)
    -a [port]       Local API port (default: 0 = do not bind)

Example to mine with your own t-Zcash address and worker1, using 4 threads:

    ./nheqminer -u t1QaK1YLzaqw9m42eFrUTk5SUPn1RFnkhpE.freyaworker1 -t 4

Or

    ./nheqminer -u 1GvsbEGHQgwSzUvCR4pv2Qha6rxUgZSSw2.envyworker1 -t 4

Your mining statistics will show up here: https://zcash.nicehash.com/workers

References:

https://github.com/nicehash/nheqminer
https://zcash.nicehash.com/

Good Luck mining Zcash!

Knapp till bloggen english

Leave a Reply

Your email address will not be published. Required fields are marked *