bitcoin mining explained

Bitcoin mining explained

Video transcription below

Introduction

What comes to your head when you hear the word mining? If you’re not familiar with the cryptocurrencies yet, I’m sure you imagine people going to mining caves with their pickaxes, wearing individual protection equipment and very often all covered in dust.

Surprisingly enough, a bitcoin miner is not that much different from that, except… there are no caves, or pickaxes, there is no need to wear any PPE and they are very often not covered in dust.But then, what are the similarities? How does bitcoin mining really work? And why miners are a key point on a proof of work cryptocurrency like bitcoin?

That is just what we’ll be discussing in this video. So, make sure to like and subscribe, and don’t forget to turn on that bell notification so you don’t miss out on any new video from the Crypto Odyssey. And if you’re real fan, join our telegram group and follow us on Instagram, links in the description.

But before we start, if you haven’t done it yet, I strongly recommend you watch our What is Bitcoin video before this one, I promise it will make the content on this one much easier to digest, link is in the description.

The similarities of a gold miner and a bitcoin miner

Now, back to the miner analogy. The similarities of a gold miner and a bitcoin miner are that, while the gold miner finds new gold nuggets that did not exist in the market before, bitcoin miners do the same creating bitcoin that did not exist before.

While the first one uses a set of mining tools, like the pickaxes, the second uses a variety of computer hardware to mine.

And just like for a gold miner, that can use sophisticated machinery to speed up the gold mining process, bitcoin miners can use computer chips called application-specific integrated circuits, or ASICs, for short. And higher-level processing units, such as graphics processing units, the famous GPUs, to get more rewards. In both cases, these elaborate mining equipments are called, wait for it, “mining equipment”.

And finally, while a gold miner must work hard, breaking rocks, filtering dirt, exploring, to find gold nuggets. A bitcoin miners must validate transactions made in the network by solving a mathematical problem that is so hard to solve that it can’t be calculated, but only guessed, and so, the miner’s computer has to work hard to find that solution getting the right to write a new block of transactions to the blockchain, and by doing so, the miner gets rewarded in bitcoins.

Noticed that I said that both need to work hard to get their rewards? Well, that’s why Bitcoin is called a Proof of Work cryptocurrency. Actually this only explains the “Work” part of it, but not the “Proof of” part of it. But we’ll get to that.

But how is Bitcoin mined?

Right, this analogy helps a bit, but it is very superficial and doesn’t tell anything about how bitcoin is actually mined. So, let’s dig deeper into that.

To understand how Bitcoin mining really works, first it’s necessary to understand how the cryptography algorithm used by the cryptocurrency works and then how the blockchain works, let’s start with the algorithm.

Bitcoin’s cryptography algorithm

The algorithm in question is known as SHA-256. Which is designed to always output a 256-bit number, which is usually represented in a 64-digit hexadecimal number This is also referred to as a hash, or hash number.

It works like this, whatever input that is given to the algorithm, it will always return a 64-digit hexadecimal number, a hash number. Doesn’t matter how long the input is, it can be a number, a text, or even a single letter. The output will always have 64 digits. And not only that, but it will also be unique. In a way that 2 different inputs can never, I said never, result in the same output. Even the slightest difference on the input will generate a completely different output, and that is crucial for the blockchain to work.

Here is an example, this is a SHA-256 hash calculator, notice that when I write in the input data: “Subscribe to the Crypto Odyssey channel” a hash number is generated, that 64 digits hexadecimal number I just mentioned. Now watch what happens when I add a dot at the end of the sentence. The hash number is now completely different from the previous one. I’ll leave a link for this calculator in the video description, so you can have a play for yourself.

You might have noticed that the hash number is composed not only by numbers, but also letters of the alphabet. And the reason is that it is in a hexadecimal system, where each digit has 16 possibilities, opposed to our numeric system where there are only 10 ways of representing numbers (zero through nine). That’s why we see those letters, specifically letters a, b, c, d, e, and f.

Let’s breathe a little

Ok, let’s breathe a little. Now you know that bitcoin miners are rewarded in bitcoin every time they add a new block to the blockchain by validating transactions in the network.

And that every transaction has a hash number.

And that hash numbers are a result of a cryptography algorithm that always outputs a 256-bit number that is always unique, and that the slightest change on the input will generate a totally new number.

Now let’s understand a bit more about the blockchain and what happens when a new transaction is made.

Blocks in the blockchain

Not all cryptocurrencies use this same blockchain system. And speaking of altcoins, a great way to exchange crypto to crypto is using Coinvertlly. Coinvertlly is a non-custodial crypto exchange, meaning you control your keys, where you can easily swap your coins for other coins without having to create an account or register anything, the process if fully anonymous. All you got to do is visit Coinvertlly.com, select the coin you are swapping from, the amount you want to exchange and, the coin you want to get in return. Then, just follow the on-screen instructions, where you’ll be asked to add the destination address, that is the wallet where you want your new coins to be sent to. Coinvertlly will then generate a unique deposit address, where you’ll send the coins you’re swapping from and in a couple of minutes, you’ll get your new coins sent to your destination wallet. Coinvertlly also offers the possibility to buy and sell crypto using your credit card or even Global Bank Transfer (SEPA or SWIFT). Visit Coinvertlly.com today and start trading!

Alright, now back to the blockchain. In Bitcoin, each block can store 1MB of data and they are composed by mainly 2 things, transactions, in the form of a merkle tree, and the block header. Let’s start with the merkle tree.

The Merkle Tree

