I know that when a miner mines an Ethereum block, they receive both the block reward and the transaction fees from all the transactions included in that block, but how exactly are all of these transaction fees sent to the miner who mines the block?


but how exactly are all of these transaction fees sent to the miner who mines the block?

They are not really sent anywhere - they don't need to be.

When a block is mined by a given miner, the consensus protocol ensures that the rest of the network becomes (eventually) consistent, meaning that all other miners accept the approved block, and get on with mining the next one.

In doing this, all other miners - as well as all other client nodes in the network - can simply update their copy of the world state to credit the winning miner's account with the associated rewards.

In consensus.go we see the following function:

func accumulateRewards(config *params.ChainConfig, state *state.StateDB, header *types.Header, uncles []*types.Header) {
    // Select the correct block reward based on chain progression
    blockReward := FrontierBlockReward
    if config.IsByzantium(header.Number) {
        blockReward = ByzantiumBlockReward
    if config.IsConstantinople(header.Number) {
        blockReward = ConstantinopleBlockReward
    // Accumulate the rewards for the miner and any included uncles
    reward := new(big.Int).Set(blockReward)
    r := new(big.Int)
    for _, uncle := range uncles {
        r.Add(uncle.Number, big8)
        r.Sub(r, header.Number)
        r.Mul(r, blockReward)
        r.Div(r, big8)
        state.AddBalance(uncle.Coinbase, r)

        r.Div(blockReward, big32)
        reward.Add(reward, r)
    state.AddBalance(header.Coinbase, reward)

The pertinent lines here are the ones calling state.AddBalance().

These add the rewards to the state variables relating to the miner's address, which is represented by .Coinbase.

(The same is done for the transaction fees in state_transition.go.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.