Résumé

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

  • The work performed by miners requires intensive computing resources, but it is what keeps a blockchain network secure.

What is cryptocurrency mining?

Cryptocurrency mining ensures the security and decentralization of cryptocurrencies such as Bitcoin, which are based on a proof-of-work (PoW) consensus mechanism. Mining is the process by which cryptocurrency transactions between users are verified and added to the public blockchain ledger. As such, mining is an essential element that allows Bitcoin to operate without the need for a central authority.

Mining operations are also responsible for introducing new units to the existing supply in circulation. However, cryptocurrency mining follows a set of tightly coded rules that govern the mining process and prevent anyone from arbitrarily creating new units. These rules are integrated into the underlying protocols of the cryptocurrency and applied by the entire network made up of thousands of nodes.

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

How does crypto mining work?

As new transactions are made on the blockchain, they are sent to a pool called a memory pool. A miner's job is to check the validity of these pending transactions and organize them into blocks.

You can think of a block as a page of the blockchain ledger, where multiple transactions are recorded (along with other data). Specifically, a mining node is responsible for collecting unconfirmed transactions from the memory pool and assembling them into a candidate block.

Then the miner will try to convert this candidate block into a valid and confirmed block. To do this, the miner must solve a complex mathematical problem that requires a lot of computer resources. However, for each successfully mined block, the miner receives a reward consisting of newly created cryptocurrencies and transaction fees. Let's take a closer look at how it works.

Step 1: Hashing Transactions

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

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

In addition to hashing and listing each transaction individually, the miner also adds a custom transaction, in which it sends itself the block reward. This transaction is called a coinbase transaction and is what creates new units of cryptocurrencies. In most cases, the coinbase transaction is the first to be recorded in a new block, followed by any pending transactions it wishes to validate.

Step 2: Creating a Merkle Tree

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

The new hash outputs are then organized into pairs and hashed once more, and the process is repeated until a unique hash is created. This last hash is also called the root hash (or Merkle root) and is essentially the hash that represents all the previous hashes that were used to generate it.

L’arbre de Merkle organise les hachages des transactions en paires et les hache ensuite.

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

A 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 a new block hash. But in addition to these two elements, they must also add an arbitrary number called a nonce.

So when the miner tries to validate its candidate block, it must combine the root hash, the previous block's hash, and a nonce, then submit them all through a hash function. Its goal is to create a hash that is considered valid.

Since the root hash and the hash of the previous block cannot be changed, miners must change the nonce value multiple times until a valid hash is found. In order to be considered valid, the output (block hash) must be less than a certain target value, determined by the protocol. In Bitcoin mining, the hash of the block must start with a certain number of zeros, this is called the mining difficulty.

Step 4: Broadcast the mined block

As we just saw, miners have to hash the block header over and over again, with different nonce values. They repeat this work until they find a valid block hash. The miner who finds it will then broadcast his block on the network. All other nodes will check if the block and its hash are valid and, if so, add the new block to their copy of the blockchain.

At this point, the candidate block becomes a confirmed block, and miners move on to mining the next block. Miners who failed to find a valid hash in time abandon their candidate block, and the mining race begins again.

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

Sometimes two miners broadcast a valid block at the same time and the network ends up with two competing blocks. Miners then start mining the next block based on which block they received first. This results in the network being (temporarily) split into two different versions of the blockchain.

Competition between these blocks will continue until the next block is mined, following either of the competing blocks. When a new block is mined, the block before it is considered the winner. The block that is abandoned is called an orphan block or stale block, which causes all miners who chose that block to switch to the winning block's chain.

What is mining difficulty?

The mining difficulty is regularly adjusted by the protocol in order to guarantee a constant rate of creation of new blocks and, therefore, a regular and predictable issuance of new cryptocurrency units. The difficulty adjusts proportionally to the computing power (hash rate) devoted to the network.

Therefore, whenever new miners join the network and competition increases, the hashing difficulty increases, thus preventing the average block time from decreasing. On the other hand, if many miners decide to leave the network, the hashing difficulty will decrease, making it less difficult to mine a new block. These adjustments help keep the block time constant, regardless of the total hashing power of the network.

Types of cryptocurrency mining

There is no single method for mining cryptocurrencies. The equipment and process changes as new hardware and consensus algorithms appear. Typically, miners use specific computing devices to solve complex cryptographic equations. Let's see how some of the most common mining methods work.

CPU mining

Central processing unit (CPU) mining involves using a computer's processor to perform the hashing functions required by the PoW consensus. In the early days of Bitcoin, the cost and barrier to entry of mining were low. The mining difficulty could be handled by a regular processor, so anyone could try mining BTC and other cryptocurrencies.

