In the traditional monetary system, governments print money when they need it. With Bitcoin, this is not the case, money is not printed, it is somehow discovered! In fact, some…

How does the mining work?

People trade Bitcoins through the Bitcoin network, but unless someone records all the transactions, no one would know who owes how much to whom. The Bitcoin network has solved this problem by collecting all the transactions made during a given period of time into a kind of list, which is called a block. It’s the miner’s job to confirm all these transactions and record them in a large ledger.

Let’s go to the hash

This large ledger is a long list of blocks called the blockchain. It can be searched and it is possible to see all the transactions that have been made between different Bitcoin addresses at any point in the network. As soon as a new block is created, it is added to the blockchain, which thus contains all the transactions that have taken place on the network. A constantly updated version of the created blocks is given to all those who participate.

But this large digital register must be trusted. How can we be sure that the blockchain is not tampered with or falsified? This is where the miners come in.

When a block of transactions is created, the miners must “process” it. They take the information contained in the block and apply a mathematical formula to it, turning it into something else. This something else is a smaller sequence of letters and numbers called a hash. This hash is stored in this new block which is at the end of the blockchain.

The hashing process has some interesting properties. While it is easy to produce a hash from data like that contained in a Bitcoin block, it is virtually impossible to deduce from the hash the data that was used to produce it. And while it is easy to produce a hash from a large amount of data, each hash is completely unique. If you change a single character in the Bitcoin block, its hash will change completely.

Miners don’t just use the transactions in a block to generate a hash. Other pieces of information are also used, and one of these pieces of information is actually the hash contained in the previous block.

Since the hash of each block is generated in part from the hash of the previous block, it becomes like a digital version of the “wax seal. This confirms that all blocks are legitimate, because if you tried to fake one, everyone would know.

Indeed, if you wanted to fake a transaction by changing a block that has already been recorded in the blockchain, the hash of that block would have to be changed. If someone were to check the authenticity of that block using the hash function, that person would discover that the hash is different from the one already recorded for that block in the blockchain. That block would immediately be identified as fake.

Because the hash of each block is used to produce the hash of the next block in the chain, forging one block in the chain would also influence the hash of all subsequent blocks, breaking the entire chain.

Competing for cryptos

Bitcoin mining

This is how miners “seal” a block. All miners compete against each other and the successful miner gets the block reward currently set at 12.5 BTC per block and decreasing by half every 210,000 blocks. At the current rate, this means that the block reward will drop to 6.25 BTC per block at some point in 2021.

Generating a hash from data is something very easy for a computer to do. So the Bitcoin network has to make it harder, otherwise anyone could confirm hundreds of transactions and blocks per second, and all Bitcoins could be mined in minutes. So the Bitcoin network makes it more complex by introducing the concept of “Proof of Work”.
The Bitcoin network does not accept just any hash process. It requires that the hash of the block has a specificity: that it starts with a certain number of zeros. There is no way to know what a hash will look like until it is generated. And as soon as something is added to the “mix”, the hash will not be the same at all.

Miners are not supposed to interfere with the transaction data of a block, but they must change the data they use to create a new hash. They do this by using another random piece of data called a “nonce”. This nonce is used with the transaction data to create a hash. If the hash does not match the desired format, the name is changed and the whole thing goes through the hash process again. This can take many attempts to find a nonce that works, and all miners on the network are doing the same thing at the same time. This is how miners earn their Bitcoins.