To mine a block you have to start by selecting transactions from your mempool to include in that block. Generally you select them based on the fee they are paying to maximize your revenue. You also have to select as many transactions until the total block weight is smaller than or equal to 4000000.
Now you finalize the first transaction in your block (the coinbase transaction):
- by setting its output amount equal to block subsidy + sum of fees from all transactions.
- computing and setting the witness hash merkle root of all transactions if at least one transaction in that block had any witnesses.
Then you can finish the block header by computing the merkle root and setting it.
Finally you start computing double SHA256 hash of the header and comparing it with target. If it were > target you increment the nonce in header and repeat the steps. If it were <= target then you have successfully found the correct combination and can submit the block to the network.
If you incremented nonce to its max and still hadn't found the result you change the header (time or version) or the block content (that would change merkle root) and repeat the above steps again. The block content that can be changed are the transactions (select different ones from mempool or change their orders) or your coinbase tx (the contents of its signature that usually referred to as extranonce).
- Have one and only one input with its outpoint set to an empty hash and max index (0xffffffff)
- Have a signature script that contains the block height at the start and is no larger than 100 bytes
- Has at least one output
- Total output amount can not exceed the block subsidy + sum of all tx fees (but it can be lower)
The block subsidy is computed based on the block height and halving that takes place every 210000 blocks and starts at 50.
50 /2 = 25 /2 = 12.5 /2 = 6.25 /2 = ...
So it currently is 6.25