How mining works
Miners are computers that bundle waiting payments into a new block and add it to the blockchain. To earn that right, they have to win a kind of lottery that costs real electricity to enter.
The guessing game
A miner takes the block it wants to add and runs it through a maths function called SHA-256, which turns any data into a fixed length code called a hash. The network only accepts a block if its hash is below a target number. There is no shortcut. Miners change a small part of the block and try again, trillions of times a second, until someone gets lucky. The winner shares the block and every node checks it in a moment.
Difficulty
Every 2,016 blocks, about every two weeks, the network adjusts how hard the target is. If blocks came too fast, it gets harder. If they came too slow, it gets easier. That keeps the average close to one block every ten minutes, however many miners join or leave.
Why it keeps things honest
To rewrite past payments, an attacker would need to redo all that work faster than the rest of the network combined. That would cost a fortune, and they would earn more by mining honestly. The winning miner is paid the block reward, which shrinks at each halving, plus the fees from the payments in the block.
The original design is described in section 4 of the whitepaper. You do not need to mine to own bitcoin. Today it is done mostly by large firms with specialised machines.
But how does bitcoin actually work?
3Blue1BrownA clear visual walk-through of the ledger and mining.
Key takeaways
- Miners compete to add the next block by spending real energy.
- Difficulty adjusts every 2,016 blocks to keep blocks about ten minutes apart.
- Rewriting history would cost an attacker more than playing fair.
Not financial advice. These lessons are general education only. Bitcoin prices can swing hard. Never put in more than you can afford to lose, and do your own research.