Skip to content

Yzgaming005/Minerhash

Repository files navigation

HASH256 GPU Miner (CUDA)

Mining HASH256 dengan akselerasi GPU CUDA untuk performa maksimal.

Perbandingan kecepatan:

  • CPU: ~100-500 KH/s (tergantung CPU)
  • GPU (CUDA): ~50-500+ MH/s (tergantung GPU, 100-1000x lebih cepat)

Fitur

  • Mining GPU dengan CUDA (Keccak-256 native kernel)
  • Dukungan Multi-GPU (semua GPU sekaligus)
  • Fallback CPU multi-threaded
  • Auto-detect GPU dan konfigurasi optimal
  • Persistent GPU memory allocation (zero-copy overhead)
  • Hashrate monitoring real-time

Kebutuhan

Hardware

  • NVIDIA GPU (Compute Capability 6.0+)
    • GTX 1060 / 1070 / 1080 / Ti
    • RTX 2060 / 2070 / 2080 / Ti
    • RTX 3060 / 3070 / 3080 / 3090
    • RTX 4060 / 4070 / 4080 / 4090
    • Tesla V100 / A100 / H100
  • Minimal 2GB VRAM

Software

  • Ubuntu 20.04+ / Windows 10+
  • NVIDIA Driver 470+
  • CUDA Toolkit 11.0+ (nvcc compiler)
  • Node.js 18+
  • npm
  • node-gyp + build tools

Install (Ubuntu/Linux)

1. Install NVIDIA Driver + CUDA

# Install NVIDIA driver
sudo apt update
sudo apt install -y nvidia-driver-535

# Install CUDA Toolkit
sudo apt install -y nvidia-cuda-toolkit

# Verify
nvidia-smi
nvcc --version

Atau download CUDA dari: https://developer.nvidia.com/cuda-downloads

2. Install Node.js & Build Tools

# Node.js 22
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo bash -
sudo apt install -y nodejs

# Build tools untuk native addon
sudo apt install -y build-essential python3

3. Clone & Setup

git clone https://github.com/mrfunntastiic/hash256-cli.git
cd hash256-cli

# Install dependencies
npm install

# Setup environment
cp .env.example .env
nano .env

Isi .env:

RPC_URL=https://ethereum-rpc.publicnode.com
PRIVATE_KEY=0xPRIVATE_KEY_WALLET_KAMU

4. Build CUDA Kernel

chmod +x scripts/build-cuda.sh
./scripts/build-cuda.sh

Output yang diharapkan:

=== HASH256 GPU Miner - CUDA Build ===
NVCC Version: 12.x
Detected GPU Compute Capability: 8.6
Compiling CUDA kernel...
CUDA kernel compiled: cuda/keccak256.o
Building Node.js native addon...
=== Build Complete ===

Install (Windows)

1. Install Prerequisites

2. Build

git clone https://github.com/mrfunntastiic/hash256-cli.git
cd hash256-cli

npm install
copy .env.example .env
notepad .env

scripts\build-cuda.bat

Menjalankan Miner

Single GPU (Default)

npm start
# atau
node miner-gpu.js

Multi-GPU (Semua GPU)

npm run start:multi
# atau
node miner-gpu-multi.js

CPU Mode (Fallback tanpa GPU)

npm run start:cpu
# atau
node miner-cpu.js

Opsi Command Line

Single GPU

node miner-gpu.js [options]

Options:
  --device, -d    GPU device ID (default: 0)
  --threads, -t   Threads per block: 128/256/512/1024 (default: auto)
  --blocks, -b    Blocks per grid (default: auto)
  --help, -h      Tampilkan bantuan

Multi-GPU

node miner-gpu-multi.js [options]

Options:
  --devices, -d   GPU device IDs, comma-separated (default: all)
  --threads, -t   Threads per block (default: auto)
  --batches, -b   Batches per work unit (default: 50)
  --help, -h      Tampilkan bantuan

Contoh Output

===========================================
 HASH256 GPU Miner (CUDA)
===========================================

GPU Devices Found: 1
[GPU] Device: NVIDIA GeForce RTX 4090
[GPU] Compute Capability: 8.9
[GPU] Max Threads/Block: 1024
[GPU] Multiprocessors: 128
[GPU] Clock Rate: 2520 MHz
[GPU] Memory: 24564 MB

[GPU] Config: 256 threads/block, 16384 blocks, 4,194,304 nonces/launch

Initialized GPU Device 0
  Threads/Block: 256
  Blocks/Grid:   16384
  Nonces/Launch: 4,194,304

-------------------------------------------
Wallet:   0x...
Contract: 0xAC7b5d06fa1e77D08aea40d46cB7C5923A87A0cc
-------------------------------------------

=== New Mining Round ===
Era:        1
Reward:     50.0 HASH
Difficulty: 115792089237...
Challenge:  0xabc123...

[GPU] Batch #30 | 285.47 MH/s | Tested: 125,829,120 | Session: 0.4min

*** NONCE FOUND! ***
  Nonce:    8273649182
  Hash:     0x000000...
  Batches:  31
  Time:     0.44s
  Hashrate: 295.12 MH/s

Submitting transaction...
TX sent: 0x...
SUCCESS! Block: 19234567
Gas used: 52341

Optimasi Performa

Tuning Threads per Block

# RTX 3090/4090 - coba 512 threads
node miner-gpu.js --threads 512

# GPU lama (GTX 1060) - coba 128 threads  
node miner-gpu.js --threads 128

Tuning Blocks

# Lebih banyak blocks = lebih banyak parallel work
node miner-gpu.js --blocks 32768

Multi-GPU Specific Devices

# Hanya GPU 0 dan 2
node miner-gpu-multi.js --devices 0,2

Troubleshooting

GPU addon not found

CUDA kernel belum di-build. Jalankan:

./scripts/build-cuda.sh

nvcc: command not found

CUDA Toolkit belum terinstall:

sudo apt install nvidia-cuda-toolkit

No CUDA-capable GPU found

  • Pastikan NVIDIA driver terinstall: nvidia-smi
  • Pastikan GPU support CUDA (Compute Capability 6.0+)

CUDA Error: out of memory

  • Kurangi blocks: node miner-gpu.js --blocks 4096
  • Tutup aplikasi lain yang pakai GPU

insufficient funds

Wallet butuh ETH untuk gas. Transfer ETH ke wallet mining.

InsufficientWork / execution reverted

Nonce sudah tidak valid (difficulty berubah). Miner otomatis retry.

Cek State Kontrak

npm run check

Struktur Project

hash256-cli/
├── miner-gpu.js          # Single GPU miner (CUDA)
├── miner-gpu-multi.js    # Multi-GPU miner
├── miner-cpu.js          # CPU fallback (multi-threaded)
├── miner.js              # Original CPU miner (legacy)
├── check-state.js        # Cek state kontrak
├── cuda/
│   ├── keccak256.cu      # CUDA kernel (Keccak-256)
│   └── addon.cpp         # Node.js N-API binding
├── scripts/
│   ├── build-cuda.sh     # Build script (Linux)
│   └── build-cuda.bat    # Build script (Windows)
├── binding.gyp           # node-gyp build config
├── package.json
├── .env.example
└── README.md

Peringatan

Lisensi

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors