The process of minting new bitcoins is in some ways similar to the process of extracting precious metals from the earth. For this reason, it has come to be known as 'Bitcoin mining.'
As stated in the Bitcoin white paper:
The steady addition of a constant amount of new coins is analogous to gold miners expending resources to add gold to circulation. In our case, it is CPU time and electricity that is expended.
A simplified overview of bitcoin mining is as follows:
Bitcoin mining is an essential component of the network's system for arriving at consensus as to the current state of the ledger. It is central to enabling people to securely make Bitcoin transactions.
The Bitcoin network is a globally distributed public ledger consisting of a giant list of timestamped transactions. For example, one ledger entry might indicate that Person A sent 1 bitcoin to Person B at 10am on Monday. The ledger is updated approximately every 10 minutes by adding 'blocks' that contain a list of new transactions. The existence of the ledger, which is voluntarily stored by thousands of participants known as 'nodes,' allows anyone to see both the current state and complete history of bitcoin ownership.
By design, there is no centralized authority deciding which transactions should be added to new blocks. Instead, the state of the ledger (ie. the 'truth') is arrived at collectively and through coordination by nodes in accordance with the Bitcoin protocol. This decentralization is what gives Bitcoin some of it's most interesting properties - namely, censorship-resistance and permissionless-ness.
Most nodes simply validate the authenticity of transactions, store the ledger, and pass on updates to other nodes (again, updates take the form of new blocks added to the chain). However, a smaller group of nodes, called miners, compete to create new blocks. When miners create new blocks, they are effectively updating the state of ledger, or the 'truth' about who owns what.
Bitcoin mining serves several functions:
Proof-of-Work mining helps to secure the Bitcoin network by requiring potential attackers to commit more resources to an attack than they could hope to gain from the attack itself. In other words, it ensures that attacking Bitcoin is a money-losing (and very costly) prospect, making it exceedingly unlikely to occur.
The process is summarized in the Bitcoin white paper:
Let's break that down into a little more detail.
To begin, miners are the ones who propose updates to the ledger and only miners who have successfully completed the Proof of Work are permitted to add a new block. This is coded into the Bitcoin protocol.
Miners are free to select valid transactions from a pool of potential transactions that are broadcast to the network by nodes. Such transactions are collected into the 'mempool.' Rational and honest miners select transactions from the mempool based on the fees attached to them, optimizing for higher fees. This gives rise to the fee market which helps to ensure the limited block space is used fairly and efficiently.
The first miner to complete the Proof of Work broadcasts her proposed new block to the wider network of nodes who then check to ensure that the block follows the rules of the protocol. The key rules here are (1) all transactions in the block are valid (ie. there are no double spends), and (2) the new block appropriately references the previous block and is numbered as the next in the chain (ie. the new block constitutes the latest block in the longest chain). If it does, nodes send it on to other nodes who complete the same process. In this way, the new block propagates across the network until it is widely accepted as the 'truth.'
However, it can (and regularly does) happen that more than one miner completes the Proof of Work at almost the same time and simultaneously broadcasts his new block out to the network. Moreover, due to network delays and geographic separation, nodes may receive new proposed blocks at slightly different times.
Note that one miner's new proposed block could be slightly different from another's. This is because, as mentioned, miners are the ones who choose which transactions to include in a block - and even though they the tend to optimize for profitibility, location and other factors introduce variation. When two miners send out different new blocks, competing versions of the 'truth' begin to propagate across the network. The network ultimately converges on the 'correct' version of the truth by selecting the chain that grows longer faster.
Let's break down that last part. Imagine there are two competing chains. Let's say 75% of miners select version A (because it was the first version they saw) and begin their Proof of Work for the next block, building on top of version A. The other 25% of miners select version B (again, because that's the version they happened to come across first) and initiate the same process building on top of that version. Statistically, one of the miners working on version A is likely to complete the Proof of Work first, broadcasting the new version out to the network. Since nodes always select for the longest chain, version A will quickly come to dominate the network. In fact, the probability that version B will grow faster vanishes exponentially with each additional block such that by the time six blocks have been added, it's a statistical impossibility. For this reason, a transaction that has been confirmed in six blocks is considered set in stone. Note that a block which doesn't end up becoming part of the longest chain (version B in our example above) is known as an orphan block. It is estimated that such blocks are created between 1 and 3 times per day. Transactions that are included in an orphan block are not lost. If they weren't already included in the version that ends up being the longest chain, they'll end up being added to the next block of the longest chain.
Bitcoin uses a military-grade encryption algorithm called Secure Hash Algorithm 2 (SHA2). Bitcoin miners are awarded BTC when they find a random number that can only be generated by running the hashing algorithm over and over again. This process is analagous to a lottery (where buying more tickets increases your chances of winning). By dedicating more computing power to the hashing algorithm, miners are effectively buying more lottery tickets.
The difficulty level for the Proof of Work algorithm is automatically adjusted every 2,016 blocks, or roughly every 2 weeks. Adjustments are made with the goal of keeping the mining of new blocks constant at 10 minutes per block.
The difficiulty adjustment factors in the total volume of computing power, or 'hashpower,' being applied to the hashing algorithm. As computing power is added, the difficulty is increased, making mining more difficult for everyone. If computing power is removed, difficulty is reduced, making mining easier.
Note that the difficult adjustment system makes Bitcoin mining quite different from the mining of precious metals. If, for example, the price of gold rises, more miners are enticed to join the market. The addition of more gold miners will inevitably result in more gold produced. By forces of supply and demand, this will eventually lower the market price of gold. In Bitcoin's case, however, the volume of bitcoin produced (minted) is predetermined by the Bitcoin protocol (ie. not affected by the number and power of miners) so no matter how much mining power is directed towards the algorithm, the volume of Bitcoin produced will not be affected.
Bitcoin mining is legal in most regions, including the US, Europe, and China.
Bitcoin mining is a highly competitive industry with narrow profit margins. The primary input is electricity, although significant upfront investments in hardware and facilities for housing the hardware are also required. The key hardware involved is known the Application Specific Integrated Circuit (ASIC), which is a computing device specialized for running the Bitcoin hashing algorithm exclusively. Profitably relies mainly on consistent access to low-cost electricity applied to the most efficient ASIC hardware.
Bitcoin mining is a naturally equilibrating system. As the price of bitcoin rises, miner margins expand. This entices more miners to join the market. However, new entrants cause the difficulty of minting new blocks to increase. This requires all participants to expend more resources, thereby reducing profitability across the board. Sustained downturns in the price of bitcoin have historically resulted in a portion of miners quitting due to costs exceeding revenue.
In most cases, miners sell their earned bitcoins to cover the costs associated with mining. These costs, then, contribute to the net sell pressure. Miner's attempts to maximize profitibilty by holding or selling Bitcoin based on market momentum may have an impact on Bitcoin's price volatility. Here, the argument is that when the price of Bitcoin is rising, miners may attempt to hold longer in the hopes that they can extract more profit. This would result in less net sell pressure, leading to a faster rise in the price. When the price of Bitcoin is falling, however, miners are likely to sell not only their reserves, but also newly acquired bitcoin. This, in turn, would contribute to volatility on the downside.