When it comes to traditional money, as soon as the government of the country needs money, it prints more money. As simple as that, ideally, money shall be backed up by some assets, like gold, silver, etc., but it is not always the case. Though we know that money and trust it.
The story is different with cryptocurrencies. Here, the money is discovered, or mined. The mining is performed by computers located all around the world.
Users are sending cryptocoins, say, bitcoins, as they are the most popular among cryptocurrencies, every time over blockchain. though who ever would keep the record of those transactions?
The blockchain collets all transactions performed within some period of time in a set which is called block. Then, it is turn to work for a miner. Miners have to verify and confirm those transactions, as well as note them in the system, the ledger.
How to Make a Hash
This ledger, or the blockchain, is a list of such blocks with information about transactions. There, in the blockchain, you can see every transaction that has ever been made. When a new block with information is generated, it will be integrated in the blockchain, and the length of transactions list will grow. The blockchain gets updated and the recent copy is downloaded to each user computer.
Though, how to be sure that the transaction lists will stay unaltered and the blockchain continues functioning?
There is, when mines came in game.
When there is a new block, it is not just added to the blockchain. First, miners apply on the information from the block a mathematical formula, which turns it into something different. This something is much shorter than the transaction string, and looks like just a random combination of digits and letters. This something is called hash. And this is what will be stored in the blockchain, at the end of it, until the next block of information doesn’t come.
It is very easy to produce a hash from the available data. Though if one wants to find out the data from the hash, then it appears practically impossible. Each hash is unique. If one character changes, the entire information set changes, as well.
Mines though use not transactions for cash generating but different pieces of data. Then, the last piece of data is stored in the last blockchain.
The next block is built on the base of information stored in all previous blocks. Hence, changing or overwriting something in blockchain is impossible, because then, you would have to overwrite the entire system. But as soon as you alter data, everybody will see and know it, as the blockchain is available for all users.
Everybody can run hashing function to check the block. Now, for a while, imagine that you have tried to fake a transaction. Then, the hash would change. Then, it will become different from the one that is stored in the blockchain. and of course, such block would be spotted as a fake one.
One hash is used for producing the next hash in the chain. Then, if you try to fake one hash, all subsequent hashes would change as well. That would cause a downtime of the entire chain.
Like this, miners seal each block and it cannot be changed anymore.
Competing for Coins Exists
All miners compete for sealing blocks. They use special commercial software to do so. The rewards for that are high. Each time when somebody creates a hash, the blockchain updates it in its system, and everyone is notified about it. The miner who confirmed the transaction gets a reward. Now it is 25 bitcoins, but the system is arranged so, that, the more bitcoins are mined, the lower the rewards are. With time, miners will get zero bitcoins for every transaction confirmation.
It is very simple to produce a hash from the data string. That is why there should be imposed some limitations, otherwise, all will be creating hashes. In such circumstances, all bitcoins would be mined within some minutes. That is why, the process has been complicated deliberately, with so-called “proof of work”. Any hash is not accepted by the blockchain. the hash has to have a certain structure. No one can predict how the hash would look before it is produced. If a new number or a sign included, then it will be a completely different hash.
Miners do not have to do much about the transactions but they change the data to create new hashes. For that, they use a “nonce”, another random piece of data. If that doesn’t fit, then, the nonce is changed and the miner has to hash the string again. To find out which nonce works may take much time and many efforts, and moreover, there is not only miner working on that. All miners are trying to hash it. Whoever manages to do it first, gets the reward.