Skip to main content

Mining Tools

How to mine?

If you want to mine in our testnet, first you need to install one of the available mining software, then you can use one of the public Hathor Stratum servers with them. Click here to see the list of full nodes available in our testnet.

Mining Algorithm

Hathor uses classic Proof-of-Work (PoW) consensus, with the same algorithm as Bitcoin for mining blocks: sha256d. The d in the end stands for double, meaning that sha256 is done twice. In other words, sha256(sha256(data)).

Mining Software

Hathor nodes implement a customized Stratum Protocol server that enable miners to request jobs and receive updates. For further details of our customization, see this document.

NOTE: Node owners can choose if they wish to run the stratum server or not. When connecting your miner to a node, make sure they have Stratum support enabled.

We have working forks of cpuminer, ccminer, and cgminer compatible with Hathor. For all of them, you need the hostname and port of a Hathor Stratum Server and a Hathor address that will receive the reward tokens when you find a new block.

cpuminer

GitHub Repository: https://github.com/HathorNetwork/cpuminer

Basic use is:

./minerd -a sha256d -o stratum+tcp://{hostname}:{port} --coinbase-addr {address}

You can choose the number of threads used by cpuminer with -t. If you omit this parameter, it will start as many threads as the number of cores in your machine.

./minerd -a sha256d -o stratum+tcp://{hostname}:{port} -t {num_threads} --coinbase-addr {address}

Run ./minerd --help to see all options.

ccminer

GitHub Repository: https://github.com/HathorNetwork/ccminer

Basic use is:

./ccminer -a sha256d -o stratum+tcp://{hostname}:{port} --coinbase-addr {address}

Run ./ccminer --help to see all options.

cgminer

GitHub Repository: https://github.com/HathorNetwork/cgminer

Basic use is:

./cgminer --url stratum+tcp://{hostname}:{port} --user x --btc-address {address}

Run ./cgminer --help to see all options.

Docker images

We've created Docker images to facilitate running our mining software. We'll publish these images to Docker Hub soon.

Development

There follows some useful snippets when you're developing a new mining software.

Convert weight to target in Python

def weight_to_target(weight: float) -> int:
    return int(2**(256 - self.weight) - 1)

Convert weight to target in C

void weight_to_target(uint32_t* target, double weight) {
    double calc = pow(2, 256 - weight);
    for(int i=0; i<8; ++i) {
        target[i] = fmod(calc, 4294967296L);
        calc /= 4294967296L;
    }
    for(int i=0; i<8; ++i) {
        if (target[i]) {
            target[i] = target[i] - 1;
            break;
        }
        target[i] = 4294967295L;
    }
}