Blockchain mining can be tricky to grasp, especially for Web3 newcomers. Verifying crypto transactions and validating blocks is the fundamental process on which the blockchain operates. The decentralized aspect of the blockchain urges the need for a verification process that differs from centralized financial systems such as the bank. And thus, we have something known as “mining”. Mining is most famously known for the Bitcoin blockchain, as it is the process of generating new coins and verifying Bitcoin transactions.
So, if you are someone that knows a bit about crypto and blockchain mining or someone who can’t wrap your head around it, this article will be your guide through the intricate details of how mining works, the need for it, and a technical explanation for those who want to know a bit further.
What’s the Point of Blockchain Mining?
Before we dwell on how blockchain mining works, we have to understand why we need it in the first place. Blockchain technology is a decentralized ledger that conducts transactions without the need for intermediaries. It’s a peer-to-peer network that has no central authority, unlike traditional systems such as the bank.
The traditional bank keeps track of all customers’ transactions in one place, and thus, its centralization can be prone to attacks or power manipulation. The blockchain, however, is a decentralized ledger without single points of power. Instead, the blockchain’s infrastructure is distributed to thousands of computers that work together to operate it.
So, how can a system without any central authority manage to generate coins and verify transactions while maintaining order, integrity, and security? This is why cryptocurrencies needed a different system of verification that doesn’t rely on central management.
Controlling digital currency is trickier than regular fiat currencies. For example, cryptocurrencies are at risk of the double-spending problem. Double-spending happens when the same digital currency is used to conduct two different transactions. This doesn’t happen with fiat. You can’t use the same $100 bill to buy two different items.
This is where blockchain mining comes into play.
What Is Blockchain Mining?
Blockchain mining is the process of adding new cryptocurrencies into circulation, as well as verifying transactions in order to avoid double-spending and counterfeit activities within a distributed network.
For the sake of this article, we will take the Bitcoin blockchain as an example. Bitcoin mining is done by the “peers” or “nodes” that operate the network using sophisticated hardware. Since the network doesn’t have a central authority, there is no one to guide the nodes on which block of transactions is the first one. This can create chaos within a distributed system if the same block gets added multiple times to a blockchain.
There should be a certain consensus that the network has to reach. Bitcoin is a blockchain that uses a Proof-of-Work consensus mechanism. A consensus mechanism makes sure that the system stays in order, and creates a sequencing for the blocks.
In a proof-of-work consensus, Miners need to compete with each other by solving complex mathematical puzzles using high-powered computers. The one that ‘wins’ the competition by providing the right answer, submits his version of the ledger in order to be checked by 50% of the network. Of course, miners who participate in the verification process receive rewards for their work with crypto tokens.
This is how miners generate more bitcoins into the network. Of course, however, there are a set of rules that govern the mining process and prevent anyone from randomly adding new coins at will.
How Does Blockchain Mining Work?
So, how does blockchain mining actually work? Here’s the simple version:
- When a transaction is conducted by one party to another, it is broadcasted to the whole blockchain network and is stored in something called a memory pool.
- Each node or miner assembles unverified transactions into a block of data.
- Then, the miner’s job is to validate this block of transactions into a confirmed block.
- Each miner validates his own block of transactions by solving a complex computational puzzle using sophisticated hardware.
- The first miner to “win” gets the right to add his version of the block to the blockchain.
- The network validates the integrity of the winning miner’s block.
- Then finally, the block gets added to the blockchain.
- After the completion of the process, the transaction is successfully conducted the winning miner receives a block of reward consisting of newly created cryptocurrencies.
- This way, new cryptocurrencies were generated and transactions were verified by the mining process.
If you already know the simple explanation of how blockchain mining works and want to know more, or are curious about further details, we’ve got you covered. Let’s go step by step into the journey of a miner and discover how blockchain mining actually works, technically. Again, for this example, we’ll use the Bitcoin blockchain.
#1. Setting Up Mining Hardware
Since the Bitcoin blockchain uses a proof-of-work consensus, miners have to invest in powerful computer equipment such as a high-processing GPU, or an application-specific integrated circuit (ASIC). This can be very expensive to buy and operate. Most miners use ASICs that are far more powerful than regular GPUs or CPUs. However, operating on such energy-demanding hardware can generate enormous amounts of power.
#2. Hashing Transactions
In order to conceal the data of transactions, miners have to submit each transaction through a hashing function. Hash is the equivalent of a password that encrypts certain data. Therefore, a hash is a mathematical function that turns arbitrary input of data into an encrypted output. The hash will always be of a certain specific length no matter what the underlying data is.
The hash is a 64-digit hexadecimal number. This means:
- The hash is always a 64 digits value.
- The value is a probability factor based on 10. There are 10 possibilities for a certain number of 0 to 10.
- The value is hexadecimal, meaning it has 16 possibilities. The numbers from 0 to 10 represent the decimal system. So, the first six letters of the alphabet are added to represent the other 6 factors (A, B, C, D, E, and F).
A hash for a certain transaction can therefore be something like this:
#3. Creating a Merkle Tree
After the miner performs a hashing function on each transaction, he organizes the generated hashes into something called a Merkle tree. This is done to render the blockchain mining process more efficient. The block of transactions is divided into two sections. The first section is the block header that includes the hash and the second section is the data that includes a list of transactions.
In order to validate a transaction, miners have to repeatedly hash data to produce a certain valid output (more on that later on). Instead of hashing and validating each and every transaction on its own, miners create Merkle trees.
Merkle trees are a structure that organizes hashes into pairs and hashes them together. Then the outputs are again organized into pairs of hashes and hashed again. The process is repeated until there is a single total hash known as the Merkle root. So, when miners want to validate a block, only the root hash is used in the block. This way, miners only have to mine the block header instead of the entire block. Here’s an example of how might that look.
#4. Mining (Nonce Value)
So now the miner has hashed out transactions and created Merkle trees, it’s time to start the actual mining. Remember before when we stated that in order for a miner to “win” in a PoW consensus, he has to perform complex mathematical computations? Well, the computations performed are guessing the target hash.
The target hash is a numeric value that a hashed block header has to be equal to or less than in order to be valid. When a miner is successful at reaching the target hash or less, the block becomes valid and the miner is therefore rewarded. So, when you hear that mining requires a lot of computer processing, it’s because miners have to make guesses to reach the target hash.
Guessing the target hash is done using something called a nonce. A nonce is short for “number only used once” and miners use it to generate as many hashes to ultimately reach the target hash. You can consider a nonce as a rolling dice. Miners generate as many nonces over and over again until one miner reaches the target hash. The first miner whose nonce generates a hash less than or equal to the target hash wins. This is basically what “complex computational puzzle” means when it comes to blockchain mining.
#5. Winning Conditions (Mining Difficulty)
So, what do we mean by in order for a miner to win he has to generate less than or equal to the target hash?
First, all target hashes begin with a string of leading zeros. The first winning condition is that the miner’s hash has to have the minimum number of leading zeros. For example, if the target hash begins with 4 zeros, the miner’s hash has to also begin with 4 zeros.
Let’s better illustrate the example with a graphic from Investopedia.
However, reaching this target is hard. Miners that work on their own, no matter what advanced processing system they use, will most likely fail to reach the target hash. This is why most miners join a mining pool where they combine their computing power and split the rewards.
#6. Broadcasting to Network
After miners reach the target hash, the block becomes a confirmed block and it gets broadcasted to the whole network for validation. After the mined block is verified, it gets added to the blockchain and all miners move on to mine the next block, and the cycle repeats itself for another target hash. Miners who fail to reach the target hash on time will discard their candidate block and move on to the next.
Here’s a summary of the whole process.
What’s a Mining Pool?
Since the probability of hitting the target hash is extremely low, miners with a small processing power percentage have a small chance of winning. Blockchain mining pools are a group of miners who join their computing resources to increase their chance of winning. When a mining pool successfully hit the target hash and mines a block, the block reward gets divided among the miners proportionally to the work they contributed.
However, mining pools have raised some concerns regarding the decentralization of the network. If an entity acquires more than 51% of the total mining power, the network can be prone to a 51% attack.
Currently, there are 4 Bitcoin mining pools that acquire more than 51% of the total mining power if combined. However, they most likely wouldn’t perform an attack since that would make the price of Bitcoin plummet.
Is Mining Profitable?
Yes and no. It depends on the investment you are willing to make regarding the right mining tools and equipment. In addition, blockchain mining can be profitable if you join a mining pool as well as other variable factors. These factors include:
- Cryptocurrency Prices: If the value of a cryptocurrency increase, so will the price of its fiat value. On the other hand, if the value of crypto increases, so will the mining rewards.
- Hardware: Mining hardware is expensive and hard to maintain and upkeep. Mining equipment may need to have upgrades, and thus, miners have to allocate a budget to upgrade their mining machines.
- Electricity Bill: The cost of electricity is another factor. If electricity costs are too high, they may outweigh earnings and make mining unprofitable.
For example, currently, the Bitcoin mining reward is 6.25 BTC. That’s around $171.140. This might seem like a lot of money, however, in comparison to the electricity bill and hardware costs, this might not be that profitable. Keep in mind the chance for a single miner to win on his own is very low. This is why it’s more profitable to join a mining pool. Fewer electricity costs and high profit.
So, is there a definitive answer to whether blockchain mining is profitable or not? Not really. It all depends on your investment. Keep in mind that mining needs extensive research and risk management. Miners have to conduct many risk assessments and evaluate the potential costs and earnings of mining before starting.
However, regarding the Bitcoin blockchain, mining rewards are being cut in half every 4 years or after 210,000 mined blocks. This is known as Bitcoin Halving. When Bitcoin first started abc in 2009, the mining reward was 50 BTC. It was later cut in half to become 25 BTC in 2012, then 12.5 BTC in 2016, and finally 6.25 BTC in 2020. This means that the next halving event will take place in 2024 when the mining reward will become 3.125 BTC.
The Bitcoin halving event was encoded by Satoshi Nakamoto, Bitcoin’s founder, in order to assure that the quantity of Bitcoin mined will drop over time. This is because Bitcoin has a limit of 21 million coins, and by cutting down rewards, miners will gradually lose the incentive to mine new coins, which will ultimately stop at the 21 million BTC mark.
Downsides of Blockchain Mining
The first downside of blockchain mining is the risk factor it brings with it. Placing hundreds of thousands of dollars in blockchain mining equipment with no return on investment can be risky. Also, since cryptocurrencies are a new technology, many countries prohibit any crypto mining activities, which can create a legal risk.
One of the biggest downsides of crypto mining has to be the environmental damage it causes resulting from the enormous energy usage. Bitcoin mining alone uses more electricity than in many European countries such as Norway. This is due to the fact that Bitcoin still runs on a proof-of-work consensus, which is basically miners running a race to hit the target hash by using power-hungry machines.
The environmental damage Bitcoin is causing has led the second most popular blockchain, Ethereum, to reconsider its consensus mechanism.
Change of Consensus: Ethereum Merge
Back in September 2022, Ethereum shifted its consensus mechanism from proof-of-work to proof-of-stake in an update known as the Merge. A proof-of-stake consensus doesn’t require the act of mining. Instead, miners become validators. Instead of validators using massive computational power to solve hashing functions, they “stake” a significant portion of their funds. The protocol randomly selects a certain validator once they stake their funds.
This shift in consensus drastically reduced energy consumption, which had fewer effects on the environment.
Mining Legal Concerns
Blockchain mining’s legality depends on which country you reside in. Some countries ban cryptocurrencies since they act as a threat to fiat currency and centralized governmental power. These countries include Bangladesh, China, Egypt, Iraq, Morocco, Nepal, Qatar, and more. However, there are more countries where crypto mining is legal than there are countries where it is illegal.
However, recently, the U.S. Treasury Department proposed a 30% crypto tax on the cost of powering mining facilities. This is a way to reduce the number of crypto-mining machines across the country, which will result in less energy consumption.
The Sustainability of Mining
Blockchain mining is the foundational process on which many blockchains function. However, proof-of-work blockchains such as Bitcoin might become problematic due to its energy-hungry consensus. Not to mention, the Bitcoin mining process takes a long time in comparison with other traditional financial systems. It takes roughly 10 minutes to mine a single Bitcoin block. In addition, the average transaction per second (TPS) rate of the Bitcoin blockchain is 5 TPS
This alludes to the infamous blockchain scalability issues. Shifting the mining process to a verification one by changing consensus mechanisms to more sustainable ones might be a step in the right direction. That is since Ethereum’s proof-of-stake led the blockchain to a 27 TPS rate.
Blockchains are still in their infancy stage and still have a lot of time to advance. If you wish to participate in the mining process, you should always do your own research and make risk evaluations to assess whether or not you can afford such an investment.