Image credits
The Bitcoin mining is the procedure of earning money (Bitcoins) by solving math problem with a computer
For the sake of understanding we will simplify the process
Lets imagine that we have just started mining. We look at the last block that was mined and we hash its header. For bitcoin hashing a SHA-256 algorithm is used. You can test it for yourself here, just insert any number and it will be hashed into a long string of numbers and letters with fixed 256-bit (32-byte) size.
For example, 1234 will always give you this number: 03ac674216f3e15c761ee1a5e255f067953623c8b388b4459e13f978d7c846f4
But you cannot reverse or decrypt this number into 1234 back again. To do this you would have to manually insert numbers one my one into hashing calculator and compare the results. This is quite similar to what miners are doing.
Lets see an extremely simplified example of mining
- We take a hashed header of last block:
5994471abb01112afcc18159f6cc74b4f511b99806da59b3caf5a9c173cacfc5
- Then combine it with 3 transactions that we would like to insert in our new block
8d969eef6ecad3c29a3a629280e686cf0c3f5d5a86aff3ca12020c923adc6c92
5c69d9ac45cca700492347264d87ca2e55bf7dfeb84525f2c9ca5db416d648e0
bd43f3349b217a3d2bf205908507c28fd943b0635bc4900898f0d116de094cb8 - And hash them by adding at the end any number, for example 1 then 2, then 3, (this number is called nonce) until we get at least one zeo at the beginning of our new hash:
After adding number 7 at the end we get our first 0 at the beginning:
Congratulations we mined our first block for the reward of 12.5 Bitcoin!!!
Mining Farms
Before it was possible to mine bitcoin even on a laptop and actually get bitcoin. However, right now the total network hashing power is so enormous that mining with a laptop is completely unprofitable even if you join a mining pool. Nowadays, there are specialized ASICs that are made specifically to mine bitcoin and you can buy them to mine bitcoin.
Companies and individuals are building so called Mining Farms with hundreds of these ASICs working together to get the bitcoin reward.
Additional rewards - Transaction fees
People who are sending transactions include additional rewards for miners, kind of like a tip, so that their transactions are included in the next block. Right now there are so many transactions in line that miners choose transaction in order of rewards.
Every block right now is limited to 1 MB of memory and if you don't leave a tip or leave very little, chances are your transaction will not be included in the near future. All transactions are seen on the network, but they are not confirmed until they are included in a block.
Not as easy as it sounds
To get one zero at the beginning is considered very easy, if that was the case then a block would have been found in less than a milisecond with total computational power of all the miners combined right now aprox. 5,530,742,000,000,000,000 hashes per second like we found right now.
That is why the current difficulty requires the miners to find a hash with at least 17-18 zeros at the beginning. This difficulty constantly changes by bitcoin algorithm when Hashing power changes so that blocks are found approximately every 10 minutes.
Mining pools
The mining pools are sort of groups, where a group of miners gathers and work together. They are called miners because their task is to metaphorically “break” the blocks, which carry transactions. They are searching for a hash code of the block to be confirmed, which will open the way for the new blocks like we saw in the example above. But they combine their computational power to find it faster then anyone else, and then just split the reward.
When it is done, the miners share 12.5 BTC, which is around 30,000$ for every block proportionally depending on the computational power that was used by each miner. Each mining pool also takes a percent profit from each block ranging from 0 - 4%.
Here is the block distribution amongst the mining pools
As you can see Antpool is the largest mining pool.
Image is clickable