✖

Bitcoin mining: how proof of work works

Behind Bitcoin is a ledger of payments that thousands of computers around the world keep together (you will find more about it in the opening part of the series). These computers are called nodes: each has the whole book and checks that new payments are valid. Payments are written into the book in packages called blocks. Whoever adds a block also sends themselves a payment in it, the block reward, which since April 2024 has been 3.125 BTC. There is a competition for the right to add the next block, and that competition is called Bitcoin mining.

It is a lottery in which tickets are not bought but worked out. A miner puts together a package from the payments that are waiting to be written, adds a number to it and works out a hash from the result: a short string of characters that stands in for the package, as a fingerprint stands in for a person. If the hash begins with a long enough string of zeros, the miner has won: they may write the package into the book and receive the reward. If not, they try the next number.

From this lottery follows one of the most valuable properties of Bitcoin: a payment that has been written cannot be rewritten afterwards, because anyone who tried would have to win the lottery again, and for every later block too. This holds even though nobody runs Bitcoin and no bank watches over the order of payments.

What a hash is

The key tool of mining is the hash, which is also called a digest. Imagine a mill: you pour any text into it, short or long, and what comes out is always a pile of the same size, a string of 64 characters. The same text always gives the same hash. But change a single letter and a completely different string comes out, with no resemblance to the first. The Bitcoin mill is called SHA-256, and the article on hash functions takes it apart in depth.

A hash is really a huge number in the binary system. For a shorter notation it is written in the hexadecimal system: besides the digits 0 to 9 it contains the letters a to f, with the values 10 to 15. For example, the text “Adam posílá Báře 1 BTC” (Czech for “Adam sends Bára 1 BTC”) has a SHA-256 hash that begins like this:

9afdc343bc67ea0a…

Guessing the number

A hash is a number, and zeros at the start make it small, just as 0042 is smaller than 4200. Let’s try mining for ourselves. After the message “Adam posílá Báře 1 BTC” we write a space and a number, and we want the hash to begin with a zero. We try zero, that is, the text “Adam posílá Báře 1 BTC 0”. The hash begins 091ebc..., so we are lucky straight away. Let’s make it harder: the hash must begin with two zeros. The number 0 is no longer enough, so we try 1: the hash 95a904..., nothing. The number 2: f5e641..., nothing again. And so on and on, until the number 128 gives the hash 00d1c2.... We started from zero, so that was the 129th attempt.

The more zeros we want, the longer we search:

A table of attempts: in the left column the number added after the message, in the right column the start of the SHA-256 hash. For the numbers 0 to 3 and then 128, 7,339, 29,301 and 951,434. The zeros at the start of the hash are red: one, two, three, four and five zeros in turn. A table of attempts: in the left column the number added after the message, in the right column the start of the SHA-256 hash. For the numbers 0 to 3 and then 128, 7,339, 29,301 and 951,434. The zeros at the start of the hash are red: one, two, three, four and five zeros in turn.

Where do these numbers of attempts come from? Any of the 16 characters can appear in the first position of a hash, and none is more common than the others. A zero will therefore be there with probability

116.

The second position does not depend on the first in any way, so a zero in both the first and the second position has probability

116⋅116=1256.

A chance of 1/16 means on average one success in 16 attempts, so one zero comes on average after 16 attempts, two after 256, three after 4,096, four after 65,536 and five after more than a million. In general, k zeros come out with probability 116k, that is, on average after 16k attempts. Every extra zero means sixteen times more work.

Our attempts did not quite match the average: four zeros came as early as the 29,302nd attempt, five zeros only at the 951,435th. That is chance, like a six on a die that sometimes turns up straight away and sometimes after twenty throws. Over a longer run the average holds. Of the first 1,600 numbers, 105 gave a hash with a zero at the start, and the average predicts 1600÷16=100.

Why it cannot be guessed cleverly

Can’t we try more cleverly? If the number 128 gave two zeros, won’t the number 129 give at least one? It won’t: the hash of 129 begins 32a2f5.... Every hash is like a new throw of a die. You can try the numbers in order, skip around or pick at random, and the chance of success is the same every time, 1/16 for each position.

Only one way is left: work out the hash and look. If somebody found a way to predict a SHA-256 hash without calculating it, they would not be a clever miner, but a person who had broken SHA-256.

Nobody can prepare a supply of numbers in advance either. Every block contains the hash of the block before it, so the competition for a new block can begin only when the previous block is finished. All the miners set off from the start at the same moment.

The block header and the nonce

Real Bitcoin does not hash the whole block but only its header, a short label of 80 bytes (a byte is 8 bits, a bit is a zero or a one). Six items fit into it:

