Summary

  • Crypto mining verifies and validates blockchain transactions. It also refers to the process of creating new cryptocurrency units.

  • Although the work miners do requires intensive computing resources, it is what helps keep a blockchain network secure.

What is crypto mining?

Crypto mining ensures the security and decentralization of cryptocurrencies, such as Bitcoin, which are based on the Proof of Work (PoW) consensus mechanism. Mining is the process by which transactions are verified and added to the public blockchain ledger. As such, mining is a fundamental element that allows Bitcoin to function without the need for a central authority.

Mining operations are also responsible for adding coins to the existing circulating supply. However, cryptocurrency mining follows a set of hard-coded rules that govern the mining process and prevent anyone from arbitrarily creating new coins. These rules are built into the underlying cryptocurrency protocols and applied to the entire network of thousands of nodes.

To create new units of cryptocurrency, miners use their computing power to solve cryptographic puzzles. The first miner to solve the puzzle has the right to add a new block of transactions to the blockchain and propagate it to the network.

How does cryptocurrency mining work?

As new transactions are made on the blockchain, they are sent to a pool called a memory pool. The job of a miner is to verify the validity of these pending transactions, as well as organize them into blocks.

You can imagine a block as a blockchain ledger page, on which a series of transactions are recorded (along with other data). More specifically, a mining node is responsible for collecting unconfirmed transactions from the memory pool and gathering them into a candidate block.

The miner will then attempt to convert this candidate block into a valid and confirmed block. To achieve this, the miner must solve a complex mathematical problem that requires many computing resources. However, for each successfully mined block, the miner receives a block reward consisting of the newly created cryptocurrencies plus transaction fees. Let's see how it works.

Step 1: Transaction Hashing

The first step to mining a block is to take pending transactions from the memory pool and pass them, one by one, through a hash function. Each time a piece of data passes through the hash function, a fixed-size output called a hash is generated.

In the context of mining, the hash of each transaction consists of a series of numbers and letters that functions as an identifier. The transaction hash represents all the information contained in it.

Apart from hashing and adding each transaction individually, the miner also adds a custom transaction, in which he sends himself the block reward. This transaction is known as a coinbase transaction, and it is what creates new coins. In most cases, this transaction is the first to be recorded in a new block, followed by all pending transactions that were waiting to be validated.

Step 2: Create a Merkle Tree

After each transaction has been hashed, the hashes are organized into what is called a Merkle tree (also known as a hash tree). The Merkle tree is generated by arranging transaction hashes into pairs, and then hashing them.

The new hash outputs are organized into pairs and hashed again, and the process is repeated until a single hash is created. This last hash is called the root hash (or Merkle Root) and is, basically, the "root" hash that represents all the previous hashes that have been used to generate it.

El árbol de Merkle organiza los hashes de transacciones en pares y luego los somete a otro hashing.

Step 3: Find a valid block header (block hash)

The block header functions as an identifier for each individual block, meaning that each block has a unique hash. When creating a new block, miners combine the hash of the previous block with the root hash of their candidate block, to generate the hash of a new block. They must also add an arbitrary number known as a nonce.

Therefore, when trying to validate their candidate block, a miner must combine the root hash, the previous block hash, and a nonce, and send it all through a hash function. Your goal is to do this repeatedly until you can create a valid hash.

The root hash and the previous block hash cannot be modified, so miners must change the nonce value several times until a valid hash is found. To be considered valid, the output (block hash) must be less than a certain target value, which is determined by the protocol. In Bitcoin mining, the block hash must start with a certain number of zeros, which is called the mining difficulty.

Step 4: Propagate the mined block

As we have seen, miners must hash the block header multiple times with different nonce values. They do this until they find a valid block hash and subsequently the miner who found it will propagate this block to the network. The rest of the nodes will check if the block and its hash are valid, and if so, they will add the new block to their copy of the blockchain.

At that point, the candidate block becomes a confirmed block, and all miners proceed to mine the next one. All miners who couldn't find a valid hash in time discard their candidate block and the mining race gets underway again.

What happens if two blocks are mined at the same time?

Sometimes it happens that two miners present a valid block at the same time, and the network encounters two competing blocks. In this situation, miners begin mining the next block based on the block they received first, causing the network to temporarily split into two different versions of the blockchain.

The competition between these two blocks will continue until the next block is mined on one of the competing blocks. When a new block is mined, the block that arrives first will be considered the winner. The block that is abandoned is called an orphan block or stale block, and will cause the miners who chose it to return to mining the winning block chain.

What is mining difficulty?

The protocol regularly adjusts the mining difficulty to ensure a constant rate for the creation of new blocks and, in return, a constant and predictable issuance of new coins. The difficulty is adjusted in proportion to the amount of computing power (hash rate) dedicated to the network.

Therefore, every time new miners join the network and competition increases, the hashing difficulty increases, thus preventing the average block time from decreasing. Conversely, if many miners leave the network, the hashing difficulty decreases, making it easier to mine a new block. These settings keep the block time constant, regardless of the total hashing power of the network.

Types of cryptocurrency mining

There are many ways to mine cryptocurrencies. Teams and processes change as new hardware and consensus mechanisms emerge. Typically, miners use specialized computing units to solve the complex cryptographic equations. Let's see how some of the most common mining methods work.

CPU Mining

In Central Processing Unit (CPU) mining, the computer's CPU is used to execute the hash functions required by the PoW mechanism. In the early days of Bitcoin, mining costs and entry barriers were low and its difficulty could be handled with a conventional CPU, so anyone could try mining BTC and other cryptocurrencies.

