EIPs Explained

EIP-3044 · Stagnant · Interface · 2020-10-14

EIP-3044: Adds `baseFee` to `eth_getBlockByNumber`

A stagnant JSON-RPC proposal to include each block's EIP-1559 base fee in the `eth_getBlockByNumber` response, the idea behind today's `baseFeePerGas` field.

What problem does it solve?

EIP-1559 added a protocol-computed base fee per gas to every block header. Wallets and gas estimators need that number to choose sensible maxFeePerGas values, but the standard JSON-RPC block object (EIP-1474) had no field for it.

EIP-3044 proposed the simplest fix: add the base fee to the existing eth_getBlockByNumber result rather than create a new endpoint.

How it works

  • Parameters of eth_getBlockByNumber are unchanged.
  • For blocks on or after the EIP-1559 fork, the result object must include the base fee as a hex Quantity.
  • For blocks before the fork, the field must not be present, so older responses are unchanged and existing clients are not broken.
  • The field is purely informational and has no consensus effect.

The proposal names the field baseFee. When clients actually shipped EIP-1559 in the London upgrade, the field that appeared in block objects is named baseFeePerGas, and it is returned by eth_getBlockByHash as well.

Sample code

Request and an abridged response as clients return it today:

curl -s -X POST -H 'content-type: application/json' "$RPC_URL" --data '{
  "jsonrpc": "2.0", "id": 1,
  "method": "eth_getBlockByNumber",
  "params": ["latest", false]
}'
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "number": "0x1b4",
    "gasLimit": "0x1c9c380",
    "gasUsed": "0x9f759",
    "baseFeePerGas": "0x7",
    "transactions": []
  }
}

Reading it with ethers v6:

const block = await provider.getBlock("latest");
console.log(block?.baseFeePerGas); // bigint in wei, null for pre-London blocks

Things to know

  • Status is Stagnant. The proposal itself was never finalized, but the behaviour it describes — an extra base-fee field, absent on pre-London blocks — is what clients implemented, under the name baseFeePerGas.
  • Do not code against a baseFee key; use baseFeePerGas.
  • Inside contracts, the current block's base fee is available via the BASEFEE opcode from EIP-3198.
  • eth_feeHistory is the usual way to fetch base fees for a range of blocks at once.

#json-rpc #base-fee #interface #eip-1559 #stagnant

Details

Authors
Abdelhamid Bakhta (@abdelhamidbakhta)
Status
Stagnant
Type
Standards Track / Interface
Created
2020-10-14
Requires

Machine-readable: Markdown · JSON