> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kronex.network/llms.txt
> Use this file to discover all available pages before exploring further.

# Mining

> Two ways to mine Kronex: kHeavyHash directly, or merge-mined from four other proof-of-work chains.

Kronex can be mined two ways, and they are not alternatives — both run at once.

|            | Algorithm                         | What you mine                                     | What you earn                                        |
| ---------- | --------------------------------- | ------------------------------------------------- | ---------------------------------------------------- |
| **Direct** | kHeavyHash                        | Kronex blocks                                     | The block reward                                     |
| **Merged** | SHA256d, Scrypt, KawPoW, Equihash | Bitcoin Cash, Litecoin, Ravencoin or Zcash blocks | Workshare rewards, on top of the parent-chain payout |

This page covers direct mining. For merged mining, read
[Merged mining](/learn/merged-mining) for how it works and
[Pool integration](/guides/pool-integration) for the full node-to-pool contract.
The short version: work already being done on one of those four chains can commit
to Kronex as well and be paid for it, without giving up the parent-chain reward
and without changing what the hardware is doing.

## Direct mining

Kronex is sealed with kHeavyHash. The pre-image matches Kaspa byte for byte, so
GMiner, lolMiner, BzMiner, IceRiver and Goldshell hardware all mine Kronex with
no firmware change. Only the source of work differs.

## What the node must be doing

A node hands out work only when it is building blocks:

```bash theme={null}
krnxd --http --http.api eth,krnx,net,web3 --http.addr 127.0.0.1 --http.port 8545 \
      --mine --miner.threads 0 --miner.etherbase 0xYOUR_ADDRESS --miner.recommit 3s
```

| Flag                 | Why                                                              |
| -------------------- | ---------------------------------------------------------------- |
| `--mine`             | without it no pending block is built and `krnx_getWork` errors   |
| `--miner.threads 0`  | stops the node's own CPU mining while templates keep being built |
| `--miner.etherbase`  | the address the block reward is credited to                      |
| `--miner.recommit`   | how often the template is rebuilt                                |
| `--miner.notify URL` | optional: the node POSTs new work to your pool                   |

The reward goes to the node's **etherbase**. A stratum login is only an
accounting label as far as the chain is concerned.

## Three methods

| Method                                            | Returns                               |
| ------------------------------------------------- | ------------------------------------- |
| [`krnx_getWork`](/rpc/krnx/getWork)               | an 11-element array: the work package |
| [`krnx_submitWork`](/rpc/krnx/submitWork)         | `true` / `false`                      |
| [`krnx_submitHashrate`](/rpc/krnx/submitHashrate) | `true`, for the node's own stats      |

All three are mirrored under `eth_`, with the names stock go-ethereum uses, so
existing ethash pool code needs only its hashing swapped out.

```bash theme={null}
curl -s -X POST http://127.0.0.1:8545 \
  -H 'Content-Type: application/json' \
  --data '{"jsonrpc":"2.0","id":1,"method":"krnx_getWork","params":[]}' \
  | jq -r '.result[0,2,3]'
```

## Two things that break integrations

<Warning>
  **The timestamp is in seconds.** Kaspa headers use milliseconds. Index `[10]`
  of the work package is the header timestamp in seconds, and it is the `TIME`
  of the pre-image. Multiplying it by 1000 produces work nobody can solve.
</Warning>

<Warning>
  **Share difficulty and consensus difficulty are 2^32 apart.** Use the boundary
  at index `[2]`, which is already `2^256 / difficulty`, instead of converting
  network difficulty yourself.
</Warning>

`MixDigest` must be zero — kHeavyHash has no DAG, and consensus rejects a
non-zero digest.

## Running a pool

The full node-to-stratum contract, including the kaspa stratum dialect, the
pre-image construction, per-connection extranonce handling and worked code
examples, is in the [pool operator reference](/guides/mining-pool).
