← All documentation

Mining WarpCoin (CPU & GPU)

WarpCoin's proof of work is double SHA-256 over the 88-byte block header. Mining means finding a Nonce such that:

SHA256(SHA256(serialized_header)) <= target

interpreted as a big-endian 256-bit integer. Because the work function is plain SHA-256d, the search runs identically on CPUs, GPUs, FPGAs, or ASICs.

Header layout (88 bytes, big-endian)

Offset Size Field
0 4 Version
4 32 PrevHash
36 32 MerkleRoot
68 8 Timestamp
76 8 Height
84 4 Bits
88 8 Nonce

Only Nonce (the last 8 bytes) changes during the search. When the nonce space for a fixed header is exhausted, fetch fresh work (the timestamp/merkle root will have moved).

Built-in CPU miner

warpcoin node --mine --miner-address <addr> --cpus 8

The node assembles a candidate block from the highest-fee mempool transactions plus a coinbase to your address, then searches the nonce space across all worker threads, abandoning work the instant a competing block arrives.

Standalone miner (the GPU integration point)

warpcoin miner --rpc http://127.0.0.1:8339 --address <addr> --cpus 8

The standalone miner is a thin loop over the node's HTTP API:

  1. GET /getwork?address=<addr> → returns a candidate block and a hex target.
  2. Search nonces until SHA256d(header) <= target.
  3. POST /submitwork with the solved block.

getwork response

{
  "block":  { "header": { ... }, "transactions": [ ... ] },
  "target": "0000ffff00000000000000000000000000000000000000000000000000000000",
  "bits":   520159231,
  "height": 42
}

Writing a GPU miner

A CUDA/OpenCL miner implements the exact same loop:

  1. Call /getwork from host code, serialize the 88-byte header.
  2. Upload the first 80 bytes (everything but the nonce) and the target to the device; launch a kernel where each thread tries a range of nonces, computing SHA256(SHA256(header)) and comparing against the target.
  3. When a thread finds a hash <= target, copy the winning nonce back, set it on the block, and POST /submitwork.
  4. Periodically re-fetch work (e.g. once per second, or when /status shows the height advanced) so you never mine on a stale tip.

Because the header and hash function match Bitcoin's SHA-256d construction (different field layout, same primitive), existing SHA-256d GPU kernels can be adapted with only the header serialization changed.

Difficulty

Difficulty auto-adjusts every 60 blocks to hold the 30-second target block time. On a brand-new network the genesis target is intentionally easy so a single machine can start producing blocks immediately; it rises as hash power joins.