Mining is the process by which new bitcoins are created but it is also the process that secures the system and prevents the creation of false transactions or the same bitcoin is spent twice. The idea here is to reward the miners who secure the system by giving them money (in addition to the fees included in each transaction).
Note: the total number of bitcoins that can be created is limited. It can only be 21 million and this limit will be reached in 2140. At that moment, the miners will be motivated to continue their work thanks to the transaction fees. This makes it a deflationary currency in the sense that a bitcoin should have more purchasing power over time because more and more wealth will be created without there being new bitcoins in return. You can get more information on Bitcoin Cash ABC fork.
Concretely the profession of minors is to validate the new transactions and add them in the blockchain. Every 10 minutes, all the transactions that have been created since the last transaction block was added are grouped into a new block that must be “validated” by the miners. This validation consists of a competition between all the minors so that they solve a mathematical problem based on the content of the new block to validate (called block candidate). The solution of this problem called “proof of work” is added in the block to prove that there was a significant effort made on it.
This aspect is fundamental because it is what allows Bitcoin to do without a central authority and in order to understand it well, we will detail how it works. The key issue to be addressed is: how to agree a network of unknowns on a universal truth knowing that in a network of unknowns, we can not trust anyone . To do this, the creator of Bitcoin, Satoshi Nakamoto, imagined a decentralized mechanism called “emergent consensus”. As we have seen, if you want to transfer bitcoins to an address, you must create a transaction and send it to the first node in the network that you find that will propagate it to the entire network.
Some of the nodes of the bitcoin network are specialized in mining. They are waiting for the creation of new blocks, and at this point, they start the competition to repot the new bitcoins that will be created by the person who will solve the problem posed by the new block as quickly as possible. Concretely, with each new transaction received, a node will add it to its stock of transactions where they wait to be added in a new block, the candidate block. When a block is validated by a node, the bitcoin network will warn everyone to start a new competition to create a new block with transactions that have been stored for the last 10 minutes. You can get more information on Bitcoin Cash ABC fork.
Indeed, after having verified that all the transactions that are in the stock are not already included in the previously calculated block (if there are any, it simply removes them), the node will create a new block with the transactions being done. finding in his stock. Then he will try to make it valid and therefore acceptable to the other members of the network and therefore “addable” to the blockchain. For this, he will try to provide proof of work by trying to solve a mathematical calculation that involves testing a lot of possibilities.
Concretely, the node will create a block itself, locally, with the following fields in the header:
Version : Version number of the software / protocol.
Hash of the previous validated block : “fingerprint” of the parent block.
Merkle Root .
Timestamp : Approximate date of creation of the block.
Difficulty target : Level of difficulty (and yes, the difficulty of the problem varies “according to” the total power of the network so that, regardless of the number of machines that do the mining, it always takes about 10 minutes to validate a block).
Nuncio : This is the parameter that minors will change (for example by incrementing) in order to find the good value of nonce that allows to create a valid block.