<p>If you add the coinbase transaction later, that will change the merkle root. If merkle root is changed, the block header is changed and hence the header hash you calculated earlier is no longer valid. This is why the coinbase transaction needs to be entered before you start calculating the hash of the header.</p>

CC BY-SA 4.0
2019-04-08T09:50:18.470Z
2019-04-08T09:50:18.470Z
Ugam Kamat
<p>When a miner creates the candidate block with transactions from the mempool, does he insert the coinbase transaction after winning the PoW or during PoW?</p>

<blockchain><proof-of-work><coinbase-transaction>
When does miner insert the coinbase transaction?
monkeyUser
# When does miner insert the coinbase transaction?

(Asked by: username_0 on 2019-04-08)

When a miner creates the candidate block with transactions from the mempool, does he insert the coinbase transaction after winning the PoW or during PoW?

**Tags:** blockchain, proof-of-work, coinbase-transaction


---

## 1 answers

### Answer by username_1 on 2019-04-08. Score: 4 | Accepted answer

If you add the coinbase transaction later, that will change the merkle root. If merkle root is changed, the block header is changed and hence the header hash you calculated earlier is no longer valid. This is why the coinbase transaction needs to be entered before you start calculating the hash of the header.


---

