What Is Bitcoin Mining?
Bitcoin mining is the process by which new bitcoins are introduced into circulation and transactions are verified and added to the public ledger, known as the blockchain.
Miners solve complex math problems using powerful computers to add transaction blocks to the blockchain, earning bitcoins and fees as rewards.
This essential process generates new bitcoins, dwindling over time by design, and safeguards the network against fraud.
Want to learn more about Bitcoin first? Start with out beginner’s guide: What is Bitcoin?
Key Mining Concepts in Simple Words
- Blockchain: A digital ledger that records all Bitcoin transactions in a secure and chronological order, like a chain of blocks linked together.
- Mining: The process of using computer power to solve complex puzzles, secure the network, and process transactions in exchange for new bitcoins and transaction fees.
- Block Reward: The amount of new bitcoins given to the miner who successfully solves the puzzle for a new block, which halves approximately every four years.
- Hash Function: A mathematical algorithm that takes any input and produces a fixed-size string of characters, which is unique for different inputs.
- Hash Rate: The speed at which a miner's equipment can solve the cryptographic puzzles, measured in hashes per second (h/s), indicating the mining power.
- Nonce: A random number that miners change repeatedly to get a different hash value until they find one that meets the network's required conditions.
- Difficulty: A measure of how hard it is to find a new block compared to the easiest it can ever be; it adjusts to keep the block discovery rate constant.
- Proof of Work (PoW): The consensus mechanism that requires miners to solve cryptographic puzzles to validate transactions and create new blocks, ensuring network security and integrity.
- Node: A participant in the Bitcoin network.
What Role Does Mining Play in the Bitcoin Ecosystem?
Mining is the backbone of Bitcoin and as such it plays a crucial role in the ecosystem, serving multiple essential functions:
Transaction Verification
Mining involves verifying transaction data and adding it to the Bitcoin blockchain. This process ensures that transactions are legitimate and prevents issues such as double-spending, where someone tries to spend the same bitcoins more than once.
Network Security
By requiring miners to solve complex mathematical puzzles, mining makes it computationally expensive to alter the blockchain. This secures the network against fraudulent activities and attacks, as altering past transactions would require an immense amount of computing power to redo the work of subsequent blocks.
Decentralization
Mining contributes to the decentralization of the Bitcoin network. Since anyone with the necessary hardware and access to electricity can participate in mining, it helps distribute control over the network, preventing any single entity from gaining too much influence.
Currency Issuance
Mining is the process through which new bitcoins are created. Miners are rewarded with new bitcoins and transaction fees for each block they successfully add to the blockchain. This reward mechanism not only incentivizes miners to keep the network secure but also controls the supply of new bitcoins, mimicking the rate at which commodities like gold are mined from the earth, hence contributing to Bitcoin's moniker as "digital gold."
Consensus Building
Mining is a critical component of the consensus mechanism in the Bitcoin network (Proof-of-Work). It ensures that all participants in the network agree on the current state of the blockchain and adhere to the same set of rules, maintaining the integrity and continuity of the blockchain.
Proof-of-Work and Why It Matters
Bitcoin is the first digital currency to solve the double spending problem using a Proof-of-Work mechanism in a peer-to-peer network.
Proof-of-Work (PoW) is a consensus mechanism that underpins the functionality of Bitcoin and several other cryptocurrencies. It plays a crucial role in enabling a decentralized network to agree on the state of the blockchain without relying on a central authority.
PoW requires miners to solve complex mathematical puzzles (the work), a process that demands significant computational power and energy (=financial investment). They are in turn rewarded with newly created Bitcoin and transaction fees.
The reward system encourages miners to continuously invest resources in the hopes of earning rewards, making dishonest behavior, such as attempting to alter the blockchain for fraudulent gains, less attractive.
Any attempt to cheat (like double-spending) requires an impractical amount of computational power to outpace the honest network, making the cost of dishonesty significantly higher than the potential rewards.
In the context of game theory, Proof-of-Work creates a competitive environment in which miners are incentivized to act honestly for personal gain, aligning individual interests with the network's security and integrity.
This competition forms the basis of a Nash Equilibrium, a concept from game theory where no participant can gain by unilaterally changing their strategy if others keep theirs unchanged.
How is Bitcoin Mined?
Bitcoin mining involves several key steps that ensure transactions are securely added to the blockchain and new bitcoins are generated as a reward for miners. Here's an overview of the entire process:
- Transaction Verification: Miners collect pending network transactions from the mempool to form a new block.
- Creating a New Block: These transactions are compiled into a block, awaiting confirmation. Due to the limited space available in each new block, miners tend to prioritize transactions with high transaction fees.
- Calculating the Merkle Root: The transactions in the new block are hashed together in pairs, and then those hashes are hashed together, and so on, until there is a single hash for all transactions, known as the Merkle root.
- Solving the Proof of Work Puzzle: The most computationally intensive step is solving the Proof of Work (PoW) puzzle. This involves finding a nonce (a variable number that miners can change) that, when added to the block and passed through a hash function, produces a hash that meets the network's difficulty target.
- Finding the Nonce: Miners use specialized hardware to rapidly guess many nonce values in search of the correct one that solves the puzzle. This process requires significant computational power and electricity, as the chance of finding the correct nonce on any given attempt is extremely low.
- Validation by the Network: Once a miner solves the puzzle, the new block is validated by other nodes in the network. The block is accepted, if it meets the required conditions (the transactions are valid, and the PoW puzzle is correctly solved).
- Adding the Block to the Blockchain: Upon validation, the new block is added to the blockchain. This update is propagated across the network, and the transactions contained within the block are considered confirmed.
- Rewarding the Miner: The successful miner receives newly created bitcoins (block reward) and transaction fees from the block's transactions.
- Repeating the Process: Miners continuously compete to solve new puzzles, processing new transactions and securing the network.
The Mechanics of Mining
Understanding the Mempool
The mempool (short for memory pool) is a collection of unconfirmed transactions waiting to be included in a block.
When users make Bitcoin transactions, they first get broadcasted to the network and are temporarily stored in the mempool until miners select and confirm them in the next block.
The state of the mempool reflects the current demand for block space on the Bitcoin network. It is influenced by factors such as transaction volume, block size limit, and miner behavior.
Constructing a Candidate Block
Miners pick transactions from the mempool when they are constructing a new block. Transactions with higher fees often have a higher priority because miners are incentivized by these fees.
This means that if the network is busy, transactions with higher fees are likely to be processed faster.
Building the Block Header
The block header is a crucial component of the candidate block. It contains:
<figure class=”block-table”>
<table>
<tr>
<th>Field</th>
<th>Description</th>
</tr>
<tr>
<td>Previous Block Hash</td>
<td>A reference to the hash of the previous block in the blockchain.</td>
</tr>
<tr>
<td>Merkle Root</td>
<td>A combined hash of all of the transactions in the block.</td>
</tr>
<tr>
<td>Timestamp</td>
<td>The current time.</td>
</tr>
<tr>
<td>Difficulty Target</td>
<td>A representation of how difficult it is to find a qualifying hash for the block.</td>
</tr>
<tr>
<td>Nonce</td>
<td>An initial value of 0, which will be varied in the mining process.</td>
</tr>
<tr>
<td colspan="2">Hashing the Block Header with SHA-256</td>
</tr>
</table>
</figure>
Once the block header is constructed, miners use the SHA-256 hashing algorithm on it to produce a fixed-size output (256 bits)–the hash.
Comparing Against the Difficulty
The resultant hash is then compared against the current difficulty target. If the hash meets the criteria (i.e., it has the required number of leading zeros), then the block is valid.
However, given the astronomical odds against finding a valid hash, miners will likely need to adjust the nonce and try again.
Adjusting the Nonce
The nonce in the block header is modified, incrementing it by one (or using other strategies to change its value) for each new hash attempt. By changing the nonce, the resultant hash changes dramatically due to the cryptographic properties of the SHA-256 algorithm.
Even a minimal change in the input value, such as the difference between "Hello" and "hello", results in a completely different hash value.
Broadcasting the Block
The first miner to achieve a valid hash announces the new block to the network for verification, securing their reward of new bitcoins and transaction fees.
Adjusting the Mining Difficulty
As more miners join the network, the hashrate increases, making it more likely to find a new block in less time. To prevent this, Bitcoin automatically adjusts the difficulty about every two weeks to keep the time it takes to add a block around 10 minutes.
Conversely, if miners leave and the hash rate drops, the difficulty decreases to keep block times consistent. This adaptability ensures the network remains stable and functional regardless of changes in mining power.
Bitcoin Block Rewards
Miners are remunerated for their efforts in two ways: block rewards and transaction fees.
The block reward, a set amount of bitcoins given for mining a block, decreases over time due to halving events. As the issuance of new bitcoins slows, transaction fees become a more crucial income source for miners.
This shift ensures that as the block reward reduces, miners' reliance on transaction fees increases, maintaining their incentive to secure the network.
How Mining Affects the Supply of Bitcoin
One of the defining characteristics of Bitcoin’s tokenomics is its fixed supply cap of 21 million coins. This design was deliberately chosen by Bitcoin's pseudonymous creator, Satoshi Nakamoto, to create a deflationary asset.
Unlike fiat currencies, which can be printed in unlimited quantities leading to inflationary pressures, Bitcoin's capped supply ensures that its issuance is predictable and cannot be altered.
To ease into the 21 million cap, Bitcoin implements the so-called halving events, cutting the miners’ block rewards in half every 4 years and ensuring a gradual approach to its maximum supply limit.
Bitcoin Halving
Every 210,000 blocks, or roughly four years, Bitcoin undergoes a "halving" where the block reward for miners is cut in half. Starting with a reward of 50 bitcoins per block when Bitcoin was first launched in 2009, this reward has already undergone multiple halvings and will continue to do so until the block reward approaches zero.
Halvings can lead to higher prices through supply and demand dynamics and often attract increased attention, sometimes triggering bullish market cycles.
We’ve written more about this topic and how it affects Bitcoin’s value: Bitcoin Halving Explained
How to Mine Bitcoin
Let’s take block 700000 as an example.
The block-header is defined by the following parameters:
"version": 1073733636
"previousblockhash": "0000000000000000000aa3ce000eb559f4143be419108134e0ce71042fc636eb"
"merkleroot": "1f8d213c864bfe9fb0098cecc3165cce407de88413741b0300d56ea0f4ec9c65"
"time": 1631333672
"bits": "170f48e4"
Let's assume the difficulty target is
0000000000000000000f48e40000000000000000000000000000000000000000
So our block hash should also start with 19 zeros.
Using nonce = 1 in the block header would lead to a blockhash of:
cf526dcc3304320861af95bd992490caaff2b6f83009ad266a219abd65fe4fbd
As we can see, the block hash starts with cf526dcc3304320861a
This block won’t be added to the blockchain, because it doesn’t fulfill the difficulty rule.
Try nonce = 2 delivers a block hash of:
e241eebfcf7328dde1d4525b060566c719ecb515478d9b7ce9343d0dd174ff5f
We now need to guess several times to find a fitting block hash.
Nonce = 2881644503 would fulfill the requirement - the block hash now is:
0000000000000000000590fc0f3eba193a278534220b2b37e9849e1a770ca959
We just mined a block!
History of Bitcoin Mining
CPU Mining
Initially, Bitcoin mining was done with Central Processing Units (CPUs), the versatile brains of computers that handle various tasks. This was feasible when Bitcoin was new, its community small, and mining difficulty low. Yet, as Bitcoin gained popularity and the network expanded, CPUs no longer provided the necessary computational power for efficient mining.
GPU Mining
The transition to Graphics Processing Units (GPUs) was a game-changer in mining. GPUs, primarily designed for video game graphics, excel at complex calculations and parallel processing, making them much more effective for Bitcoin's mining algorithm.
FPGA Mining
Field Programmable Gate Arrays (FPGAs) offered a further leap in efficiency. Unlike GPUs, FPGAs can be customized for specific tasks, allowing miners to finely tune their hardware for Bitcoin's mining algorithm, achieving better performance with lower energy consumption.
ASIC Mining
The introduction of Application Specific Integrated Circuits (ASICs) represented the zenith of mining technology. ASICs are engineered exclusively for Bitcoin mining, particularly to run the SHA-256 hashing algorithm. Their unmatched speed and efficiency dwarf previous technologies.
However, their inability to perform tasks beyond mining makes them highly specialized tools in the cryptocurrency mining industry.
Security & the 51% Attack
Bitcoin mining secures the blockchain but exposes a theoretical risk known as the 51% attack, where an entity gains majority control over the network's mining power. This control could allow for transaction manipulation and double-spending coins–first using them for transactions, then erasing those transactions from the blockchain to spend the coins again.
Attackers might use "shadow mining" to create a secret, parallel blockchain, later overtaking the legitimate one by presenting a longer chain. This would invalidate the transactions recorded on the now-discarded blocks, posing significant risks to Bitcoin's security and trustworthiness.
Although feasible in theory, the decentralized nature and significant cost of achieving over 50% mining power make such attacks impractical and unlikely, preserving Bitcoin's security and user trust in its transactional integrity.
Tax Considerations of Bitcoin Mining
Taxation of Bitcoin mining has emerged as a complex issue in many jurisdictions as governments grapple with how to classify and treat cryptocurrency-related activities.
Mining can be seen both as an entrepreneurial activity and as a form of income generation. Consequently, miners may be required to pay income or business taxes based on the value of the Bitcoins they mine.
Additionally, when they subsequently sell these coins, capital gains taxes could apply, depending on price appreciation and jurisdictional rules.
Be sure to check out our extensive collection of Crypto Tax Guides to learn more.
Mining's Environmental Impact
Bitcoin mining's environmental impact is a topic of significant concern. This process requires an enormous amount of electricity to power the specialized hardware needed for mining, leading to a substantial carbon footprint.
The Cambridge Bitcoin Electricity Consumption Index estimates the total Bitcoin electricity consumption for 2023 to be 121.13 TWh–about 0.44% of global demand for electricity in the same year.
Additionally, the production and disposal of mining hardware, which becomes obsolete every few years, generates electronic waste. While renewable energy sources and efficiency improvements offer some mitigation, the growing energy demand of Bitcoin mining continues to pose environmental challenges.
Bitcoin Mining FAQ
Is Bitcoin Mining Worth It?
It depends on electricity costs, hardware efficiency, and Bitcoin's market price. It can be profitable for some, costly for others. Joining a mining pool can be worthwhile, as it increases the chance of earning Bitcoin rewards by pooling computational resources.
What Do You Need to Mine Bitcoin?
Specialized hardware (ASICs), a stable internet connection, and access to cheap electricity.
How Many Bitcoins Are Left?
As of now, about 19 million bitcoins have been mined, leaving about 2 million bitcoins left to be mined out of the total 21 million.
Can You Mine Bitcoin at Home?
Yes, but it's challenging due to high electricity costs and the need for powerful hardware.
How Long Does It Take to Mine a Bitcoin?
It takes roughly 10 minutes to mine a Bitcoin block. The mining difficulty continuously adapts to the computational power of the network, balancing the creation rate regardless of how many miners are competing.
What’s Next?
We're glad to hear that you want to learn more about Bitcoin and the world of cryptocurrencies!
Of course, we had to simplify many technical concepts in this article in order to provide an understandable introduction to Bitcoin.
This article was just the first part of our series "What is Bitcoin and how does it work?"
Here you'll find all the entries to help you become a Bitcoin pro in no time:
Or maybe you’d like to jump ahead and learn about the best cryptocurrencies to buy now?
Either way, be sure to also check out our popular crypto portfolio tracker and crypto tax calculator to learn why more than 350,000 crypto investors use Blockpit to make smarter decisions.