The main purpose of Bitcoin mining is to provide security for the Bitcoin network, incentivized by a reward of new bitcoins. Bitcoin mining is a computing process that generates hash power. To attack the Bitcoin network, an attacker must generate more than 50% of the total hash power. There is not even remotely close to enough computing hardware on Earth to do that, which is what makes Bitcoin the most secure financial platform ever conceived. The speed at which Bitcoin processes transactions, or the number of transactions addded, is not related to mining, hash power, or electricity consumed – those are completely separate things, as will be explained in this article.
Bitcoin transactions are verified by the Bitcoin software, which can run on any computer, even the tiniest most power-efficient ones. Each running instance of the software is called a node in the Bitcoin network. Bitcoin nodes communicate with each other over the Internet, or by satellite or radio network or any other means of communication, for the purpose of receiving new blocks of transactions to verify, or sending new transactions to the network. Together, the nodes form a consensus on which transactions are legitimate. There are at least tens of thousands of Bitcoin nodes, all around the world. Anyone is free to download the open-source software and run a node.
The Bitcoin nodes each have their own copy of the Bitcoin ledger, known as the blockchain, which is a verifiable record of who* holds bitcoins, and how many bitcoins they each hold. Each node has a separate, independent copy of the blockchain. Each copy is identical because the nodes share the same consensus rules, so they all independently reach the same conclusion about which blocks of transactions are legitimate, and add new blocks to their local copy, in the same order.
*By "who", I mean wallet addresses; there are no names involved.
Although all Bitcoin nodes confirm blocks of transactions on the blockchain, it takes a special kind of "economic node" to create a new block of transactions: a mining node, or simply, a miner. Anyone may link their node software to mining hardware, but it is a substantial investment. Successful miners get paid transaction fees from Bitcoin users, and they get a "block reward" of newly minted bitcoins, issued automatically by the Bitcoin network.
Any computer can run the mining algorithm and compete to mine bitcoin. For the first few years of Bitcoin's existence, people used home computers and graphics cards to do so. But as competition scaled up, specialized purpose-built Bitcoin mining hardware called Application Specific Integrated Circuits (ASICs) were developed. Now, only ASICs are fast enough to have a chance at winning the competition between miners. There are numerous manufacturers of Bitcoin ASICs.
Bitcoin miners are competing with each other to find a nonce, which is a solution to a mathematical algorithm that ties a potential new block of transactions to the previous block in the blockchain, such that every new block re-verifies all previous blocks in the chain, all the way back to the first block. The difficulty of the problem that miners are racing to solve is set by the Bitcoin network (see "Difficulty Adjustment", below). The process of cryptographically tying new blocks to previous ones creates an immutable character, since to change any block in the chain, all previous blocks must also be changed – and it would have to happen faster than the rate at which new blocks are being added, since with each new block you'd have to start over. It is practically impossible to change the blockchain after new blocks have been added.
Finding the nonce, and thus creating a new block, is also the beginning of Bitcoin's consensus mechanism. The miner who finds the nonce and receives the block reward broadcasts their new block to the rest of the Bitcoin network. The rest of the nodes in the network then verify that the new block is cryptographically sound and complies with the rules encoded into their software. If a miner submits a block to the network that has different rules, the nodes will reject it, and the block will be ignored. If this happens, then the miner who issued the block will have a different blockchain than the rest of the nodes, and will never be able to spend the bitcoins they received on their copy of the blockchain, since they won't be recognized by any other nodes. This is called a fork of the blockchain.
When a new block is sent to the network and it complies with the rules, then the nodes add it to their copy of the blockchain, and await the next block. Each new block that gets verified by the network of nodes also verifies all preceding blocks in the chain. The number of times a block is verified is called the number of confirmations. The greater the number of confirmations a block of transactions has, the higher the confidence we have in its immutability. Six confirmations is considered to be a confidence level of 100%.
The Difficulty Adjustment
The difficulty of the math problem that miners work on, and thus probability of them solving it, is automatically set by the Bitcoin network, in a setting called the difficulty adjustment. The problem is like guessing a particular number in a set as large as 2^256, which is greater than the number of atoms in the universe. The size of the set, and thus the difficulty of finding the needle in the haystack, is increased or decreased based on the total hash rate of the network. The purpose of increasing or decreasing the difficulty setting is to keep the time between new blocks at about 10 minutes. If the rate of guesses (hash rate) increases, the probability of someone finding it sooner than 10 minutes increases, so Bitcoin compensates by adjusting the difficulty to make the problem harder to solve. Thus, the rate of new blocks of transactions is kept at 10 minutes per block, regardless of how much (or how little) computing power is deployed.
In order to determine what the difficulty should be set to, the Bitcoin node software infers the total hash rate of the network based on the time between the last several blocks. If new blocks are consistently found less than 10 minutes apart, probability dictates that more miners (or faster ones) are at work, and so the difficulty needs to be adjusted upward. If it consistently takes longer than 10 minutes per block, then it is inferred that less miners (or slower ones) are at work, and the difficulty is adjusted downward.
A very non-intuitive factor is at play here. Bitcoin mining can take place anywhere, and they need not communicate with each other. All miners working on the same problem statistically affects the overall outcome, and the speed of block discovery. As Gregory Trubetskoy explains,
The Secure Hash Algorithm is what is known in statistics and probability as memoryless. This is a property that is particularly counter-intuitive for us humans... Memorylessness is required for the problem to be progress-free. Progress-free means that as miners try to solve blocks iterating over nonces, each attempt is a stand-alone event and the probability of finding a solution is constant at each attempt, regardless of how much work has been done in the past. In other words at each attempt the participant is not getting any “closer” to a solution or is making no progress.
The probability of finding the solution given a specific difficulty in a given period of time is therefore determined solely by the speed at which all participants can iterate through the hashes. Not the prior history, not the data, just the hashrate.
Taking advantage of this mind-boggling probabilistic phenomenon whereby any participation affects the outcome even if in complete secrecy and without success, is what makes Satoshi’s invention so remarkably brilliant.
Transactions per Block
Blocks can contain no transactions, or thousands of transactions. Or even millions of transactions, if second layer technologies are considered. The number of transactions in a Bitcoin block depends on several factors, such as how many are waiting in the queue (called the mempool), how the miner selected transactions (e.g. those with the highest fees attached), and the size of the data the transactions consume. The maximum size allowed per block is enforced by the bitcoin nodes.
The number of transactions per block tends to increase over time, as new techniques are developed to squish more data into less space. Keeping the block size low is a very high priority, since the size of the blockchain is continually growing, and the rate of growth should not outpace affordable storage costs for the nodes, at the risk of decreasing decentralization. The current rate is around 2500 transactions per block. Although one must keep in mind that some single transactions actually represent thousands of other transactions on other layers attached to the Bitcoin base layer. So "2500" is actually the minimum number of transactions in a block, with no upper bounds on the maximum, due to second layer networks.
The nascent Lightning Network is a second layer technology that allows for an unlimited number of Bitcoin transactions per second, through a separate peer-to-peer payment network that is cryptographically tied to Bitcoin. To transact on the Lightning Network, one "deposits" bitcoin into a lightning wallet. One can do an unlimited number of instant payments with other users of the Lightning Network (i.e. retail shops), at a practically free (fractions of a penny) cost. At the user's discretion, the final bitcoin balance can be settled back to the Bitcoin blockchain in a single transaction. In this way, one transaction in a Bitcoin block can actually represent the sum total of many transactions (no limit) on layer two.
Many people believe that in the future, the Bitcoin "base layer" will mainly be used to transact in large amounts (billions of dollars worth) between exchanges or institutional entities, whereas most transactions between individual people will take place on layers built on top of the Bitcoin network, like the Lightning Network.
The miner who successfully finds the nonce that links a new block to the previous one, and thereby creates a new block, is rewarded with a block reward. This happens every 10 minutes, as new blocks are created by miners. Currently, the block reward is 12.5 bitcoins. Every 4 years, the size of the reward is cut in half. In May 2020, the block reward will become 6.25 bitcoins. So the supply of new bitcoins is continually decreasing over time. This is the opposite of government money, whose supply is constantly increasing, diluting its buying power over time.
Proof of Work
Since miners are doing actual work to find the nonce, and since the total amount of work being done is known (due to the difficulty setting at the time), the algorithm that the miners run is called Proof of Work. Every bitcoin can be traced back to its moment of creation as a block reward, so we can prove how much work was done to create it. Thus, for the first time in history, we have a digital asset that is tied to the physical world, in a mathematically provable way. This establishes a real economic cost to produce, making it a commodity.
Digital assets that do not use proof of work operate in a closed system that do not have economic impact in the real world. Video games that have their own internal virtual currency operate in this way. The game company creates virtual currency at will, and the players use it within the game. The game itself may have economic impact – marketing and sales of the game, etc. – but the virtual currency inside the game is of concern to nobody outside the game. The currency is essentially worthless, to non-players.
In contrast, the only way to create a new bitcoin is to mine it, here in the real physical world. Large scale Bitcoin mining operations form contracts with power plants (mostly hydro), build, buy, or rent warehouses, employ staff, and purchase a lot of hardware. Some miners are even building their own solar plants. Miners spend the bitcoin they earn to pay for the goods and services they need to operate, exchanging it for local currencies, if desired. This has real economic impact on people's lives, whether they participate in the Bitcoin network or not.
The mining competition makes bitcoin very difficult to acquire, which makes it scarce. Scarce money is also called hard money, because it is hard to create. It is called "mining" because it is analogous to mining gold, which is currently the hardest form of money (but Bitcoin is catching up!). Historically, harder money becomes the dominant form of money, so this bodes well for bitcoin's success as a monetary asset. See What is Bitcoin? for more on the monetary aspects of bitcoin.
Game Theory / Economic Feedback Loop
In addition to generating new bitcoin and providing unbreakable security, the mining process provides longevity to the Bitcoin network through an economic feedback loop. The more bitcoin mining taking place (the greater the hash power), the more difficult and expensive it is to attack the network, thus increasing the security of the system. The more secure the Bitcoin system, the more appealing it is as a means of storing value. This tends to increase the demand for bitcoin, especially in parts of the world where securing one's money is difficult.
An increased demand for bitcoin, coupled with its limited supply, creates upward pressure on the free-market price of bitcoin. Increased bitcoin prices provide an increased incentive for mining, since the value of the bitcoin reward is much greater than the cost of running mining hardware. As more miners compete, the security of Bitcoin increases, and thus we have a self-perpetuating financial incentive system.
Bitcoin has no shortage of vocal critics, worried that mining is "wasting energy" and contributing excessively to global warming. A pervasive and consistant error these critics make is in their assumptions about the source of electricity that bitcoin mining uses. They create a map of where they think Bitcoin mining is taking place, and then they find the average energy mix of that location, and assume bitcoin miners are using that average mix, just like the average home owners. Even otherwise high quality studies from the likes of MIT make this egregious assumption, which inevitably leads to erroneous conclusions.
A moment's consideration of the very strong economic incentive for miners – to use the cheapest possible sources of electricity – calls the average-mix assumption into question. Electricity bills are the main operating expense of bitcoin mining, so the lower its cost, the higher the profit. The lowest cost power is almost always hydro-electric power, often stranded power. Although, wind and solar sources are catching up quickly. Serious miners form service contracts with the lowest cost electricity producers.
For a detailed look at what bitcoin miners are actually using for electricity, see the reports from Coinshares, who actually do the difficult work of verifying the energy sources, rather than making absurd assumptions.
Furthermore, we show that Bitcoin mining is mainly located in global regions where there are ample supplies of renewable electricity available. And finally, we calculate a conservative estimate of the renewables penetration in the energy mix powering the Bitcoin mining network at 74.1%, making Bitcoin mining more renewables-driven than almost every other large-scale industry in the world. – The Bitcoin Mining Network, Trends, Composition, Average Creation Cost, Electricity Consumption & Sources (June, 2019)
- "Beware of Lazy Research: Let’s Talk Electricity Waste & How Bitcoin Mining Can Power A Renewable Energy Renaissance" by Christopher Bendiksen of Coinshares: https://coinshares.co.uk/insights/beware-of-lazy-research-bitcoin-mining-update
- "Bitcoin doesn’t incentivize green energy" - a criticism of Coinshare's report on Bitcoin mining, that argues 78% renewable sources should be the upper range of their estimate, at best. https://www.theblockcrypto.com/post/9559/bitcoin-doesnt-incentivize-green-energy
Another error critics commonly make is in their estimates of the amount of electricity used by miners, which they extrapolate from the hashrate by making assumptions about the power efficiency of mining hardware. They usually don't take into account that mining hardware is constantly becoming more power efficient with every new model, which is in part why the hashrate continues to grow every year.
Lastly, through their lack of understanding about the purpose of Bitcoin mining, critics falliciously devide the number of transactions per unit of time by the energy use over that time, to conclude that the energy use per transaction is rediculously high. As explained at the begining of this article and in the "Transactions per Block" section, the number of transactions is unrelated to the mining process and the electricity it uses. There could be zero transactions in a given period, or there could be millions, with the same amount of mining. With layer two transactions, there is no way to know how many transactions took place, and it could have been billions of them. Mining is providing security, not "processing transactions".
The Internet is estimated to use about 2547 TWh of electricity per year. The Bitcoin network, between 40 and 50 TWh per year. By some estimates, Bitcoin is three times more energy efficient than the traditional banking system, which it aims to replace. So the question is, what is a secure, reliable, stable, incorruptible global financial system available to everyone on Earth, worth? Parker Lewis argues:
"Any and all concerns about the amount of energy bitcoin consumes or will consume is a red-herring. It is not that we should sacrifice electricity that could otherwise power homes; instead, it’s that we will never have the electricity to power those homes if we do not have a reliable monetary system to coordinate economic activity and marshal resources. In practice, bitcoin will not practically compete for the same energy resources that fuel the basic productive and consumptive functions of our economy (not zero sum); instead, bitcoin’s function as a currency system will ensure that those very energy needs can continue to be fulfilled...
Setting aside the systemic risks that currently plague our financial system, bitcoin is a fundamentally more sound monetary system from the ground up. And, it is one secured by the production and consumption of energy. You do not have to believe that the dollar’s fate will be that of the Venezuelan bolivar to recognize the importance and interplay between the stability of a monetary function and the production of energy resources that provide basic economic necessities. And the risk inherent in even the possibility of hyperinflation is so negatively asymmetric that the price of bitcoin energy consumption is of small relative cost." – Bitcoin Does Not Waste Energy
Energy vs Electricity
Another issue to get clear on is the difference between energy and electricity. People talk about energy like it is a scarce resource, but energy is actually a fundamental, ubiquitous force in the universe. It is perhaps the least scarce thing in existence. Modern civilization runs on various forms of energy, such as heat, light, oil for transportation, and electrical energy. The energy use of a country involves all of these forms, whereas bitcoin mining uses only generated electrical energy (and actually produces heat energy). So it is absurd to compare the "energy use" of a country with that of Bitcoin, to assess overall environmental impact, as many studies do. A more sensical comparison would be to the electricity used by Christmas lights in the USA. Although, a reliable global monetary system provides way more value than Christmas.
Electricity can be generated in many ways. Power producers sell electricity to those who want to buy it. There is nothing compelling them to sell to commercial buyers like bitcoin miners. They, and the communities in which they operate and employ people, receive economic benefit from selling electricity to miners. If bitcoin miners are willing to pay for electricity, that means they are finding enough value in the activity to merit the expense. If miners are not actually contributing value to society, their costs will outweigh their profits, and they will go out of business. This is how free markets work, and how value-producing goods and services make their way into our societies, or fail to.
Societies are striving to generate electricity in cleaner ways than burning fossil fuels, and hopefully we manage to transition to clean, renewable sources quickly. As our civilization grows, demand for electricity will continue to grow as well, regardless of Bitcoin's success or failure. Bitcoin only adds to the already large incentive for society to modernize its electrical grids and develop cleaner means of electricity generation.