Mining is the process by which the miner adds a new block to the blockchain. By this, the network confirms recent transactions and plays a crucial role in the blockchain ledger’s maintenance and development.
When a user tries to perform the transaction from the blockchain network the crypto amount is dispatched from his wallet with the help of the wallet application. This transaction is added to the pool of unconfirmed transactions, waiting for its turn to be selected by the miner.
When the transaction is performed, the wallet application advertises it to be selected and confirmed by blockchain miners.
A miner then picks the transaction from the pool of unconfirmed transactions, multiple miners can pick the same transaction from the pool and creates their block by performing computational work in solving a complex mathematical problem. The first miner to solve the problem, his block is added to the blockchain network. And the runner-up miner is called Omar and their block is called the Omar block.
The miner who successfully adds the block to the network wins the reward in exchange for his work.
To mine any new block, the miner has to follow some consensus protocol.
It is the procedure by which all the peer nodes of the blockchain are brought to an agreement about the present state of the ledger.
Since blockchain is a distributed decentralized network that provides immutability, transparency, and security. There is no centralized authority present to verify and validate the transactions, yet every transaction in the blockchain is valid and secure because of its consensus protocol and algorithms.
Several consensus algorithms are adopted by various blockchains
- Proof of Work: This consensus algorithm is used by several blockchains for selecting the miner for the generation of the next block. The idea behind this algorithm is to generate the hash for adding the block into the network. The hash is generated based on the difficulty level set by the network. And the generation of hash requires a lot of computational work. And the miner who generates the hash as soon as possible can add the block to the network
- Proof of Stake: This consensus algorithm is widely used after PoW. It reduces the computational work required to verify and add the block. Here the miner or validator needs to invest in the coins by having some of the coins as the stake. The validator is then selected randomly to validate the block. This mechanism randomize who gets to validate the block instead of using the computational work to select the miner. To validate the block the coin owner must stake the specific amount of coins. For eg: Ethereum requires 32 ETHs for the user to become the validator.
Hence the miners and the mechanism play important in maintaining the state of this distributed ledger and keeping it immutable and secure.