Mining in Bitcoin (2019.8.23) | Monologue by Dr. Geek

Monologue by Dr. Geek

Lonely Researcher, Prof. Dr. Geek
He has been challenging advanced technology research in academia, education for young people and technology funding by the unique IT technologies for bright future of mankind.

Miners validate new transactions and record them on the global ledger or distributed database (blockchain). 

 

On average, a block (the structure containing transations) is mined every 10 minutes. 

 

Miners compete to solve a difficult mathematical problem based on a cryptographic hash algorithm. 

 

The solution found is called the Proof-Of-Work

 

This proof proves that a miner did spend a lot of time and resources to solve the problem. 

 

When a block is 'solved', the transactions contained are considered confirmed, and the bitcoin concerned in the transactions can be spend. 

 

So, if you receive some bitcoin on your wallet, it will take approximately 10 minutes for your transaction to be confirmed.

 

Miners receive a reward when they solve the complex mathematical problem. 

 

There are two types of rewards: new bitcoins or transaction fees. 

 

The amount of bitcoins created decreases every 4 years (every 210,000 blocks to be precise). 

 

Today, a newly created block creates 12.5 bitcoins. 

 

This number will keep going down until no more bitcoin will be issued. 

 

This will happen around 2140, when around 21 million bitcoins will have been created. 

 

After this date, no more bitcoin will be issued.

 

Miners can also receive rewards in the form of transaction fees. 

 

The winning miner can 'keep the change' on the block's transactions. 

 

As the amount of bitcoin created with each block diminishes, the transactions fees received by the miner will increase. 

 

After 2140, the winning miner will only receive transaction fees as his reward.

 

                       Fig : Image Courtesy: dev.to

 

The amount of bitcoin issued with each block is divided by 2 every 210 000 blocks. 

 

So we can calculate the maximum amount of bitcoin with some code.

 

Exemplary code:

 

// First 210 000 blocks reward

const start_reward = 50

// The reward is modified every 210000 blocks

const reward_interval = 210000

const max_btc = () => {

  // 50 BTC = 5000000000 Satoshis

  // Satoshis are the smallest denomination in bitcoin

  let current_reward = 50 * 10 ** 8

  let total_btc = 0

  while (current_reward > 0) {

    total_btc += reward_interval * current_reward

    current_reward = current_reward / 2

  }

  return total_btc

}

console.log (`The maximum amount of BTC created will be ${max_btc ()} Satoshis, or ${max_btc () / 10**8} BTC`)

// The maximum amount of BTC created will be 2100000000000000 Satoshis, or 21000000 BTC

 

So, yeah, 21 million will be probably the maximum amount of bitcoin issued in the end!