As mentioned in the preceding chapter, bitcoin mining is how new bitcoin are created and how bitcoin transactions are validated. As such, bitcoin mining is the most important aspect in the Bitcoin phenomenon and is key to its function, security and well-being.
Bitcoin Mining in a Nutshell
The following is a simplified account of bitcoin mining:
- Bitcoin transactions made by bitcoin users around the world are placed into blocks to be validated on the Bitcoin network.
- For the transactions to be validated, each block contains a cryptographic puzzle to be solved by a bitcoin miner (the hardware).
- A bitcoin miner (the person) purchases some mining hardware and connects them to the Bitcoin network.
In bitcoin terminology, bitcoin miner can refer to either the person or the hardware.
- The mining hardware performs high-speed guesses at the expense of electricity to solve the block puzzles to validate those bitcoin transactions.
- Each solved block is added to the previous solved block, forming a series of blocks known as the blockchain.
- For his outlay of capital costs in the mining facility and operational costs in electricity, the bitcoin miner is rewarded with the preset number of bitcoin for every block that is solved.
- The bitcoin miner also earns the transaction fees paid for all the transactions in the block that is successfully mined.
- The bitcoin miner then sells his bitcoin on the open market to cover his running costs. This is how new bitcoin end up in circulation to be bought, sold, kept or spent.
- The race to solve cryptographic puzzles and validate blocks becomes a competition amongst all bitcoin miners around the world as each miner vies for the maximum reward possible.
A Brief History of Bitcoin Mining
- In January 2009, Nakamoto released the first bitcoin software that launched the Bitcoin network and the first units of the bitcoin cryptocurrency, denoted by the currency code BTC and the symbol ₿.
- The first bitcoin was released into circulation in the first block on 3rd January 2009.
- The first block, known as the genesis block of bitcoin or block number 0, carried a reward of 50 bitcoin (Reward Era 1).
- Interesting to note, embedded in the transaction detail of the genesis block, was the text: The Times 03/Jan/2009 Chancellor on brink of second bailout for banks. This is probably an allusion to the problem that bitcoin was created to solve.
- During this period when Bitcoin was still in its infancy and mining difficulty was at its initial stages, the processing power of computers or CPUs were powerful enough to solve the block puzzles.
- Later on, miners learned that they could harness the higher power and efficiency of graphics cards or GPUs to solve blocks faster than CPUs.
- While CPUs could still probably be used to mine at that time, miners were losing out to those who had deployed GPUs, in terms of number of blocks solved as well as running costs. This made GPUs far more favourable for mining than CPUs.
- By mid-2011, miners discovered that FPGA hardware could run at higher hashrates and at the same time consume little power, making them very efficient machines for the purpose of bitcoin mining.
- FPGAs were more efficient than GPUs, and made CPU mining less viable.
- In 2013, ASIC mining came into the scene. ASIC miners are much faster and more efficient than any mining hardware that came before. This rendered all other previous hardware obsolete for mining bitcoin.
- ASIC miners are still used to mine bitcoin today, although they have gone through several iterations and version upgrades since they were first used.
- GPUs and older hardware were then feasibly used to mine other altcoins such as Ethereum and Monero, as is done today.
Solving the Cryptographic Puzzle
To complete our understanding of how bitcoin mining works, let’s now take a look and see the processes involved in the solving of the cryptographic puzzle when validating a block.
- Every block consists of a hashA hash is a function that converts one value to another. value made up by the data in that block. This data is made up of the block header, the transactions placed in that particular block and other information, including (and especially including) the hash from the preceding block.
- Since this data is different for each block, its hash value is also unique.
- In solving the puzzle, the miner applies multiple nonces32-bit random numbers used in a cryptographic communication only once and churned out by miners to derive a block hash that is less than or equal to the current target of the network. to the block hash in quick succession until a result with the required number of leading zeroes is found. This, as determined by the mining difficulty, should take on average about 10 minutes.
- To help understand the application of nonce to derive the required hash, watch the following visual demo:
- When this is achieved, the miner announces the result on the network. Other miners then confirm that to be true, and the miner is declared the successful miner for that block and is then awarded the preset number of bitcoin as a reward.
- The solved block of transactions is then appended on the blockchain. The next block consisting the hash of the last block which is also the result of all blocks before it, as well as the new batch of transactions included in it, forms the next puzzle to be solved by the next successful miner.
- Should the mining difficulty increase, a higher number of leading zeroes would be required in the result. This would take the miner a longer time to solve. The opposite applies when the mining difficulty decreases.
Next, in section 1.6 What is Blockchain, we will put together what we have discussed so far and see how everything comes together to form the bitcoin blockchain, and what the blockchain means to the Bitcoin system.