⛏️ 2D Bitcoin Mining Simulator — Real SHA-256 Proof-of-Work Race
Watch real SHA-256 proof-of-work mining computed live with the browser's Web Crypto API. Multiple simulated miners race with different hash rates; watch real leading-zero-bit targets, measured hash rates, and win-share converge to hash-rate share over many rounds.
A flat, statistics-first take on Bitcoin mining: every hash on screen is a genuine SHA-256 digest computed by the browser's own Web Crypto API, checked bit-by-bit against a real difficulty target. Multiple simulated miners with different real hash rates race each other, round after round, and their win share is tracked live against their hash-rate share — the exact law that governs real mining-pool payouts.
🔬 What It Demonstrates
Each miner hashes prevHash | round | minerId | nonce with crypto.subtle.digest("SHA-256", …) and counts the real leading zero bits of the digest — equivalent to comparing the 256-bit hash, as a number, against a target of 2^(256−difficulty). A round ends the instant any miner's genuine hash clears that bar. Because expected attempts scale as 2^difficulty, and each miner's win probability per attempt is proportional to its share of total attempts, win share converges to hash-rate share as rounds accumulate — the law of large numbers playing out with real cryptography.
🎮 How to Use
Press Start Mining to launch every miner's independent hashing loop. Raise Difficulty to require more leading zero bits (exponentially harder). Add Miners to see more competitors, each with a distinct real hash rate (1×, 2×, 3×, 5×, 8×, 13× the Speed slider). Watch each miner's blue "hash-rate share" bar and green "win share" bar in the info panel — over many rounds the green bar should settle near the blue one.
💡 Did You Know?
This simulator's difficulty tops out at 18 leading zero bits so a round finishes in seconds — Bitcoin's real network difficulty in 2025 corresponds to roughly 90+ leading zero bits, meaning the entire global mining industry searches on the order of 2^90 hashes for every block, using the exact same SHA-256 primitive this page runs in your browser tab.
About the 2D Bitcoin Mining Simulator
This simulator models Bitcoin's proof-of-work consensus using real cryptography rather than a scripted animation. Each simulated miner repeatedly calls the browser's native crypto.subtle.digest("SHA-256", …) on a block header combined with an incrementing nonce, then inspects the genuine 256-bit digest bit by bit to count its leading zeros. A hash "wins" the round the instant those leading zero bits meet or exceed the difficulty target — exactly the same win condition real Bitcoin nodes check, just at a scale small enough to resolve in seconds inside a browser tab.
Because several miners hash independently and in parallel, each with its own measured real hash rate, this page doubles as a live statistics demonstration: probability theory predicts that a miner's share of blocks won should converge to its share of the network's total hashing power. The simulator tracks both quantities — hash-rate share and observed win share — round after round, so you can watch the law of large numbers narrow the gap between prediction and outcome in real time.
Frequently Asked Questions
How is this different from the 3D Bitcoin Mining simulation?
The 3D version renders an approximate, non-cryptographic hash function purely for visual pacing and shows a growing blockchain. This 2D version instead uses the browser's real SHA-256 implementation via the Web Crypto API for every single hash, checks a genuine bit-level difficulty target, and focuses on the statistical relationship between hash-rate share and win share across many rounds rather than on blockchain visuals.
Is the hashing actually real, or just for show?
It is real. Every attempt calls crypto.subtle.digest("SHA-256", data), the same standardized cryptographic primitive used by TLS, password hashing, and Bitcoin itself. The resulting 32-byte digest is inspected directly — nothing is faked or pre-computed. You could copy any header string logged in a lane and verify its SHA-256 hash independently and get the same result.
Why measure success in "leading zero bits" instead of leading zero hex digits?
Working in bits gives finer-grained, continuously adjustable difficulty. One hex digit of leading zero corresponds to exactly 4 bits, so "8 leading zero bits" is the same requirement as "2 leading zero hex digits" — but bit-level granularity lets the difficulty slider step by single bits, doubling the search space every single step, which mirrors how real network difficulty is expressed as a numeric target rather than a round hex-digit count.
Why does win share take a while to match hash-rate share?
Each round is a single Bernoulli trial per miner with a win probability proportional to that miner's share of total attempts made before any miner succeeds. Over a small number of rounds, variance dominates and a slower miner can easily get lucky. As the round count grows, the law of large numbers pulls the observed win frequency toward the true underlying probability — which is exactly the miner's hash-rate share. This is the same reason small mining pools see "lumpy" payouts while large ones see smooth, predictable ones.
What does the colored bit strip under each miner represent?
It renders the miner's most recent real SHA-256 digest as 48 four-bit nibbles. Nibbles fully inside the current difficulty's required zero-bit prefix are highlighted brightly; a nibble straddling the boundary is shown in a intermediate shade; everything after the target is dimmed. This makes it visible, hash by hash, how close an attempt came to clearing the target — most attempts fail within the very first nibble, which is exactly what a uniformly random 256-bit output predicts.
Why do higher difficulty settings take so much longer?
Each SHA-256 output is, for practical purposes, a uniformly random 256-bit number. The probability that it has at least d leading zero bits is 2^-d, so the expected number of attempts before a success is 2^d. Raising difficulty by one bit doubles the expected search — the same exponential relationship that makes Bitcoin's real-world difficulty (tens of leading zero bits) require specialized ASIC hardware computing hundreds of exahashes per second.
How do real Bitcoin mining pools use this same hash-rate-share logic?
Mining pools combine many independent miners' hash rates and split the pool's block rewards proportionally to each participant's contributed share of total hashes submitted — regardless of who happens to find the winning nonce in any given block. This simulator's win-share-versus-hash-rate-share comparison is a scaled-down, directly observable version of exactly that payout principle, played out over rounds instead of real 10-minute blocks.
What is the Web Crypto API and why use it here instead of a JavaScript SHA-256 implementation?
crypto.subtle is a standardized browser API (part of the W3C Web Cryptography specification) that exposes the browser's own, typically hardware-accelerated, cryptographic primitives directly to JavaScript. Using it here guarantees the digest is a spec-correct, industry-standard SHA-256 output — not an approximation — while also running faster than an equivalent hand-written JavaScript implementation, which matters when a simulation needs to compute many genuine hashes per second.
A statistics-first proof-of-work race: every hash is real SHA-256 computed with the browser's Web Crypto API, checked bit-by-bit against a genuine leading-zero-bit difficulty target. Multiple simulated miners with different real hash rates compete, and their win share converges to their hash-rate share over many rounds.
2D · HTML5 Canvas 2D · 60 FPS target · runs fully client-side, no install