How Bitcoin Mining Works?

When you hear about "mining" bitcoin, you imagine a coin dug out of the ground. But bitcoin isn't physical, so why do we call it mining?

Because it is similar to gold mining where bitcoin is in the protocol design (just as gold is underground), but bitcoin has not been brought out to light (just as gold has not been excavated). The bitcoin protocol stipulates that 21 million bitcoins will exist at some point. What "miners" do is take them out into the light, several by one.

They can do this as a reward for blocking validated transactions and including them in the blockchain.


Step back a bit, let's talk about "nodes." Node is a powerful computer that runs bitcoin software and helps keep bitcoin running by participating in delivering information. Anyone can run a node, you can simply download the bitcoin software (free) and leave certain ports open (the drawback is that it consumes energy and storage space - the network at the time of writing takes about 145GB). Nodes spread bitcoin transactions across the network. One node will send information to several nodes it knows, who will deliver information to the nodes they know, etc. That way it finally spread to the entire network quite quickly.

Some nodes are mining nodes (usually called "miners"). This group makes extraordinary transactions into blocks and adds them to the blockchain. how do they do this? By solving complicated math puzzles that are part of the bitcoin program, and include the answers in the block. The puzzle that needs to be solved is finding numbers that, when combined with data blocked and passing a hash function, produce results that are within a certain range. This is far more difficult than it sounds.

(For trivia lovers, this number is called "nonce", which is a combination of "numbers used once." In the case of bitcoin, nonce is an integer between 0 and 4,294,967,296.)

Solve puzzles

How did they find this number? By guessing randomly. The hash function makes it impossible to predict what will be produced. So, the miner guesses the mystery number and applies the hash function to the predicted number combination and the data is blocked. The resulting hash must begin with a predetermined zero. There is no way to find out which number will work, because two consecutive integers will give very varied results. What's more, there may be some nonces that produce the desired results, or maybe they don't exist (in this case the miner keeps trying, but with a different block configuration).

The first miner to get the hash in the desired range announces its victory across the network. All other miners immediately stop working on the block and start trying to find out the mystery number for the next one. As a reward for his work, the winning miner gets a new bitcoin.


At the time of writing, the prize is 12.5 bitcoin, which at the time of writing is worth nearly $ 200,000.

Even though it's not as easy as an agreement as it sounds. There are many mining nodes competing for the prize, and this is a matter of luck and computing power (the more guesses you can do, the more lucky you are).

In addition, the cost of being a mining node is quite large, not only because the hardware is needed (if you have a processor faster than your competitors, you have a better chance of finding the correct number before they do), but also because of a large amount of electricity who runs this processor consumes.

And, the number of bitcoins given as prizes for solving puzzles will decrease. Now it's 12.5, but it will decrease every four years or more (the next one is expected from 2020-21). The value of bitcoin relative to the cost of electricity and hardware can rise over the next few years to compensate for some of this reduction, but that is uncertain.


Calculation difficulties (the number of zeros needed at the beginning of the hash string) are often adjusted, so it takes an average of about 10 minutes to process the block.

Why 10 minutes? That is the amount of time that the bitcoin developer thinks is needed for a steady stream of new coins and decreases to a maximum of 21 million (estimated to be some time in 2140).

If you're so far, then congratulations! There is still a lot to explain about the system, but at least now you have an idea of ​​the outline of programming genius and concepts. For the first time we have a system that allows convenient digital transfers in a way that is decentralized, trust-free, and anti-destructive. The impact can be very large.
Powered by Blogger