What is Bitcoin mining? Bitcoin mining is how Bitcoin transactions are validated and confirmed by the Bitcoin network. Bitcoin miners create a new block by solving a proof of work problem that is chained through cryptographic proof to the previous block.Each block builds upon the previous one creating a blockchain. Every transaction in the blockchain can be proven. In this way, the Bitcoin network can come to distributed consensus as to how many Bitcoins (100,000,000 satoshis) are allocated to each public key address.What is a Bitcoin miner? A Bitcoin miner is a computer specifically designed to solve problems according to the proof of work algorithm. Currently, highly specialized chips called ASICs, Application Specific Integrated Circuits, are used as Bitcoin miners. There are many places where you can buy a Bitcoin miner.What is Bitcoin? Bitcoin is an internet protocol that enables the transfer of value over a communications channel like the Internet or radio.One of its first applications is as a decentralized digital currency. Think of it like being able to send a gold coin as easy as you send an email.But there will be a lot more applications of this blockchain technology. It will enable all types of amazing things like self-driving cars that are able to pick up passengers and pay for their own maintenance. Or a refrigerator that is able to pay for groceries to restock itself.Bitcoin is changing the world of finance the same way that the Internet changed publishing. When everyone has access to this type of powerful financial technology then the whole world benefits as trade becomes cheaper, faster, simpler and more efficient.The Bitcoin NetworkThe bitcoin network is a peer-to-peer payment network that operates on a cryptographic protocol. Users send bitcoins, the units of currency, by broadcasting digitally signed messages to the network using bitcoin wallet software. Transactions are recorded into a distributed, replicated public database known as the blockchain, with consensus achieved by a proof-of-work system called “mining”. The protocol was designed in 2008 and released in 2009 as open source software by “Satoshi Nakamoto”, the name or pseudonym of the original developer/developer group.The network requires minimal structure to share transactions. Messages are broadcast on a best effort basis, and nodes can leave and rejoin the network at will. Upon reconnection, a node downloads and verifies new blocks from other nodes to complete its local copy of the blockchain.Bitcoin mining is the process of adding transaction records to Bitcoin’s public ledger of past transactions. This ledger of past transactions is called the block chain as it is a chain of blocks. The block chain serves to confirm transactions to the rest of the network as having taken place. Bitcoin nodes use the block chain to distinguish legitimate Bitcoin transactions from attempts to re-spend coins that have already been spent elsewhere.Bitcoin mining is intentionally designed to be resource-intensive and difficult so that the number of blocks found each day by miners remains steady. Individual blocks must contain a proof of work to be considered valid. This proof of work is verified by other Bitcoin nodes each time they receive a block. Bitcoin uses the hashcash proof-of-work function.The primary purpose of mining is to allow Bitcoin nodes to reach a secure, tamper-resistant consensus. Mining is also the mechanism used to introduce Bitcoins into the system: Miners are paid any transaction fees as well as a “subsidy” of newly created coins. This both serves the purpose of disseminating new coins in a decentralized manner as well as motivating people to provide security for the system.Bitcoin mining is so called because it resembles the mining of other commodities: it requires exertion and it slowly makes new currency available at a rate that resembles the rate at which commodities like gold are mined from the ground.The Computationally-Difficult ProblemMining a block is difficult because the SHA-256 hash of a block’s header must be lower than or equal to the target in order for the block to be accepted by the network. This problem can be simplified for explanation purposes: The hash of a block must start with a certain number of zeros. The probability of calculating a hash that starts with many zeros is very low, therefore many attempts must be made. In order to generate a new hash each round, a nonce is incremented.The Difficulty MetricThe difficulty is the measure of how difficult it is to find a new block compared to the easiest it can ever be. It is recalculated every 2016 blocks to a value such that the previous 2016 blocks would have been generated in exactly two weeks had everyone been mining at this difficulty. This will yield, on average, one block every ten minutes. As more miners join, the rate of block creation will go up. As the rate of block generation goes up, the difficulty rises to compensate which will push the rate of block creation back down. Any blocks released by malicious miners that do not meet the required difficulty target will simply be rejected by everyone on the network and thus will be worthless.RewardWhen a block is discovered, the discoverer may award themselves a certain number of bitcoins, which is agreed-upon by everyone in the network. Currently this bounty is 25 bitcoins; this value will halve every 210,000 blocks.Additionally, the Bitcoin miner is awarded the fees paid by users sending transactions. The fee is an incentive for the miner to include the transaction in their block. In the future, as the number of new bitcoins miners are allowed to create in each block dwindles, the fees will make up a much more important percentage of mining income.TransactionsA bitcoin is defined by a sequence of digitally signed transactions that began with the bitcoin’s creation as a block reward. The owner of a bitcoin transfers it by digitally signing it over to the next owner using a bitcoin transaction, much like endorsing a traditional bank check. A payee can examine each previous transaction to verify the chain of ownership. Unlike traditional check endorsements, bitcoin transactions are irreversible, which eliminates risk of chargeback fraud.Although it is possible to handle bitcoins individually, it would be unwieldy to require a separate transaction for every bitcoin in a transaction. Transactions are therefore allowed to contain multiple inputs and outputs,[4] allowing bitcoins to be split and combined. Common transactions will have either a single input from a larger previous transaction or multiple inputs combining smaller amounts, and one or two outputs: one for the payment, and one returning the change, if any, to the sender. Any difference between the total input and output amounts of a transaction goes to miners as a transaction fee.How Bitcoin Mining WorksTo form a distributed timestamp server as a peer-to-peer network, bitcoin uses a proof-of-work system similar to Adam Back’s Hashcash and the internet rather than newspaper or Usenet posts. The work in this system is what is often referred to as bitcoin mining.The mining process involves identifying a value that when hashed twice with SHA-256, begins with a number of zero bits. While the average work required increases exponentially with the number of leading zero bits required, a hash can always be verified by executing a single round of double SHA-256.For the bitcoin timestamp network, a valid “proof-of-work” is found by incrementing a nonce until a value is found that gives the block’s hash the required number of leading zero bits. Once the hashing has produced a valid result, the block cannot be changed without redoing the work. As later blocks are chained after it, the work to change the block would include redoing the work for each subsequent block.The best chain (black) consists of the longest series of transaction records from the genesis block (green) to the current block or record. Orphaned records (purple) exist outside of the best chain.Majority consensus in bitcoin is represented by the longest chain, which required the greatest amount of effort to produce. If a majority of computing power is controlled by honest nodes, the honest chain will grow fastest and outpace any competing chains. To modify a past block, an attacker would have to redo the proof-of-work of that block and all blocks after it and then surpass the work of the honest nodes. The probability of a slower attacker catching up diminishes exponentially as subsequent blocks are added.To compensate for increasing hardware speed and varying interest in running nodes over time, the difficulty of finding a valid hash is adjusted roughly every two weeks. If blocks are generated too quickly, the difficulty increases and more hashes are required to make a block and to generate new bitcoins.Bitcoin mining is a competitive endeavor. An “arms race” has been observed through the various hashing technologies that have been used to mine bitcoins: basic CPUs, high-end GPUs common in many gaming computers, FPGAs and ASICs all have been used, each reducing the profitability of the less-specialized technology. Bitcoin-specific ASICs are now available. As bitcoins become more difficult to mine, computer hardware manufacturing companies have seen an increase in sales of high-end products.Computing power is often bundled together or “pooled” to reduce variance in miner income. Individual mining rigs often have to wait for long periods to confirm a block of transactions and receive payment. In a pool, all participating miners get paid every time a participating server solves a block. This payment is proportional to the amount of work an individual miner contributed to help find that block.The Bitcoin Mining ProcessA rough overview of the process to mine bitcoins is:New transactions are broadcast to all nodes.Each miner node collects new transactions into a block.Each miner node works on finding a proof-of-work code for its block.When a node finds a proof-of-work, it broadcasts the block to all nodes.Receiving nodes validate the transactions it holds and accept only if all are valid.Nodes express their acceptance by moving to work on the next block, incorporating the hash of the accepted block.How Payment Verification HappensUpon receiving a new transaction a node must validate it: in particular, verify that none of the transaction’s inputs have been previously spent. To carry out that check the node needs to access the blockchain. Any user who does not trust his network neighbors, should keep a full local copy of the blockchain, so that any input can be verified.As noted in Nakamoto’s whitepaper, it is possible to verify bitcoin payments without running a full network node (simplified payment verification, SPV). A user only needs a copy of the block headers of the longest chain, which are available by querying network nodes until it is apparent that the longest chain has been obtained. Then, get the Merkle branch linking the transaction to its block. Linking the transaction to a place in the chain demonstrates that a network node has accepted it, and blocks added after it further establish the confirmation.Bitcoin Mining PoolsAs more and more miners competed for the limited supply of blocks, individuals found that they were working for months without finding a block and receiving any reward for their mining efforts. This made mining something of a gamble. To address the variance in their income miners started organizing themselves into pools so that they could share rewards more evenly.