Jump to content
Onchain Report

Crypto news from every chain

Block.coinbase in Solidity: Who Sets the Fee Recipient

What does block.coinbase return in a smart contract? The current block’s payable fee-recipient address, which builders can receive through conditional payments.

Onchain Report Newsroom#741a103 min read

Block.coinbase in Solidity: Who Sets the Fee Recipient

block.coinbase returns the payable address named as the current block’s beneficiary, or fee recipient. In Solidity, the value comes from the block header, so it is the same for every transaction in that block.

Flashbots bundles helped popularize searcher contracts that pay this address only when a trade succeeds. For more on the infrastructure behind this flow, see the flashbots relay.

Who sets the address, and why do contracts pay it?

The EVM’s COINBASE opcode reads the beneficiary address from the block header; Solidity exposes that value as block.coinbase, with type address payable. Here, “coinbase” is an old Ethereum term for the block beneficiary, not the Coinbase exchange.

Since Ethereum’s Merge, the beneficiary field holds the fee recipient chosen by whoever built the block. With MEV-Boost, the builder commonly sets its own address there, then pays the validator in a final transaction. In that case, block.coinbase points to the builder, not the validator. Flashbots is a research and infrastructure organization involved in MEV—the value that can be extracted by reordering or including transactions.

Say a searcher contract spots an arbitrage opportunity. It can perform the trade and end with block.coinbase.transfer(x), sending an agreed payment to the block’s fee recipient. If the trade fails and the transaction reverts, the payment does not go through. This lets the searcher offer payment for inclusion while making it conditional on a successful result.

Shanghai made access to this address cheaper. Under EIP-3651, the coinbase address is warm at the start of a transaction. A transfer to it therefore skips the 2,600-gas cold-access charge that would otherwise apply to a first access to a cold address.

A common mistake is to treat block.coinbase as the validator’s fixed address and use it to identify who proposed the block. On a MEV-Boost block, the address may belong to the builder instead. Since the block producer chooses the beneficiary, it is also unsuitable as a source of security or randomness that contracts must trust.

Related

How do you set block.coinbase in Foundry or Hardhat tests?

Set the coinbase value in the test environment, then check what your contract reads. Foundry provides the coinbase cheatcode; Hardhat supports the coinbase cheatcode and a local-network setting for new blocks.

Can block.coinbase be used for access control or randomness?

A contract can compare block.coinbase with an address, but the block producer chooses that value, so it should not be treated as a trusted identity. It is also not a secure random value: a producer can influence the beneficiary address.