Skip to content

Repository files navigation

hash256-miner-c

High-performance C miner for hash256.org (HASH token, contract 0xAC7b5d06fa1e77D08aea40d46cB7C5923A87A0cc) on Ethereum mainnet.

Uses AVX-512 8-way Keccak-1600 SIMD for ~50-100x speedup over the official Node.js reference miner.

Architecture

flowchart TD
    O["orchestrator/orchestrator.js<br/>(Node.js + ethers.js)<br/>· fetch challenge from contract<br/>· spawn miner subprocess<br/>· submit mine(nonce) tx<br/>· refresh on new epoch<br/>· 5 pre-flight checks<br/>· write stats.json"]
    M["bin/miner (C, AVX-512 SIMD)<br/>· args: challenge_hex target_hex --threads N<br/>· 4 pthreads x 8-way AVX-512<br/>· 32 Keccak permutations per cycle<br/>· prints FOUND nonce hash on hit"]
    SRV["monitor/server.js (Node.js + express)<br/>· read stats.json + miner.log<br/>· web dashboard on :7878<br/>· REST API: /stats /log /network"]
    RPC((Ethereum RPC<br/>publicnode/llamarpc/ankr))

    O -- "spawn subprocess<br/>per challenge" --> M
    M -- "stdout: FOUND<br/>stderr: hashrate" --> O
    O -- "tx mine(nonce)" --> RPC
    RPC -- "challenge, gas, receipt" --> O
    O -.write.-> STATS[(stats.json)]
    O -.write.-> LOG[(miner.log)]
    SRV -.read.-> STATS
    SRV -.read.-> LOG
    SRV --> RPC
Loading

For deep-dive on Keccak SIMD, threading, pre-flight checks — see docs/ARSITEKTUR.md.

Performance Targets

Setup Hashrate Time per solution*
Scalar C, 1 thread ~10-20 MH/s 4-8 hours
Scalar C, 4 threads ~40-80 MH/s 1-2 hours
AVX-512 8-way, 4 threads ~320-600 MH/s 8-15 minutes

*At current difficulty (~2.75 × 10¹¹ hashes per solution).

GPU support?

No GPU support in this repo — pure CPU AVX-512 SIMD. Designed for cheap VPS rentals (~$15-30/mo) which beat GPU rentals on cost-per-HASH at current difficulty.

For full analysis (when GPU becomes worth it, hashrate comparison, CUDA porting roadmap), see docs/GPU-PORTING.md.

TL;DR economics at current difficulty (~Mei 2026):

Setup Hashrate Cost/month $/HASH minted
CPU AVX-512 4-vCPU VPS ~450 MH/s ~$16 ~$0.00039
GPU rental RTX 4090 ~15 GH/s ~$350 ~$0.00046
Bare metal RTX 4090 ~15 GH/s ~$80 (electric) ~$0.00006 (best!)

Stick with CPU unless you own GPU hardware or difficulty raises 100x.

Requirements

  • Linux x86-64 with AVX-512 (avx512f + avx512vl + avx512bw flags)
  • gcc 9+ or clang 10+
  • Node.js 18+
  • Ethereum wallet with small ETH balance for gas (~0.005 ETH = $11)

Verify your CPU supports AVX-512:

grep -oE 'avx512f|avx512vl|avx512bw' /proc/cpuinfo | sort -u
# Expected output: avx512bw\navx512f\navx512vl

Setup

1. Build the C miner

make
# Produces ./bin/miner (single static binary)

2. Run self-test (no network required)

make test
# Verifies AVX-512 SIMD output matches scalar reference for 100 random inputs

3. Setup orchestrator

cd orchestrator
npm install
cp .env.example .env
# Edit .env on the machine that will run the miner. NEVER commit .env.

.env contents:

RPC_URL=https://ethereum-rpc.publicnode.com
PRIVATE_KEY=0xPRIVATE_KEY_BARU_KAMU
THREADS=4
GAS_LIMIT=200000

4. Run

cd orchestrator
node orchestrator.js

Output:

[orchestrator] wallet:    0xABC...
[orchestrator] balance:   0.005 ETH
[orchestrator] challenge: 0x123...
[orchestrator] difficulty: 4.21e62
[orchestrator] spawning miner with 4 threads
[miner]       benchmark : 480 MH/s aggregate
[miner]       searching ...
[miner]       FOUND nonce=12345678901234
[orchestrator] submitting mine(12345678901234)
[orchestrator] tx hash:   0xabc...
[orchestrator] confirmed: block 25069300, reward 100 HASH
[orchestrator] new challenge ...

Security

  • Never commit .env. The .gitignore blocks it but verify yourself.
  • Use a fresh wallet dedicated to mining. Funding only as much ETH as needed for gas.
  • PRIVATE_KEY only in .env on the machine running the miner. Never paste in chat, IDE, git, or share.
  • Compromised PK = total loss of funds in that wallet. With a dedicated mining wallet, max loss is your gas budget.

Files

hash256-miner-c/
├── src/
│   ├── miner.c              # Main: argv parse, threading, FOUND detection
│   ├── keccak_scalar.{h,c}  # Scalar Keccak-256 (reference + verification)
│   ├── keccak_avx512.{h,c}  # AVX-512 8-way Keccak-1600 SIMD
│   └── util.h               # Hex parsing, BE/LE conversion
├── tests/
│   └── test_keccak.c        # Verifies SIMD vs scalar match
├── orchestrator/
│   ├── orchestrator.js      # Node.js controller
│   ├── package.json
│   └── .env.example
├── Makefile
├── deploy.sh                # rsync to VPS + remote build + run
├── .gitignore
└── README.md

Deployment to VPS

./deploy.sh <user>@<your-vps-host>
# Then SSH in to set up .env on the VPS itself:
ssh <user>@<your-vps-host>
cd ~/hash256-miner-c/orchestrator
nano .env  # paste PRIVATE_KEY locally on VPS
node orchestrator.js

For 24/7 operation:

nohup node orchestrator.js > miner.log 2>&1 &

Or via systemd (see deploy/systemd.service template).

Documentation

Detailed docs in Bahasa Indonesia at docs/:

Doc Topic
docs/README.id.md Overview ringkas + quick start (Bahasa Indonesia)
docs/INSTALASI.md Install dari nol — verify AVX-512, build, setup wallet, fund ETH, .env
docs/PEMAKAIAN.md Run foreground/systemd/watchdog, monitoring, withdraw HASH, troubleshoot
docs/ARSITEKTUR.md Internal: Keccak vs SHA-256, AVX-512 SIMD, threading, pre-flight checks
docs/GPU-PORTING.md Why CPU-only, when GPU becomes worth-it, CUDA roadmap
docs/KONFIGURASI.md Reference for every .env field, RPC providers, tuning gas + threads

License

MIT — see LICENSE. Keccak SIMD implementation derived from public-domain XKCP code by The Keccak Team.

About

High-performance CPU miner for hash256 HASH token on Ethereum mainnet — Keccak-256 with AVX-512 8-way SIMD.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages