On the Bitcoin blockchain, mining allows transactions to be recorded to the blockchain in a verifiable way and also enables the minting of new bitcoins.
The purpose of a blockchain is to record data in a decentralized way, with distributed computers each verifying that a transaction is legitimate. Every 10 minutes, a new block is created. Miners then take a batch of unconfirmed transactions and put it into this new block, and then it is broadcasted to the entire network. This is how a new block is added, and how the blockchain is created.
The bitcoin mining process achieves decentralized verifiability by providing an incentive for multiple computers to try and find the next block in which to confirm transactions. The incentive for finding new blocks is that each block has a bitcoin reward in it that is given to the miner who finds the block.
In order to find a block on the Bitcoin blockchain, a miner must be the first one in the Bitcoin network to find a certain nonce (which you can think of as a random number, for the sake of simplicity) that is less than or equal to the “target” hash of that particular block. This nonce will subsequently produce the correct block hash that is accepted by the rest of the miners.
Calculating the right hash to complete a block is basically guesswork, so miners have to churn through lots of random guesses until one of them hits the right one. As a result, competing for block rewards requires miners to expend large amounts of computational power.
Once a block has been accepted by the entire network and added to the blockchain, the miners move on to calculating the hash for the next block.
The reward for generating the correct block is currently 12.5 bitcoins. That number will decrease over time by being halved until it approaches zero (it will never actually reach zero). The last bitcoin is expected to be created on May 7, 2140.
The bitcoins that are awarded to the winning computer in the competition to complete a block are new bitcoins that did not exist previously anywhere on the network. In this way, mining makes new bitcoins available to participants in the network.
By design, calculating the right hash to complete a block becomes more and more difficult over time. In the early days of Bitcoin, when the chances of calculating the right block hash were much higher than they are today, one could mine with a regular computer and have a decent chance of getting the block reward before anyone else.
Today, however, most bitcoin mining is done using special computers, called miners. These devices typically use graphics processing units, or GPUs, to run many mathematical calculations in an attempt to find a winning hash. Although GPUs are usually used to process video output, they also happen to be able to calculate hashes much faster than a traditional computer could with regular central processing units, or CPUs, which is why mining rigs use GPUs for their processing power.
The cost of bitcoin mining rigs ranges from a few hundred dollars to many thousands of dollars, depending mostly on how much power the miner consumes and the current price of bitcoin. While costs will vary depending on the price of electricity in a particular area as well as the difficulty of finding the right block hash, the electricity required to mine a single bitcoin can cost thousands of dollars.
If you don’t want to buy and maintain your own mining rig, you can take advantage of cloud-based bitcoin mining services. A variety of companies allow users to pay to run bitcoin mining operations on mining rigs that they maintain in their own data centers.