Mining is the process that allows transactions to be verified, new information to be added to the database and new coins to be released into circulation. Mining is important because it enables cryptocurrencies to function as a decentralized peer-to-peer network.
Mining performs three main functions:
- Issuance of new coins
Whereas central banks issue fiat currencies, bitcoins have to be mined. It’s a similar concept to mining for gold or anything else in that the bitcoins exist in the software but are not in circulation and so need to be ‘unearthed’. This is achieved by specialized mining nodes solving puzzles who are then rewarded with cryptocurrency.
- Transaction confirmation
A transaction is only confirmed as secure once it’s included in block inserted into the blockchain. The more confirmations, the more secure a payment is considered to be.
- Provide security
The more miners that are mining, the more secure the network is. Distributed mining power (hash rate) keeps the network secure. Hypothetically, the only way for Bitcoin transactions to be reversed is if the majority (51%) controlled the network’s mining hash rate.
Although not all cryptocurrencies use mining, Bitcoin is the most widely used example of a mineable cryptocurrency.
Mining Bitcoin Explained
Bitcoin uses a blockchain that is regulated by a network of nodes; in this context, there are two types of node:
- Nodes are computers that communicate with other nodes within the network to document and synchronize the information.
- Some of these nodes are specialist mining nodes that are responsible for taking all the new transactions and adding them into blocks to make up the blockchain.
Miners race against each other to solve complex mathematical problems. Once a miner has found the solution, they will share it with the rest of the network so that they can verify the solution and confirm the addition of the block.
Miners have to guess a number to “solve” the block. How does this actually work?
Miners must find the number, that when combined with the hash function will produce a number within a specific range.
What is a hash function?
In simple terms, a hash function is a series of algorithms that you can apply to data and produce a single ‘hash’ – (a hash is just a number). There are basic hash functions and cryptographic hash functions, the latter of which are used in blockchain.
In every bitcoin, there is a special part of the block that can be filled with a random number, also known as a nonce (“number only used once”). Each miner takes information from blocks they already know about (from the memory pool) and builds a block out of them. Once they have hashed every transaction, they are organized into pairs and hashed again to form what we call a ‘Merkle Tree’ or ‘hash tree’. This process is repeated until they have one single hash that represents all of the previous hashes; this is also referred to as the ‘root hash’. Basically, to solve the hash, the miner must, through trial and error, work out which sequence of numbers to use as the nonce.
If the output from the algorithm is smaller than the target number, then it will be considered valid and can be accepted by the rest of the network. If the hash of the block is bigger than the target number, the miner must alter the data going into the hash function until they find the correct answer.
In theory, people could also get to the correct output value by changing the transaction details existing in the blockchain, that’s why proof-of-work is necessary, and the miner must share the answer with the other nodes for them to check. Once a miner finds an answer that meets the ‘hash is smaller than target number’ rule, the miner will share the answer with the other nodes for them to verify.
The difficulty level of the puzzle is determined by the number of users and the computational power of the network. As more miners join, the difficulty level of the puzzle increases to compensate so that the rate of block creation doesn’t increase. This ensures a steady currency production; currently, the average time of a block formation is 10 minutes.
For each block successfully mined, the miner is rewarded with cryptocurrency. To ensure a steady supply, the reward amount is halving every 210,000 blocks (which roughly takes four years). As of October 2019, 18 million bitcoins out of the total 21 million have been mined.
The future of mining
Although this current mining system helps to secure the network against attacks, mining requires expensive computer hardware that consumes a considerable amount of energy. Many alternative consensus methods are being developed to try and overcome this, and some cryptocurrencies may get rid of mining altogether.
If you want to learn more about the practicalities of mining please take a look at our articles on the easiest ways to mine and the most profitable crypto to mine. Here you can find all the information you need to get you started!