What do Bitcoin Miners really solve? You may know that we solve "hashes", but what does that really mean. Can anybody see what we are solving? And what about an example of what a bitcoin mining machine seeks to solve?
Understanding hashes is the first step in understanding mining. A hash will take an input of any length, and generate what appars to be a randomised output of a specific length. The same input will always generate the same output, but changing just one character will drastically change the output.
a948904f2f0f479b8f8197694b30184b0d2ed1c1cd2a1ec0fb85d299a192a447 is the hash of 'hello world', and 30e731839774de9ea08ff1adb8aa6b638e05f64900d005f84aea563cab0092b5 is the hash of 'hello worle', Very different, aren't they?
This behaviour makes it near impossible to predict what input gives a particular output. For example, what input gives aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa as a hash? It's not feasible to work it out. People will often build lookup tables that map these inputs to outputs in order to perform quick reversals later. These tables are called rainbow tables and rely on the input already having been hashed.
The second step is to get the idea of a proof of work. It might be impossible to find a hash specifically with a string consisting of nothing but the letter "a" but what if we asked for a hash with a single zero at the front? That's a lot easier!
Altering the last letter of 'hello world' took 26 attempts to finally get 'hello worlC' which equates to 0d7eae0f646102a05716b3ab0309c2ccc2952c0b3420b4aabb24ff969a320f8c
Why is this of use to us miners? Because it creates a puzzle whose difficulty is measurable and which it's impossible to perform better than blind guessing. That second property is important because it's the only way to create a fair "mining" system. Miners solve such puzzles as above but which are far more difficult. For example, find a hash that looks like this: 00000000000000zzzz.
Each hash can be considered to be just a number. For example, the hash 00000000000000a05716b3ab0309c2ccc2952c0b3420b4aabb24ff969a320f8c has a numeric value of 1006471685857908083785100068964934199141504624183378801987468
So in mining, the miners have to achieve a hash with a numeric value lower than a specified number. This number is called the target. If your hash attempt gives you a number less than the target, which is the same thing as having a bunch of zeros at the front of the hash, then you win and you get to "mine the block". To find such a small hash takes millions of attempts, or more accurately, the whole mining network, with everyone trying at the same time, needs millions of billions of tries to get it right.
The part of the content that we are hashing and are allowed to change in order to try and get a hash beginning with zeros, is called the nonce.
The current block reward of 12.5 Bitcoins is given to the miner who successfully "mines the block" (finds the appropriate hash). It's not really that mining "generates" the Bitcoin in any sense, it's just that it's written into Bitcoin code that a transaction block starts with a unique transaction called a "coinbase" transaction, which is the only type of transaction with no inputs. It only has an output, consisting of the reward plus the transaction fees.
It's imprtant to remember that it is impossible to solve the puzzle better than through blind guessing. If there was any way at all to get at the answer quickler, perhaps through artificial intelligence; or the application of modular arithmetics, factorials, or advances in prime number theory, new blocks would be created too fast, and the last Bitcoin would be mined well before the proposed date. That would not only be unfair to miners without the financial muscle to run such an operation, but would seriously undermine the confidence in the network.