How basecoin transaction is added to a block? I'm new to blockchain and bitcoin. In my understanding, miners are trying to find a nonce that is added to a block, and then the hash of the block will have some zeros at first and the first transaction in each block is a coinbase transaction.
Is coinbase transaction added to block before calculating the hash or after??? And what forces the miner, not to add 100 bitcoins as their basecoin transaction??
Also on btc.com I saw that different blocks have different amounts of bitcoins. Shouldn't it be a fixed amount of bitcoin, i.e 6.25??
It's called a &quot;coinbase&quot; transaction. It's added before the hashing work is done, just like all of the other transactions are.
If a miner tried to pay themselves any more than allowed in the coinbase transaction then the block they mine is considered invalid (since it contains an invalid coinbase transaction) and will not be accepted by the network, so they would have wasted any money spent mining it. This has happened before; for example, AntPool at block #584,802 submitted a block with too high of a coinbase transaction, and the block was rejected (see more).
Any amount above the block reward of 6.25 BTC paid in the coinbase is the sum of all of the transaction fees paid in that block, and this is how the miner claims their transaction fee reward.