However, as more people started mining and the network's hash rate increased, mining profitably became more and more difficult. Furthermore, the evolution of mining machines with higher computing power eventually made CPU mining almost impossible. Today, 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. While they are generally used for video games or graphics rendering, they can also be used for mining.

GPUs are relatively inexpensive and more flexible than ASIC mining hardware. Some altcoins can be mined with GPUs, but efficiency depends on the mining algorithm and difficulty.

ASIC mining

An Application-Specific Integrated Circuit (ASIC) is designed for a specific use. In the crypto field, this refers to specialized hardware developed for mining. ASIC mining is known for its efficiency but also for its high cost. Since ASIC miners are state-of-the-art, the cost of a unit is much higher than central processing units (CPUs) or graphics cards.

Additionally, continued advancements in ASIC technology can quickly make older ASIC models uneconomical and, therefore, require regular replacement. Even excluding electricity costs, ASIC mining is one of the most expensive methods.

Mining pools

As a block reward is given to the first successful miner, the probability of finding the correct hash is extremely low. Miners with only a small percentage of the mining power have very little 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 (hash power) to increase the probability of earning block rewards. When the pool successfully finds a block, miners share the reward equally among all pool members, based on the amount of work provided.

Mining pools can be beneficial to individual miners in terms of hardware and electricity costs, but their dominance in mining raises concerns about a 51% attack on networks.

What is Bitcoin mining and how does it work?

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

Proof of Work (PoW) is the original blockchain consensus mechanism created by Satoshi Nakamoto. It was introduced in the Bitcoin whitepaper in 2008. In short, PoW determines how a blockchain network achieves consensus among all distributed participants without a third-party intermediary. To do this, it requires significant computing power in order to deter malicious actors.

As we have seen, transactions on a PoW network are verified by miners. To earn the right to mine the next block, miners compete by solving complex cryptographic puzzles using specialized mining hardware. The first miner to find a valid solution can then broadcast their block of transactions on the blockchain, and receive the block reward.

The amount of crypto in a block reward varies between different networks. For example, on the Bitcoin blockchain, a miner who finds a block can get 6.25 BTC plus fees as a 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 (roughly every four years).

Will crypto mining be profitable in 2023?

While it is possible to make money mining cryptocurrencies, it requires careful consideration, 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 adopt risk management practices and evaluate the potential costs and benefits of mining before launching.

The profitability of cryptocurrency mining depends on several factors. One of them is the evolution of the price of cryptocurrencies. When cryptocurrency prices increase, the fiat currency value of mining rewards also increases. Conversely, profitability may decrease as prices fall.

The efficiency of mining hardware is also a crucial factor in determining the profitability of mining. Mining hardware can be expensive and therefore miners must balance the cost of the hardware with the potential profits it can generate. Another factor to consider is the cost of electricity, if it is too high it can weigh on profits and make mining unprofitable.

Additionally, mining hardware may need to be upgraded relatively often, as it tends to become outdated quite quickly. The new models will perform better than the old ones and if miners don't have the budget to upgrade their machines, they will likely struggle to stay competitive.

Finally, there are the changes that occur at the protocol level. For example, Bitcoin halving can affect mining profitability because it halves the reward for mining a block. Additionally, Ethereum completely switched from PoW consensus mechanism to Proof of Stake (PoS) in September 2022, making mining useless.

Conclusion

Cryptocurrency mining is an essential part of bitcoin and other PoW blockchains, as it contributes to the security of the network and the regularity of the issuance of new units. Additionally, mining can generate passive income for miners. You can learn more with these step-by-step instructions in our article How to Mine Crypto?

Mining has certain advantages and disadvantages, the most obvious being the potential income from block rewards. However, mining profits can be affected by a number of factors, including electricity costs and market prices. So, before you start mining, you need to do your own research (DYOR) and evaluate all the potential risks.

More information

  • What are permissioned and permissionless blockchains?

  • What is staking in crypto?

  • What is an NFT?

Disclaimer and Risk Warning: This content is presented to you “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 professional advice, nor as a means of recommending the purchase of a specific product or service. You should seek advice from appropriate professionals before making any decisions. Where the article was written by a third-party contributor, please note that the opinions in the article do not necessarily reflect those of Binance Academy. Please read our full disclaimer here to find out more. Prices of digital assets can be volatile. The value of your investment may go down as well as up and you may not get back the amount you invested. You are solely responsible for your investment decisions and Binance Academy is not responsible for any losses you may incur. This content should not be construed as financial, legal, or professional advice. For more information, please refer to our Terms of Use and Risk Warning.