Hey guys, I ve kept it short and sweet through out the article. And no beating around the bush.
What is mining in Blockchain?
The purpose of mining is to find the nonce. Millions of nodes (miners) compete to find that nonce. There are certains rules to create that nonce.
Mining is a way to keep Blockchain decentralized.
How can I mine?
I have a transaction pool from which i get all the transactions fed to mine.
Once i get hold of the previous transactions from the pool, I have approximately 10 minutes to solve a difficult mathematical problem based on a cryptographic hash algorithm and to find the nonce. The nonce generated is to create the Hash.
Once the hash is created, I will transmit this block to all my peers. They need to validate my block: These are the rules for validation:
1. My hash is lesser than the target
2. Block size is within acceptable limits
3. Block timestamp is less than two hours in the future
4. The first transaction is a coinbase transaction (Coinbase is the trading platform)
5. The coinbase transaction has a valid reward
6. The transactions within the block are valid
If my block is valid, the other miners will update the blockchain with my new block.
If I create a valid block, I will be rewarded either with
a. Bitcoins or
b. Transaction points
Proof-Of-Work: This is to prove that I spent time and energy to find the valid hash
Confirmed : When the puzzle is solved, the transactions contained are considered ‘confirmed’
Candidate Block: The block which is created first and which is not confirmed yet
Transaction Pool : Memory pool where all previous transactions reside
Target : This is generated by the network and defines if the block’s hash is valid or not. If your hash is higher than the target, it is not valid. In the Bitcoin world, the target is adjusted every 2016 Blocks
Difficulty: Difficulty is a measure of how difficult it is to find a hash below a given target. The Bitcoin Network has a global block difficulty. Valid blocks must have a hash below this target.
For example, I want to start mining(find the nonce). I first create a candidate block. My candidate block’s header will have the following:
· The previous Block’s hash
· Merkle Tree Root
· Data for the competition (Version, Timestamp, Target, Nonce)
The number of bitcoins created will decrease every 4 years i.e., every 2,100,000 blocks. Today, a newly created block contains 12.5 bitcoins. So, approximately, after 2140, there are no bitcoins to be issued. While wich transaction points, the miner can keep the change in the transaction itself.
The Hash Function used is SHA256. The output is always 256 bits long.