When you hear about bitcoin “mining,” you envisage coins being dug out of the ground. But bitcoin lucky miners isn’t physical, so why do we call it mining? The bitcoin protocol stipulates that 21 million bitcoins will exist at some point. What “miners” do is bring them out into the light, a few at a time.
They get to do this as a reward for creating blocks of validated transactions and including them in the blockchain. Backtracking a bit, let’s talk about “nodes. A node is a powerful computer that runs the bitcoin software and helps to keep bitcoin running by participating in the relay of information. Nodes spread bitcoin transactions around the network.
These group outstanding transactions into blocks and add them to the blockchain. By solving a complex mathematical puzzle that is part of the bitcoin program, and including the answer in the block. The puzzle that needs solving is to find a number that, when combined with the data in the block and passed through a hash function, produces a result that is within a certain range. For trivia lovers, this number is called a “nonce”, which is a concatenation of “number used once. How do they find this number? The hash function makes it impossible to predict what the output will be. So, miners guess the mystery number and apply the hash function to the combination of that guessed number and the data in the block.
The resulting hash has to start with a pre-established number of zeroes. There’s no way of knowing which number will work, because two consecutive integers will give wildly varying results. The first miner to get a resulting hash within the desired range announces its victory to the rest of the network. All the other miners immediately stop work on that block and start trying to figure out the mystery number for the next one. As a reward for its work, the victorious miner gets some new bitcoin.