The block header as a strip of six boxes with their lengths in bytes: 4, 32, 32, 4, 4 and 4, the last box in orange. An arrow leads through a double SHA-256 calculation to the hash 00000000000000000001e646ddc9…, with the nineteen zeros at the start in red. The block header as a strip of six boxes with their lengths in bytes: 4, 32, 32, 4, 4 and 4, the last box in orange. An arrow leads through a double SHA-256 calculation to the hash 00000000000000000001e646ddc9…, with the nineteen zeros at the start in red.

  1. the version of the rules (4 bytes),
  2. the hash of the previous block (32 bytes), which is how blocks are arranged into a chain,
  3. the hash of all the payments in the block (32 bytes), so that changing a single payment changes the header too; how thousands of payments are turned into a single hash is explained in the part on the blockchain,
  4. the time (4 bytes),
  5. the required difficulty (4 bytes),
  6. the nonce (4 bytes), a number that the miner changes, exactly like our number after the message.

From the header the miner works out a SHA-256 hash and from it another hash. The result is compared with the requirement. On the real block 978,859 from 5 December 2026 we will show how it turns out. Its hash is

00000000000000000001e646ddc90a0d…

and it begins with nineteen zeros. The nonce of this block is 3,577,362,784. If we increase the nonce in the header by one, the hash begins 0126..., with a single zero. We downloaded the whole header from mempool.space and recalculated the hash ourselves: it matches.

This is exactly what is called proof of work. Finding a header with nineteen zeros costs an enormous number of attempts. Checking it costs two hash calculations, a fraction of a millisecond. So anyone can check that the miner really did the work, without having to trust them. The winner therefore simply sends the new block to the nodes, they check it, and the competition for the next one begins.

The nonce has only 4 bytes, that is, 32 zeros and ones, so it takes “only” 232, roughly 4.3 billion, values. Today that is not enough. When a miner runs out of nonces, they change something else slightly, for example the time or the order of payments in the block, and try all the nonces again.

Difficulty

So far we have counted zeros for simplicity. In reality the hash must be smaller than a target number, which is simply called the target. The target of block 978,859 begins with nineteen zeros and continues with the characters 1f0a3. The hash of the block has 1e646 after its zeros. It is compared as with decimal numbers, character by character from the left: the one is the same and e is smaller than f, so the hash is a little smaller and passed. The target can therefore be tightened even by a little, not just by a whole zero, that is, sixteen times.

More often than the target, the difficulty is quoted, which we will denote D. The first block in 2009 had difficulty 1, which meant roughly eight zeros at the start of the hash. By our rule that is

168=4,294,967,296=232

attempts per block (sixteen is 24, so 168 = 232). At difficulty D the work is D times as much, so on average

D⋅232 attempts.

As of 5 December 2026 the difficulty is D ≈ 145.09 · 1012 (according to mempool.space). Substituting:

145.09⋅1012⋅232≈6.2⋅1023 attempts.

That many attempts, roughly 620 sextillion, is what the whole network needs on average for one block. It lies between 1619 and 1620, so a hash with nineteen zeros corresponds exactly to today’s difficulty.

How many attempts can the whole network manage? The answer is given by the hashrate, the network’s power in hashes per second. Nobody reports it; it is estimated from how fast blocks are arriving. As of December 2026 it is about 0.97 · 1021 hashes per second, almost a sextillion. If every person on Earth had to work them out, each would get over a hundred billion hashes per second. How many seconds does one block take the network? We divide:

6.2⋅10230.97⋅1021≈640 s,

that is, about 10.7 minutes. This is not circular reasoning, even though the power is estimated from the speed of blocks: the difficulty is set only once every two weeks, and the power has changed since then, which is why it did not come out at exactly ten minutes. That it came out at almost ten is no accident, though.

Why ten minutes

The Bitcoin program wants a block to be added on average once every ten minutes. But the power of the network keeps changing, and so after every 2,016 blocks each node recalculates the difficulty itself. At ten minutes per block that is

2016⋅10=20,160 minutes=14 days.

The node looks at how long the last 2,016 blocks really took and multiplies the difficulty by the ratio “how long it should have taken to how long it took”. How this looks in real life is shown by the recalculation of 27 November 2026. The previous 2,016 blocks took only 13.01 days, so the difficulty was multiplied by

1413.01≈1.076,

so it rose by 7.6%. It works in the opposite direction too. At the turn of January and February 2026, 2,016 blocks took 15.77 days and the difficulty was multiplied by 14/15.77 ≈ 0.888, so it fell by about 11%. So that the network is not thrown off by an error or by cheating with the time, the difficulty may change by at most a factor of four up or down in one recalculation.

A graph over a year from December 2025 to December 2026. The blue curve shows the power of the network in EH/s, that is, quintillions of attempts per second, fluctuating roughly between 800 and 1,100. The red steps show the power that would correspond exactly to blocks every ten minutes at the current difficulty, and each step lasts two weeks. The steps catch up with the curve with a delay. A graph over a year from December 2025 to December 2026. The blue curve shows the power of the network in EH/s, that is, quintillions of attempts per second, fluctuating roughly between 800 and 1,100. The red steps show the power that would correspond exactly to blocks every ten minutes at the current difficulty, and each step lasts two weeks. The steps catch up with the curve with a delay.