A merkle tree works like a genetic hierarchy tree. While you are a combination of your father’s gens, with your mother’s gens, and your father and mother are a result of a mix of your grandparents’ gens. The merkle tree is no different, but instead of DNA material, we have hash numbers.

Here is an example. A total of 4 new transactions were made in the network, and each one of them were hashed, generating their own unique hash numbers. Actually they are hashed twice, we hash the hash, as a security measure.

This hash numbers are combined 2 by 2 and hashed again, generating a new hash number that can represent the 2 original ones. Please note, hash numbers are only child, they cannot have a sibling. This process is repeated until we have 1 single hash number that can represent all the transactions that made it. That last hash number is called the Merkle Root. With it, all transaction in a block can be validated without having to look into each individual transaction.

The block header

The block header is a summary of the contents in the block itself. It contains the following six components:

  • The version of software the Bitcoin client is running
  • The timestamp of the block
  • The Merkle Root
  • The hash of the block before it
  • A nonce
  • The target

Remember that the Merkel Root serves as a valid summary of every transaction in the block, without having to look at every transaction.

The hash value of the previous block allows the network to correctly place the blocks in chronological order. This is where the term blockchain comes from, each block is linked to the previous block.

Nonce and target are the key to mining. They are the basis for solving the SHA-256 problem that miners need to solve.

From all the 6 components of the block header, the nonce is the only one unknown to the miner when he first finds the new block. Nonce is a blend word for “number used once”, and is the number miners need to guess to solve that mathematical problem. More into that in a bit.

Let’s first understand what the target is.

The target number in a bitcoin block

The target stored in the block header is just a number stored in bits that ranges between 0 and 2 to the power of 224, a number greater than 67 digits.

The goal of the miner is to get the head of the block, add a random number to it, the nonce, and hash it twice. The value of the resulting hash must be less than or equal to the target value. That’s right, the miner does not need to guess the exact number, but one that will result in a hash smaller or equal to the target. It sounds easy when said, but it’s a very hard process to do.

The nonce

Now let’s understand what the nonce is. here is how it’s used: the miner adds a number, starting from 0, to the nonce in the block header, and double-hashes the block header information. If the resulting hash value is not less than the target value, the miner adds 1 to the nonce, adds it to the block header again, and hashes the changed value. This process is repeated until the miner finds a hash value that is less than or equal to the target value.

To have a better idea of how hard and time consuming this process is, the nonce for the Genesis block, the first block ever created in the blockchain, is 2,083,236,893. This means Satoshi Nakomoto’s computer went through this process over 2 billion times before it was able to find a hash that could solve the mathematical problem.

I guess this makes it clear why miners are always trying to get the best mining equipment they possibly can, as only the first miner to find the nonce that solves the puzzle gets to write the block in the blockchain and is rewarded for it.

Miners’ Rewards

Alright, so miners get bitcoin by adding new blocks to the blockchain, and that is done by validating transactions in the network. But how much do they get exactly?

First, you need to comprehend that the reward is not paid by anyone. The reward comes from Bitcoin being created out of thin air. That’s how Satoshi Nakamoto wrote Bitcoin’s code to be like, with a limit of 21,000,000 bitcoins. Meaning, once all bitcoin has been mined, this Bitcoin out of thin air thing, will no longer exist.

There is a mechanism called Halving, that slows down this process, cutting the reward in half roughly every four years. And I say roughly because it depends on the mining speed, or hashrate of the network. This means, at every halving event Bitcoin becomes scarcer, and its price tends to go up. So, although miners make less in bitcoin, they still have the incentive to continue mining as Bitcoin worth more.

At the beginning, miners would get 50 BTC per block. On November 28, 2012, that reward was cut in half, that was the first halving, going to 25 BTC per block. The second halving happened on July 9, 2016, where the reward went down to 12.5 BTC per block. The third one on May 11, 2020, cutting the reward down to 6.25. The fourth halving event is believed to happened somewhere in early 2024, when the reward will be cut in half again, to 3.125 BTC per block mined.

And to keep it short, miner will always have an incentive, even after all Bitcoin has been mined, which is believed to happen somewhere in the year 2140. To understand that better, I’ll leave a link in the description that will tell you more about Transaction fees vs Mining Reward.

Proof of Work

In the beginning of the video, I mentioned Bitcoin uses proof of work to function, and we can see clearly now that it takes a lot of work to find a valid nonce. But what about the proof part of it?

When the nonce is found, the miner publishes the block to any node connected to the blockchain, aka another miner. This node does not trust the miner, so it needs to validate the information. It simply takes the block header, double-hash it and checks if the final hash value is lower than the target value included in the block. Once the block is deemed valid, the new node will continue to propagate this block across the network until every node has an up-to-date ledger.

And there we have it, the proof that the miner really worked to guess a valid nonce.

Wrap up

Now you know what the similarities of a bitcoin and a gold miner are.

Why Bitcoin is called a proof of work crypto, and how this process works.

The importance of miners in the blockchain system.

What a block is really made of.

What halving is all about.

And how mining bitcoin is really done.

Many other topics were mentioned in the video that we barely touched their surface. If you want to get into more details on those, please check the list of related videos we left on the description. And feel free to comment on anything you wish to see here in the Crypto Odyssey.

If you liked the video, don’t forget to let us know by hitting that like button and sharing your thought on the comments down below. And if this video was helpful to you, it will certainly be helpful to your fellow ones, share the video and spread the word! See you next time!

Continue reading

Comments