The Proof-of-Work Hash Demo lets you mine a block hash in your browser. You set the block data and a difficulty target, and the page iterates nonces with SHA-256 until it finds a hash that meets the target — exactly how proof-of-work mining works, just at a learnable scale.
How it works
A miner repeatedly hashes the block data combined with a changing nonce and checks whether the result meets a difficulty target. Here the target is a number of leading hexadecimal zeros:
attempt = SHA256( blockData + nonce )
valid = attempt starts with N zero hex digits
Because SHA-256 output is effectively random, you cannot predict which nonce
will work — you simply try nonce = 0, 1, 2, … until one succeeds. The first
nonce that produces a qualifying hash is the proof of work.
Why difficulty scales by 16
Each hexadecimal digit has 16 possible values, so the chance a given digit is
zero is 1/16. Requiring N leading zeros means the chance any single hash
qualifies is (1/16)^N. The expected number of attempts is therefore 16^N:
about 16 for one zero, 256 for two, 4,096 for three, and so on. This is why real
networks raise difficulty to keep block times steady as hash power grows.
The anatomy of a block
In this demo, the block consists of two elements: the block data (any text you enter) and the nonce (an integer the miner increments with each attempt). In a real blockchain, a block typically also contains:
- A timestamp
- A reference to the previous block’s hash (creating the “chain”)
- A Merkle root of the transactions
The demo simplifies to just data plus nonce to isolate the proof-of-work mechanic without requiring knowledge of the full block structure.
SHA-256 and the one-way function property
SHA-256 has three properties that make proof-of-work possible:
Deterministic — the same input always produces the same output. This lets any participant verify a claimed proof by running the hash themselves.
One-way — given a hash output, you cannot reverse-engineer the input. This means the only way to find a nonce that produces a hash meeting the target is to try nonces, one after another.
Avalanche effect — changing a single bit of input changes roughly half of the output bits unpredictably. This ensures there is no shortcut: nonce N+1 gives a completely different hash from nonce N, so knowledge of one failed attempt gives no information about the next.
These three properties together mean that finding a valid nonce requires real computational work, which is the security foundation of proof-of-work consensus.
Difficulty reference table
| Leading zeros required | Expected attempts | Approximate browser time |
|---|---|---|
| 1 | 16 | Instant |
| 2 | 256 | Instant |
| 3 | 4,096 | Instant |
| 4 | 65,536 | Under 1 second |
| 5 | ~1 million | 1–3 seconds |
| 6 | ~16 million | 15–45 seconds |
| 7 | ~268 million | Several minutes |
Times are approximate and depend on your hardware. Bitcoin’s real network currently requires hashes with around 77 leading zero bits (in binary), corresponding to difficulty in the tens of trillions — which requires specialised ASICs running in huge farms to hit the ~10-minute target block time.
Example and notes
Mining the data hello at difficulty 4 means searching for a SHA-256 hash that begins with 0000, which takes on average 16^4 = 65,536 attempts — a fraction of a second in the browser. Push difficulty to 6 or 7 and you will feel the exponential cost first-hand. This demo runs a single SHA-256 pass locally and is not connected to any blockchain.