This article may be technical and not suitable for laypersons. If you have background in computer science it will be easy to comprehend. If you are curious about bitcoin mining, it may be interesting to know what exactly a miner does underneath.
Bitcoin is a ledger system that keeps track of all transactions ever done in bitcoin currency. It is anonymous and decentralized. Anonymous because it keeps track of name and amount of each transaction using a digital signature called a has that will take billions of years to decode by brute force using a classical binary computer (the one on your desktop). It is decentralized because no authoritative computer has one and only one copy of the ledger to approve/disprove transactions and include those approved in the ledger.
Miners (software/hardware) collect the transactions on the network (like “Bob pays Don 10 bitcoins” and “Suzy pays Lucy 8.3 bitcoins”) into large bundles called blocks. These blocks are strung together into one continuous, authoritative record called the block chain, which doesn’t permit any conflicting transactions. This is necessary because without it people would be able to sign the same bitcoins over to two different recipients, like writing checks for more money than you have in your account. The block chain lets you know for sure exactly which transactions count and can be trusted (so no bad checks!).
The way Bitcoin makes sure there is only one block chain is by making blocks really hard to produce. So instead of just being able to make blocks at will, miners have to compute a cryptographic hash of the block that meets certain criteria. Bitcoiners refer to this process as “hashing“.
The only way to find a cryptographic hash that’s “good enough to count” is to try computing a whole bunch of them until you get lucky and find one that works. Miners who successfully create a block are rewarded some bitcoins according to a preset schedule. The difficulty of the criteria for the hash is continually adjusted based on how frequently blocks are appearing, so more competition equals more work needed to find a block.
A modern GPU can try hundreds of millions of hashes per second, so to be competitive in this race to find hashes miners need specialized hardware, otherwise they will tend to spend more on electricity than they make in the bitcoin.
In addition to the hash criteria, a block needs to contain only valid, non-conflicting transactions. So the other main task for miners is to carefully validate all the transactions that go into their blocks, otherwise they won’t get any reward for their work!
Because of all this work, when a Bitcoin client signs on to the network it can trust the block chain that was most difficult to produce (since this is evidently the one that was being worked on by the most miners). If there was a “fake” blockchain competing with the real ones (say, where someone pretends that they didn’t actually give Lucy those 8.4 bitcoins and they still have them), the fraudster would have to do as much work as the whole rest of the network to make their block chain look as trustworthy. So essentially, the intense work that goes into finding blocks through hashing secures the network against fraud. There is also, of course, some nifty code that figures out how to choose between conflicting transactions; and what to do if two people find valid blocks at the same time.
One last thing: why is it called mining? In the original analogy, people who performed this essential work were compared to gold miners digging the gold out of the ground so that everyone could use it. But in reality, Bitcoin “miners” are just running computer programs on very specialised hardware that automates the process of securing the network. To sum up, this software
- Collects transactions from the network
- Validates them, and doesn’t allow conflicting ones
- Puts them into large bundles called blocks
- Computes cryptographic hashes over and over until if finds one “good enough to count”
- Then submits the block to the network, adding it to the block chain and earning a reward in return.