EIPs Explained

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

EIP-3045: Adds `baseFee` to `eth_getUncleByBlockHashAndIndex`

A stagnant proposal to add a `baseFee` field to the block object returned by `eth_getUncleByBlockHashAndIndex` for blocks after the EIP-1559 fork.

What problem does it solve?

EIP-1559 added a base fee per gas to every block header. Tools that estimate gas prices or analyze fee history need to read that value through JSON-RPC, and the RPC responses had to grow a field for it.

EIP-3045 covers one specific endpoint: eth_getUncleByBlockHashAndIndex, which returns the header of an uncle (ommer) block. Since uncle headers also carry a base fee after the fork, the response should expose it.

How it works

The request parameters are unchanged: a block hash and an uncle index. Only the result changes:

  • For uncle blocks on or after the EIP-1559 fork block, the result must include baseFee, a hex-encoded quantity as defined in EIP-1474.
  • For blocks before the fork, the result must not include the field.

Adding one field instead of a new endpoint was chosen as the simplest change to integrate, and omitting it for older blocks keeps existing consumers working.

Sample code

JSON-RPC request and the relevant part of the response, as proposed:

{
  "jsonrpc": "2.0",
  "id": 1559,
  "method": "eth_getUncleByBlockHashAndIndex",
  "params": ["0xc6ef2fc5426d6ad6fd9e2a26abeab0aa2411b7ab17f30a99d3cb96aed1d1055b", "0x0"]
}
{
  "jsonrpc": "2.0",
  "id": 1559,
  "result": {
    "number": "0x1b4",
    "baseFee": "0x7",
    "gasLimit": "0x9f759",
    "gasUsed": "0x9f759"
  }
}

Reading an uncle header from TypeScript (ethers v6):

import { JsonRpcProvider } from "ethers";

const provider = new JsonRpcProvider(process.env.RPC_URL);
const uncle = await provider.send("eth_getUncleByBlockHashAndIndex", [blockHash, "0x0"]);
// Clients expose the field as `baseFeePerGas`, not the `baseFee` name proposed here
console.log(uncle?.baseFeePerGas ?? uncle?.baseFee);

Things to know

  • Status is Stagnant. It was never finalized, and the field name proposed here (baseFee) is not what clients ship: Ethereum clients return baseFeePerGas in block and header objects.
  • The JSON-RPC API it extends, EIP-1474, is itself Stagnant; the maintained reference is the ethereum/execution-apis specification.
  • Since The Merge, proof-of-stake Ethereum produces no uncle blocks, so this endpoint is only relevant for historical proof-of-work blocks.
  • Inside contracts, the current block's base fee is available via the BASEFEE opcode from EIP-3198.

#json-rpc #api #fees #uncles #interface

Details

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

Machine-readable: Markdown · JSON