Mining Cryptocurrencies explained in 7 simple steps.

Chances are you’ve heard about mining.

Not the one that involves people mining for rocks and minerals. I’m talking about crypto mining. The process of creating new currency, and validating transactions at the same time.

Perhaps you looked for more info but it was too vague or too technical. Or you simply didn’t have the time. But if you’re like me, you want to know. What is it? How is it done?

So, here’s a guide. Crypto mining in seven simple steps. Let’s begin.

Step 1:

Peter wants to send 0,5 Bitcoins to Sally. He opens his bitcoin wallet, and initiates the transaction. He asks to send 0,5 bitcoins from his wallet, to Sally’s wallet. For example:

Step 2:

The request goes to the underlying blockchain network (in our case, bitcoin) and then it’s inserted into a pool of unconfirmed transactions. This is the place where all pending (unconfirmed) transactions go.

Step 3:

Miners from this network, pick transactions and add them to their block.

A miner, is an entity with enough processing power to complete a transaction. It can be a single person, or a pool of miners sharing resources. Miners control nodes in order to complete the transactions. Nodes are physical or virtual servers that form a network.

A block is a collection of data. In our case, a collection of unconfirmed transactions and some metadata. Miners create their own blocks, and they can all add Peter’s transaction to their blocks. Blocks have also a maximum size. In our case, a bitcoin block can hold up to 1 MegaByte (Mb) of data.

Before they add any transaction to their blocks though, they check the balance of Peter’s account to see if he has enough bitcoin in his wallet. If he does, the transaction is valid, and any miner interested can add it to their block. Miners usually pick first the transactions with the highest fees offered. When you send crypto, you add an amount you are willing to pay for the transaction to be processed. The higher the fee, the faster your transaction will be completed.

Step 4:

When their blocks are filled with unconfirmed transactions, miners will try to solve a mathematical problem. Each miner will have a different problem, but the difficulty will be the same for all miners. This is the definition of mining. Solving this mathematical problem.

WARNING: GEEK PARAGRAPHS FOLLOWING.

(Just a couple of them, but if you are not in the mood, jump to Step 5.)

This problem is actually a hash function. A function that tries to map data of arbitrary size, to data of fixed size. In our case, the miner takes the data from all of the unconfirmed transactions inside the block, and tries to output a string of numbers and letters of fixed size. Especially for bitcoin, this string must start with a specific number of zeros. At the moment, it must start with 18 zeros. This is the only way for the block to be added to the blockchain.

Miners continue to change data inside the block, until the output starts with 18 zeros. But they can’t change the transaction data. Right? Otherwise, the transactions will make no sense. Instead, they change the data of something called the nonce. The nonce is a 4-byte field inside the block that the miners can change until they achieve the desired hash output. Eventually, a miner (or group of miners) finds an input string (transaction data + the nonce) that hashes to an acceptable output string. This is how the math problem is solved, and why it requires so much computational power to solve it. It’s not a difficult problem. It’s the number of tries and combinations a computer must perform in order to reach to that number starting with 18 zeros. This process also consumes a lot of resources (like electricity, or network bandwidth if we are talking about cloud servers). That’s why miners get paid for solving the problem.

(GEEK TALK OVER. BACK TO THE STEPS)

Step 5:

The miner who solves this problem, announces the solution to the network (all other miners).

Step 6:

The other miners will now make sure the solution is valid. If the hash output (number) corresponds to the problem (the input). This is the definition of Proof of Work. The miner who solves the problem, broadcasts the solution (proof that they worked and solved it). The rest of the nodes will check the integrity of the solution and verify it’s correct. They will also make sure that all transactions inside the block are still valid. After that, consensus is reached. We only need the majority of the network (miners) to reach consensus. Not the 100% of them.

Imagine going to a bank with 1000 branches all over the world, for a bank transfer. And half of the bank’s managers (at least), from all branches, all over the world must verify andco-sign for the transaction to be valid and completed. That’s how safe a blockchain transaction is, described in banking terms.

Step 7:

The block is added to the network. Every new block added on top, serves as a confirmation that our block is valid. It also makes it more difficult for malicious parties to alter the contents of it. The miners then, go back to work and start filling their blocks with the next unconfirmed transactions.

That’s it! It wasn’t hard, was it? Mining is a pretty straightforward and secure process. In another post we will explain Proof of Stake, which unlike Proof of Work (like bitcoin) rewards your belief in the success of the coin, and not your computational skills and resources.

Be safe and profitable,

Leo.