Bitcoin mining: A complete guide
What is bitcoin mining? ⛏️
Bitcoin mining is a process that validates Bitcoin transactions and issues new bitcoin (BTC) into circulation.
Bitcoin mining helps to:
-
Incentivize miners who propose and verify new transactions for the Bitcoin blockchain.
-
Secure the Bitcoin blockchain against attacks.
-
Manage the creation and flow of new units of the bitcoin cryptocurrency entering the market for the first time.
Similar to physically mining precious metals like gold, mining bitcoin requires specialized hardware, energy and a little bit of luck.
However, instead of shovels and pans, Bitcoin miners compete against one another using purpose-built computing equipment.
Each miner’s goal is to win a cryptography-based competition. The winner of each round receives a highly sought-after block reward for their efforts. They are also granted the right to propose a new block of pending transaction data to join the blockchain.
If this is all new to you, keep reading our complete guide to Bitcoin mining below.
But, if you want a deeper and more technical understanding, you may be interested in checking out our article, How do cryptocurrencies use cryptography?
Why is bitcoin mining needed? 🔍
Before diving into the mechanics of Bitcoin, it’s important to understand why Bitcoin mining happens in the first place.
The Bitcoin network is not managed by a central bank, powerful billionaire or intermediary financial institution. It’s collectively managed by volunteers spread across the globe, and anyone can join.
This means Bitcoin relies on the cooperation of its users to operate and function. In return for dedicating their computer power to validating transactions, the protocol rewards miners with new units of bitcoin cryptocurrency.
By incentivizing cooperation, miners collectively help to secure the network by making it prohibitively expensive for malicious actors to gain majority control over it.
Bitcoin Price
Bitcoin proof-of-work consensus mechanism ⚙️
A blockchain consensus mechanism is a computer-driven system that ensures participants in a decentralized network can reach consensus on new data entering the blockchain.
Because Bitcoin blocks and the transaction data inside of them become permanent once they’re added to the blockchain, it’s crucial that this information is valid.
For example, the network must make sure that people don’t attempt to transfer funds that they don’t actually have, or “double spend” the same balance by sending it to two different people at the same time
Consensus mechanisms help the network collectively agree on these questions to ensure new transactions follow the rules of the protocol before they are permanently added to the blockchain.
There are a variety of different consensus mechanisms that can be employed on a blockchain-based network, each with its own specific method for filtering out dishonest users.
Bitcoin uses the proof-of-work (PoW) consensus mechanism — a system that involves computing power and energy to ensure participants act within the best interests of the network.
This method leverages principles from game theory, a mathematical study of how humans interact with one another. By requiring participants to have skin in the game — purchasing equipment and covering running costs — the proof-of-work system helps to dissuade bad actors from attempting to corrupt the network.
You can learn more about proof-of-work and other types of consensus mechanisms in our Kraken Learn Center article What is a blockchain consensus mechanism?
Understanding decentralization 🕸️
To better understand Bitcoin’s decentralization, let’s look at a traditional, centrally controlled company like Uber.
Imagine if Uber was collectively managed by its millions of taxi drivers and app users, instead of a select group of top executives. In this more decentralized model for Uber, all parties involved would collectively agree on how drivers were paid and how the drive hailing app would function — rather than these decisions being made for them by an executive team.
Furthermore, instead of the company managing important roles such as administration and app development, anyone in the world could help contribute to these roles from home using their own devices. This could create a much more accessible and transparent ecosystem for everyone.
All that being said, this level of decentralization can pose some serious questions; if anyone can participate in the network and there’s no single authority to oversee its operations, how can it dissuade dishonest people from attempting to corrupt the network, and how can it make sure everyone collaborates effectively?
This is where the blockchain consensus mechanism comes in.
How does bitcoin mining work? 🧑🏫
Simply put, bitcoin mining is a race to win a game of luck that repeats approximately once every ten minutes.
It involves miners using specialized machines to generate random values. Whoever generates a value that beats the target value, wins. The difficult part is, miners have no control over the values they create. They just have to keep generating new values in the hopes that they eventually stumble across a winning one.
Once someone does, they broadcast their value to every other miner in the network to check its validity.
An easier way to understand this process is to think of thousands of people trying to solve a Rubik’s cube blindfolded, all at the same time.
At the start, each person has their own identically-scrambled cube. Once the competition begins, everyone starts randomly turning their cubes until an invigilator announces a winner. The rest of the competitors take off their blindfolds and inspect the winner’s cube to verify its completion. Then, the competition starts all over again.
Making sense so far? Let’s dive a little deeper.
To be more specific, miners compete against one another by using purpose-built computers to generate cryptographic hashes — usually many millions of them per second — in the hopes of being the first to guess the right hash.
You can think of each new hash as a single turn of a Rubik’s cube.
Whichever miner guesses the correct hash first earns the right to add that block to the blockchain. In return for their work, the miner receives the block reward.
What are cryptographic hashes? 🧩
Hashes are fixed-length codes created when somebody runs any kind of input through a cryptographic hash function.
You can think of cryptographic hash functions like magic code machines that can take anything from a single letter to an encyclopedia and turn it into a completely unique and random fixed-length code.
Over the years, various types of hashing algorithms have emerged. Each uses a different methodology for taking inputs and turning them into randomized codes.
The Bitcoin network uses the Secure Hash Algorithm 256 (SHA-256), which was originally developed by the United States National Security Agency (NSA).
SHA-256 hashes are 28 character, fixed-length hexadecimal codes that contain a mixture of numbers between 0-9 and letters between A-F.
It doesn’t matter how small or large an input is, it will always generate a code of the exact same length. For example, running either the single word “Hello” or an entire Lord of the Rings book through the SHA-256 algorithm will produce two unique 28 character hash codes.
Hashes are vitally important in the mining process because they possess a number of unique characteristics.
Hashes are:
-
Deterministic - The same input will always produce the exact same hash code.
-
One-way - While it’s easy to turn an input into a hash, it’s impossible to know what the input was from the output.
-
Random - Hash codes bear no resemblance to their inputs.
-
Unique - No two hashes are ever the same.
What’s special about these features is that if a person modifies just a small part of the input, it creates a totally different output.
For example, if you changed a single letter in a Lord of the Rings book, it would produce an entirely new hash code, unrecognizable from the first one.
Anyone can create hashes by running any input through a cryptographic hash function. You can even try it yourself using a free online hashing calculator.
How do bitcoin miners win block rewards? 🏆
To win the Bitcoin mining competition and earn block rewards, miners must create a hash with an equal or lower value than a goal set automatically by the Bitcoin protocol itself. This value is known as the target hash.
Every target hash will have a certain number of zeros at the front. Depending on the current mining difficulty, which is also set automatically by the protocol, there might be only a few zeroes at the front or many.
The more zeroes at the front of a target hash, the harder it is for miners to beat it, and vice versa.
For example, a typical bitcoin target hash might look something like this.
00000000000a28ba41fe240e0b37
An easier target hash to beat might look like this.
000agh3h5g6711deabcc650918d9
Did you notice that it has significantly fewer zeroes at the front?
While this might seem trivial, adding just one extra zero at the front makes the competition many hundreds of times more difficult to win.
You can think of it as the difference between flipping a coin and it landing on heads three times in a row versus twenty times in a row.
The target hash for each new block of transactions is first broadcast to the network as a part of the previous block. This information is stored in the block header, which is a part of the bitcoin block that stores several important pieces of identifying information.
Also inside the block header is a value called a nonce, short for “number used once.”
When creating a hash to beat the target hash, all miners take the block header of the previous block, change the nonce to a new number and run it through the SHA-256 hashing algorithm. Each time the nonce value is changed, it produces an entirely new hash.
Since it’s impossible for miners to know what inputs will produce what hashes, beating the target is simply a matter of trial and error.
The process of guessing and checking continues until one miner successfully creates a hash that has the same or more zeros at the front as the current target hash.
The winning miner then proposes a new block of transaction data to all the other miners on the blockchain for them to independently verify. These other miners, who did not win the mining competition, independently verify the proposed block to make sure it’s valid.
How much bitcoin do miners get from block rewards? 🎁
Each miner that wins the mining competition receives a reward.
Known as a block reward, this newly-created bitcoin compensates the miner for their efforts throughout the mining process. Block rewards are also the way in which new bitcoin enters into circulation
Whenever miners sell their BTC, it becomes available to the rest of the crypto market to buy.
When Bitcoin’s creator, Satoshi Nakamoto, launched the protocol in 2009, they created a computer program to manage the amount of new bitcoin units that are released as block rewards. Every 210,000 blocks, or approximately every four years, a systematic event called a Bitcoin halving takes place.
Each Bitcoin halving automatically slashes the amount of new BTC given as block rewards by 50% until the next halving takes place. Initially, block rewards awarded 50 newly-minted BTC to successful miners.
On November 28, 2012, the first Bitcoin halving took place and reduced block rewards from 50 BTC to 25 BTC. The second halving activated on July 09, 2016, and cut rewards by a further 50% to 12.5 BTC.
These halvings will continue programmatically reducing the amount of bitcoin given as block rewards by 50% each time until the number of BTC in circulation reaches the 21 million maximum supply limit.
Once the protocol issues all 21,000,000 bitcoin, which is expected to happen in the year 2140, no new units of bitcoin will be created.
This means that all block rewards received after 2140 will contain zero bitcoin.
Want to learn even more about how bitcoin enters circulation and how this halving mechanism works?
Check out the Kraken Learn Center article, What is a Bitcoin Halving?
How hard is it to win Bitcoin block rewards? 🎛️
The ease or difficulty of winning the mining competition and earning the block reward comes down to three key factors:
-
Hashrate.
-
Mining difficulty.
-
Equipment.
Hashrate
Hashrate is a metric used to track the total computational power of all miners in a blockchain network. In short, it combines the number of hashes per second each miner produces with their machines.
This measurement provides insights into the total size of a blockchain’s mining network and how secure it is against majority attacks.
As a network’s hashrate rises, it often leads to increased mining difficulty, and vice versa.
Going back to the Rubik’s cube example, the more people there are competing to solve the cube, the lower the chances are of winning.
Mining difficulty
The Bitcoin protocol has a built-in feature that automatically adjusts the difficulty of the mining competition to ensure that miners continue to discover new blocks as close to the 10 minute block time target as possible.
As mentioned above, newly minted bitcoin enters circulation via block rewards each time a miner successfully beats the target hash and is granted the right to add a new block to the blockchain.
To ensure that new coins don’t flood the market as the network swells with an ever-increasing number of new miners, an algorithmic difficulty adjustment system was coded into Bitcoin’s protocol by its creator, Satoshi Nakamoto, ahead of its launch to manage this issue.
The bitcoin mining difficulty algorithm is such that after every 2,016 blocks (approximately every two weeks), the protocol checks to see how long it took for miners to discover the winning hash for each block and compares that time to the 20,160 minutes it should take (10 x 2,016.)
If there’s suddenly a surge in the number of people mining bitcoin and new blocks are being discovered too fast, the algorithm will increase the target hash difficulty (increase the number of zeros at the front) to slow miners down.
Conversely, if the number of miners drops off or it starts taking too long for them to discover new blocks, the algorithm will make subsequent target hashes easier (by reducing the number of zeros at the front).
Think of it like adjusting the difficulty of completing a Rubik’s cube by increasing or decreasing the number of rows the cube has.
A 3x3 cube, for example, would be much easier to solve than a 5x5 cube, and so on.
Equipment
To gain a competitive advantage over others in the network, many miners use Application-Specific Integrated Circuits (ASIC) mining rigs. These machines are capable of generating hundreds of millions of hashes per second, and can be run in parallel to give owners a greater chance of winning block rewards.
Several large public companies including Riot Platforms, Marathon Digital and CleanSpark Inc. currently operate huge crypto mining facilities containing thousands of ASIC mining machines.
The participation of these larger outfits have dramatically increased Bitcoin’s overall hashrate, making it increasingly harder to discover new blocks.
It’s possible for anyone to see what the current Bitcoin hashrate is at any given time, using multiple free online hashrate charts.
Is bitcoin mining profitable for individuals? 📊
When mining difficulty increases, so too do the costs associated with mining.
In some cases, it can make it incredibly hard for solo miners to operate above break-even levels.
In these scenarios, many independent miners decide to pool their resources together in so-called mining pools.
Mining pools share their processing power and proportionally split any block rewards they earn amongst all members of the pool.
Today, the majority of bitcoin mining is done by these groups.
Start buying bitcoin
Now that you have learned all about bitcoin mining, are you ready to take the next step in your crypto journey?
Click the button below to buy bitcoin on Kraken today!