Too Lazzzy to Read? Listen to this article👇
Cryptocurrency mining is a process in which transactions between users are checked and added to the open book of the blockchain. The extraction process is also responsible for introducing new coins into the existing negotiable offer and is one of the key elements that allow cryptocurrencies to function as a decentralized peer-to-peer network, without the need for external central authority.
Bitcoin is the most popular and well-known example of cryptocurrency mining, but it is worth noting that not all cryptocurrencies are mining. Bitcoin mining is based on a consistent algorithm called Proof of Work.
How does it work?
A miner is a node in the network that collects transactions and organizes them into blocks. Whenever transactions are made, all nodes on the network receive them and check their validity. Then the miner nodes collect these transactions from the memory pool and start collecting them in a block (candidate block).
The first step in cryptocurrency mining is the individual hashing of each transaction taken from the memory pool, but before starting the process, the miner’s node adds a transaction in which a mining reward is sent (the reward for the block). This transaction is called a coin-based transaction, which is a transaction in which coins are created “from nothing” and in most cases is the first transaction recorded in a new unit.
After each transaction has been subjected to hash, the hashes are then organized into something called the Merkle tree (or hash tree), which is formed by organizing the various hashes of the transactions in pairs and the following hashing.
The output is then organized in pairs and returned to the hash and the process is repeated until it reaches the “top of the tree”. The top of the tree is also called the root hash (or Merkle root) and is a single hash that represents all the previous hashes that were used to generate it.
The root hash – along with the hash of the previous block and a random number, called nonce – is then inserted into the block header. The header of the block is then subjected to hash, creating output based on these elements (root hash, a hash of the previous block and number of once), as well as numerous other parameters. The resulting output is a block hash and will act as an identifier for the newly generated block (candidate block).
To be considered valid, the output (block hash) must be less than a certain target value, which is determined by the protocol. In other words, the hash of a block must start with a certain number of zeroes.
The target value, also known as hashing complexity, is regularly regulated by the protocol, guaranteeing a constant rate at which new blocks are created and proportional to the amount of hashing power allocated to the network.
As a result, whenever new miners join the network and the competition increases, the complexity of the hash will increase, making it impossible to reduce the average block time. On the contrary, if the miners decide to leave the network, the complexity of hashing will be reduced, maintaining the block time constant, even if less network power is assigned to the network.
The mining process requires miners to continue to execute hash of the block header over and over again, scrolling once until one of the miners in the network finally receives a valid hash of the block. When a valid hash is found, the foundation node will transmit the block to the network. All other nodes will check if the hash is valid and if so, will add the block to their copy of the blockchain and proceed to the analysis of the next block.
However, sometimes it happens that two miners simultaneously transmit a real block and the network ends with two competing blocks. The miners begin to extract the next block, based on the block they received first. The competition between these blocks will continue until the next block is obtained based on one of the competing blocks. An abandoned block is called an abandoned or obsolete block. The miners of this block will return to the extraction of the winning block.
Although the premium for the block is given to the miner, who first finds a valid hash, the probability of finding a hash is equal to a fraction of the total extraction power in the network. Miners with a small percentage of mining energy have little chance of finding the next block on their own. Mining pools are created to solve this problem.
This means sharing the resources of miners who share their computing power across the network to distribute the reward equally among all members of the pool, depending on the amount of work they contribute to the probability of block detection.