How does bitcoin mining work?

Dhiraj Khodade
3 min readFeb 28, 2021

Blockchain is the core technology behind bitcoin.

What is Blockchain?

Blockchain is digital ledger of transactions and it is based on peer-to-peer (P2P) topology, so it allows data/transactions to be stored globally on thousands of servers. Allows anyone on the network to see everyone else’s data/transactions. That makes it difficult for any one user to gain control and tamper the transactions. Basically it is shared, immutable ledger which makes it impossible to hack or change the system.

What is Bitcoin mining?

As we know Blockchain is decentralized P2P network which has no central authority or middleman instead it is powered by it’s users. So Bitcoin transactions are verified in decentralized system where people contribute computing resources to verify these transactions.

The process of verifying transactions is called mining.

This is called mining because it is similar to mining of commodities like gold, where it takes lots of efforts and lots of resources to mine gold and there is only so much gold in earth that makes its supply limited and the amount of gold mined every year is roughly same. Similarly huge computing power is required in process of mining bitcoin and number of bitcoins generated decreases over the time. Also there is limited supply, only 21 million bitcoins will ever be created. So bitcoin being a currency with limited supply makes it deflationary currency.

Why do we need Mining process?

Bitcoin mining is done to make the bitcoin blocks secure and tamper proof. And people who contribute computing power and resources to mine blocks are rewarded with transaction fees and newly created bitcoins.

How Miners get Rewarded?

Miners verify transaction using software called bitcoin miner. This program basically puts all the transactions happened in particular time period (approx. 10 mins for bitcoin can be different for different crypto currencies) together which is called as block. Miners try to guess the hash of this new block which is expensive operation in terms of computing and the miner who guesses this hash first gets the mining reward and the block is added to blockchain with link to previous block using hash of previous block. So each block has hash of previous block along with its own hash. If anyone has to tamper the block he/she has to recalculate the hash of all the blocks in the blockchain which is very very time consuming and costly operation and also remember blockchain is decentralized ledger and thousands of users have the copy of blockchain so it is impossible for someone to hack or tamper the blockchain.

Proof-of-Work

Proof of work is just a piece of data that is hard to produce also called as mining difficulty. In bitcoin this difficulty self-adjusts every 2016 block which is approx 2 weeks and it also self adjusts in such a way that it should take approx 10 minutes to mine the block. If it takes less than 2 weeks to get to 2016 blocks then difficulty increases and if it takes more than 2 weeks then difficulty decreases.

When a valid block is mined the miner gets reward of few bitcoins currently (as of 2021) this reward is 6.5 BTC. In early days of bitcoin this reward was 50 BTC per block and this reward goes down by half every four years. Miners also get transaction fees which is paid by senders of transactions.

As you can guess mining is kind of gamble. Only first miner who mines the block only he/she gets the reward while others who were trying parallely do not get anything, instead all the computing resource they spent goes in vain. So miner started to organize themselves in groups to combine computing power with everyone in the group to increase chances of mining block and then share mining reward with everyone in group fairly.

--

--