However, as more people started mining and the network's hash rate increased, profitable mining became increasingly difficult. Likewise, over time, the rise of specialized mining hardware with greater computing power made CPU mining virtually impossible. Currently, CPU mining is no longer a viable option as all miners use specialized hardware.

GPU Mining

Graphics Processing Units (GPUs) are designed to process a wide range of applications in parallel. Although they are commonly used for video games or graphics rendering, they can also be applied to mining.

GPUs are relatively inexpensive and more flexible than popular ASIC mining hardware. Although you can mine some altcoins with GPU, its efficiency depends on the mining difficulty and the algorithm.

ASIC Mining

An Application Specific Integrated Circuit (ASIC) is designed to serve a single specific purpose. In the case of cryptocurrencies, it designates specialized hardware developed for mining. ASIC mining is known to be highly efficient, but expensive. As ASIC miners are at the forefront of mining technology, the cost of a unit is much higher than that of CPUs or GPUs.

Additionally, the continued advancement of ASIC technology may make older ASIC models less cost-effective and require routine replacement. Even if electricity costs are excluded, this makes ASIC mining one of the most expensive ways to mine.

Mining pools

Since the first successful miner receives a block reward, the probability of finding the correct hash is extremely low. Miners who have a small percentage of mining power have a very small chance of discovering the next block on their own. Mining pools offer a solution to this problem.

Mining pools are groups of miners who pool their resources (hashing power) to increase the probability of earning block rewards. When the pool is successful in finding a block, the pool's miners share the reward based on the amount of work each has contributed.

Mining pools can benefit individual miners in terms of hardware and electricity costs, although their dominance over mining raises concerns about a 51% attack on the network.

What is Bitcoin mining and how does it work?

Bitcoin is the most popular and established example of a mineable cryptocurrency. Bitcoin mining is based on the PoW consensus algorithm.

PoW is the original blockchain consensus mechanism created by Satoshi Nakamoto, which was introduced in the Bitcoin whitepaper in 2008. Simply put, PoW determines how a blockchain network achieves consensus among all distributed participants without external intermediaries. It achieves this by requiring significant computing power that discourages those who act in bad faith.

As we have already seen, the miners who verify transactions on a PoW network are miners who compete to solve complex cryptographic equations using specialized mining hardware. The first miner to find a valid solution can submit their block of transactions to the blockchain and receive the block reward.

The amount of cryptocurrency in the block reward varies across different blockchains. For example, on the Bitcoin blockchain, miners can earn 6.25 BTC block reward (as of March 2023). Due to Bitcoin's halving mechanism, the amount of BTC in a block reward halves every 210,000 blocks (approximately every four years).

Is cryptocurrency mining profitable in 2023?

Although cryptocurrency mining can make money, it requires considerable evaluation, risk management, and research. It also involves investments and risks, such as hardware costs, cryptocurrency price volatility, and cryptocurrency protocol changes. To mitigate these risks, miners often carry out risk management practices and evaluate the potential costs and benefits of mining before embarking on it.

The profitability of crypto mining depends on several factors. One of them is changes in cryptocurrency prices. When these prices increase, the fiat value of mining rewards also increases. On the contrary, profitability may decline along with falling prices.

The efficiency of mining hardware is also a crucial factor in determining mining profitability. Mining hardware can be expensive, so miners must balance the cost of the hardware with the potential rewards the activity will generate. Another factor they need to take into account is the cost of electricity: if it is too high, it could exceed profits and make mining unprofitable.

Additionally, mining hardware will likely need to be updated relatively frequently, as it tends to become outdated rather quickly. New models will outperform old ones, and if miners don't have the budget to upgrade their machines, they will likely have trouble remaining competitive.

Finally, there are the changes that happen at the protocol level. For example, the Bitcoin halving can affect mining profitability because it cuts the rewards for mining a block in half. Likewise, Ethereum left aside the PoW consensus for the Proof of Stake (PoS) mechanism in September 2022, which meant that mining was no longer used on that network.

Conclusions

Crypto mining is a fundamental part of Bitcoin and other PoW blockchains, as it secures the network and keeps the issuance of new coins constant. Additionally, mining can generate passive income for miners. You can learn more with these step-by-step instructions in our article How to Mine Cryptocurrencies.

Mining has certain advantages and disadvantages. The most obvious advantages are the potential for profits from block rewards. However, this is affected by a number of factors, including the cost of electricity and market prices. With this in mind, before jumping into crypto mining, you should do your own research (DYOR) and evaluate all potential risks.

Further reading

  • What are permissioned and permissionless blockchains?

  • What is cryptocurrency staking?

  • What is an NFT?

Legal Notice and Risk Warning: This content is presented "as is" for general information and educational purposes only, without representation or warranty of any kind. It should not be construed as financial, legal or other professional advice nor is it intended to recommend the purchase of any specific product or service. You should seek your own advice from suitable professional advisors. As this article is a product of third-party contributions, please note that the opinions expressed are those of the third-party contributor and do not necessarily reflect those of Binance Academy. For more information, read our full legal notice here. Digital asset prices can be volatile. The value of an investment can go down as well as up, and you may not get back the amount invested. Only you are responsible for your investment decisions. Binance Academy is not responsible for any losses you may incur. This material should not be construed as financial, legal or other professional advice. For more information, please see our Terms of Use and Risk Warning.