# How it works The Bitcoin mining in relation to the blockchain?

Let’s think about the miners as computers or devices, which is what they really are, and leave the analogy of the “pick and shovel” to one side.

The confidence that gives value to the network that cements Bitcoin is based on the computational power provided by the nodes that comprise it.

Transactions are packaged in blocks, which require a lot of this power to be verified and very little to verify that indeed have been verified.

This is basically what is known as the mining and has two purposes: to

ensure the Bitcoin Bitcoin network ensuring that transactions are legitimate and are verified.
Generate new bitcoins as a reward for each block that is mine to ensure the network.
A good analogy to understand this is to imagine the mined as if it were a competition to see who can solve a puzzle that has tens of thousands of rows and columns, with millions of pieces, that melts and changes completely when someone solves it, something that happens every 10 minutes on average. If I taught you the puzzle already done, return to the remake is easy, but if not, it is a complicated task. Even for a powerful computer.

This example illustrates the problem faced by devices connected to the network to the minar, a process that is essentially two things:

Grouping transactions into blocks and send them to the rest of the nodes of the network.
Inspect the blocks to verify that all transactions within them are legitimate.
For a block to be added to the string, it is necessary to carry out a process known as hasheo or hashing.

A hash is a piece of code with a certain length resulting from the application of a mathematical algorithm to something, such as a word or code fragment.

If any letter of that word or set of words changes, the hash would do, in such a way that each hash will be unique.

No matter the length of what we want to convert to a hash as it will always be the same length and the difficulty to decrypt it is determined by the type of algorithm to apply.

For example, if we apply a special function developed by the NSA, called “Secure Hash Algorithm (SHA-256”, the same as used Bitcoin) to encode these three elements, give us these hashes as a result:

– The blockchain technology is: 7ad3f33c8d27585a66e80ba9cda9a73c5facc2255f556163c9a60c36b1bbee01

– The Milk: 44d1ce60431ee647623e670513cea2fd84fcc89830922d6b5f9f0554d10a2a5b

– The Blockchain technology is the milk: 909479bd040e7ca681d967ceef7f1fc000329d113aeb96a54b506b8b27ac644e

the first job you should do a node to the minar is to create blocks, something that requires a lot of work and that involves doing several things at once:

Group a set of transactions and create a hash that represents you.
Number the block.
Create a temporary seal.
Create a hash containing information about the last block undermined, that is to say, the immediately preceding the mine.
Create a random variable called nonce (We Can understand a nonce as a word created to describe something and that can only be used once).
Each time you create a block, you are given a unique hash so that when the nonce changes, the hash of the block also changes.

Therefore, the problem they have to solve the miners with the nonce is that they have to find out a certain type of hash for each block must contain the correct number of zeros at the beginning. To do this, the device to undermine what it does is release repeatedly and randomly nonces until it gives with the correct hash of that block.

The more computational power inputs, the quicker you can try with new nonces and more quickly you will be able to find the solution to the block and take the reward in Bitcoins.

This is the hash of a block Bitcoin:

000000000018d6425c085ae165831e934ff763ae46a2a6c172b3f1b60a8ec26f

Once your device has created a hash that lace, the “Solution of the problem,” also known as “Proof” or proof of work which is how you know this process, it relays the message to the rest of the network and here is when it starts to play his second work: when it is proposed that the solution to a new block, the rest of devices inspected in order to “agree” that is indeed correct.