Mining is one of the most misunderstood things in cryptocurrencies, as most people believe mining is how bitcoins, for example, are created. This is partially incorrect.
What is mining?
Mining is the process of how consensus is created.
Consensus is the agreement about how much money is tied to a private key. Basically, how much money is in each person’s account? In a centralized system as we have with fiat money (a national currency usually issued by a country’s government or central bank, e.g. the U.S. dollar), a central institution such as banks watch over how much money we have and whether we can actually pay for something or not. In decentralized systems, it works by every participant watching everyone else and then either confirming or rejecting a transaction based on whether we have the money or not.
What are users, nodes and minders?
Users: Most of the people in a decentralized network are users (like you and me). They make and receive payments and have to pay miners a small fee (this fee can also be zero sometimes) for them to check the validity of their transactions.
Full-nodes: Nodes forward information they receive to everyone else, for them to also have the same information, and for the network to stay decentralized.
Miners: Miners check and verify transactions that users want to make. They create consensus.
In theory, anyone can do all three things: mine (check transactions), forward info to others (full-node) and use the system (user). However, these roles are way more specialized. Most people using crypto join as a user to send and receive money. They leave it to others (miners) to make sure the transactions are correct and that full-nodes forward the transactions within the network so that everyone has the same information on what the transaction history (blockchain) looks like. Full-nodes are set up as check points and are not really participating in actual transactions. What results is, instead of one central institution, a large group of people creating consensus.
What is consensus?
Consensus is agreement over what has and what hasn’t happened.
How does this work in a decentralized system as chances are, the more participants (miners) there are, the more disagreement there is? Blockchain technologies have a very sophisticated solution to creating consensus. As soon as you decide to make a payment to someone, you have to use your private key to “sign” this transaction. This basically means that you send money from one public address to another. Since only you (hopefully) have the private key associated with the public address, it is only you who can send these coins and no one else. Since there is no central authority watching, you have to broadcast this transaction to a few full-nodes that your wallet is connected to – your wallet does that automatically. Then, these nodes forward this information to other nodes and miners, who do the same thing. This is an exponential wave that happens within a few milliseconds, and soon everyone who is part of the community knows about your transaction.
Whenever a miner receives a transaction, they check whether the transaction was actually correctly signed with the private key and that you had the coins in the first place. Since there are several transactions every second, you can “bribe” the miners to pick and “check” your transaction first, by paying a small fee. In theory, you don’t have to pay any fees, but since there are so many transactions happening at the same time, miners would never start to process your transaction to include it into the blockchain (transaction history), as they earn more by processing those transactions that give them a fee. Every legit cryptocurrency has a set of cryptographic rules that make sure that miners cannot make up fake stuff. For example, they cannot just create fake transactions like crediting themselves with millions of dollars.
So, how is it decided which miner gets your fee, since only one miner receives it? Also, what if you tried a double-spending attack by broadcasting one transaction to one miner and a different transaction with the same money to another? Which transaction is valid, and which one is not? Even though there is a democratic system among the miners, if anyone just gets to vote on the transactions as they wish, it is going to be quite disorderly.
What is a consensus algorithm?
In order to avoid all this mayhem, legit cryptocurrencies have developed consensus mechanisms that govern the above problems in a decentralized system:
- Conflict of opposing information – one miner saying one thing and another saying something else.
- Possibility of creating fake miners who work in your interest and allow you to cheat.
- Incentive mechanisms to motivate as many people in the system to participate in the consensus and not only participating as a user.
While there are many more consensus algorithms in the making and they might be labeled differently in different cryptocurrencies, these are the three most important ones:
Proof of Importance
This is one of the least used so far. It might be adopted more in the coming years, but so far Proof of Work has mostly been used. With a Proof of Importance consensus algorithm, the participant with the “most importance” gets to say which transactions happen and also receives incentives the most often. Since the person will not be the only participant with importance, it is a probabilistic mix of when they have authority and when someone else does. How does importance get established? Different cryptocurrencies have different mechanisms for that, but one factor is the length of time someone is part of the system, combined with the number of other miners trusting them by opting in to receive information from them.
Compare it to social media. You are more likely to trust the friend request of someone on Facebook that has been on there for quite some time already, has a legit looking profile, and many of your friends are already connected to this new friend. It is similar in the world of decentralization when Proof of Importance is used. Someone’s importance percentage is based on the value the system decides, which assigns how much “voting power” they have, how often they get to go first with transaction processing, and how often they are rewarded. The upside of this system is that literally anyone, poor or rich, can achieve a high level of importance. The downside is that this system could be gamed by simply creating fraudulent participants who then vote for each other, thereby creating importance. See it like a fake social media account that people start to follow only because many others are following it. Few blockchain algorithms are using this mechanism for this reason, and it probably still needs some additional features to scale well.
Proof of Stake
The idea of importance can be taken a step further, where money resembles importance. Basically, whoever controls more money in the system has more importance. As you might already imagine, this system has a lot of critics, as it begs the question of how such a network could be decentralized, if only some rich accounts share all the consensus power. So far, only a few blockchains are using this consensus mechanism, but for those that do, it seems to be working well. The risk of one large player ruling it all is eminent, but the advantages of this system are on the table:
- The mechanism of understanding how much voting power you have is clear by simply dividing the amount of money you stake (proof of your money by locking it in a special contract for a given period of time), with the total amount staked by the community. So, there is the possibility that while someone might have a lot of money, they may still not have much voting rights because they are spending it on a regular basis and not staking it as proof of his ownership. The math is clear and simple. If you were to stake 1,000 coins, for example, and 100,000 coins are being staked in total, you have 1% voting power and are expected to get 1% of the say and 1% of the rewards.
- Since the rewards of the transaction system get shared with the stakers, whoever puts up more will get a larger percentage of the rewards. Therefore, you can calculate a much more accurate return on your money on an annual basis, which might be an interesting investment opportunity. For example, you know that a blockchain might reward you with 5% of your staked up capital per year. You stake 1,000 coins and receive 50 coins every year for taking part in the consensus algorithm. Depending on what these coins are worth, this can mean a lot.
- Since money cannot be created out of thin air in a legit blockchain, the possibility of fraudulent attackers, as in proof of importance, is extremely low.
Of course, there are also downsides. One of them, besides the rich getting richer, is the risk of forking attacks. In proof of stake, if a blockchain forks (splits), you automatically control the coins on both new chains. You just doubled your coins that you can keep staking on either. Developers are still looking for good solutions in that regard. This is different than proof of work, as here you have to make a decision on which chain you invest your work into.
Proof of Work
The last of the three consensus algorithms is the most used and oldest of them all. Most of the large cryptocurrencies use it because it has been tested extensively over the past decade, and it is the most resistant to the aforementioned forking attacks. Instead of proving your importance or staking money, you have to prove that you have done work. Whoever does the work first gets to be the first to choose the transaction composition and also gets the mining reward. This reward consists of all the transaction fees of that time frame (block) and, depending on the cryptocurrency, an additional incentive. For example, Bitcoin’s incentive is 6.25 bitcoins per block (time frame).