The graph shows that the difficulty only catches up with the power after a delay. When the power grows, the step lies below the curve and blocks come faster than every ten minutes. Only the recalculation lifts the step. That is why in periods of growth blocks arrive a little more often, which was also the reason why the halvings, the halving of the reward after every 210,000 blocks, came sooner than after four years. Since the recalculation on 27 November the network has, on the contrary, slowed down a little, blocks take an average of those 10.7 minutes, and the next recalculation will most likely lower the difficulty.

A miner’s chances

Take a miner with a thousandth of the power of the whole network. Every block is a new lottery, and the miner wins it with probability 11000, because they work out a thousandth of all the attempts. About 24 · 6 = 144 blocks are added a day, so in a day the miner wins on average

144⋅11000=0.144 of a block,

that is, one block roughly every 1÷0.144≈6.9 days.

What is the chance of winning at least once in a day? It is easier to work out the opposite. In one block the miner fails to win with probability 9991000. Blocks are independent lotteries, so in all 144 blocks the miner fails to win with probability

(9991000)144≈0.866.

So the miner finds at least one block a day with probability 1 − 0.866 = 0.134, about 13%. For a week it is 1,008 blocks, and the same calculation gives about 64%, and for thirty days 99%. Beware of a tempting shortcut: in a week the chance is not seven times bigger than in a day, that is, 94%, otherwise eight days would give over a hundred per cent.

A small miner is worse off. With a millionth of the network’s power they would wait on average 1,000,000÷144≈6,944 days, which is over 19 years. That is why miners join together in pools: they calculate together and share the reward according to how much work each did. Instead of one big win in 19 years, each gets a small share almost every day. In the week up to 5 December 2026 the largest pool found 220 of 940 blocks, about 23% (according to mempool.space).

A graph of the probability that a miner with a thousandth of the network’s power finds at least one block, depending on the number of days from 0 to 30. The red curve rises quickly at first and then approaches 100% more slowly. The marked points: after one day 13%, after seven days 64%, after thirty days 99%. A graph of the probability that a miner with a thousandth of the network’s power finds at least one block, depending on the number of days from 0 to 30. The red curve rises quickly at first and then approaches 100% more slowly. The marked points: after one day 13%, after seven days 64%, after thirty days 99%.

The same trick shows how long we wait for a block. In every second the whole network has roughly the same chance of finding a block, namely 1600, because it needs 600 seconds on average. The chance is the same every second, because each attempt is independent and past failures change nothing. The probability that the network does not find a block within 30 minutes, that is, 1,800 seconds, is

(599600)1800≈0.05.

So roughly every twentieth block makes us wait over half an hour. On the other hand, a block arrives within a minute with probability 1−(599600)60≈0.095, in almost every tenth case. And if you have already been waiting ten minutes, that has not shortened anything: the network does not remember how many attempts have already failed, and the next block will again come on average in ten minutes. After ten minutes of waiting the block is still not found in roughly 37% of cases, because (599600)600≈0.37.

What proof of work is for

Why make the whole world burn electricity guessing numbers? Because work protects history. Every block carries the hash of the previous block, so anyone who wants to change a payment in some old block changes its header, and its hash stops meeting the target. They therefore have to mine the block again. But that changes the hash that the next block refers to, so they have to mine that one again too, and then all the later ones up to the present. And the rest of the network does not stand still meanwhile, it keeps adding more blocks. Nodes treat as valid the history with the most work behind it, so a fraudster would have to outrun all the honest miners put together. The same rule decides a dispute between two blocks found almost at the same moment: the network splits for a while, and the chain on which another block piles up faster is the one that counts.

How much power a fraudster would need for that, and what their chance is if they have less than half, is worked out in the part on the 51% attack. And why this protection is one of the three pillars of Bitcoin’s security is described in the part on security.

So guessing numbers is not useless work, even though the resulting number means nothing by itself. What gives it value is a single thing: nobody can find it more cheaply than by honest trying.

See also

Chapters: Bitcoin: what it is and how it works, The Bitcoin halving: why there are only 21 million bitcoins, Bitcoin mining: how proof of work works, Blockchain and the Merkle tree: how it works and why history cannot be rewritten, The Bitcoin address, private key and signature, Seed phrase: why nobody can guess the 12 words of a wallet, Ethereum: smart contracts and proof of stake, Is Bitcoin secure? What its cryptography rests on, The 51% attack: can Bitcoin be spent twice?, Quantum computers and Bitcoin: what if elliptic curves fell, Bitcoin and SHA-256: what if the hash function fell, Post-quantum Bitcoin: how Bitcoin would defend itself against quantum computers