---
eip: 3198
label: EIP-3198
title: BASEFEE opcode
status: Final
type: Standards Track
category: Core
created: 2021-01-13
requires: 1559
official: https://eips.ethereum.org/EIPS/eip-3198
source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-3198.md
canonical: https://eips.huatuo.xyz/eip-3198/
lang: en
tldr: "Added the BASEFEE opcode (0x48), which returns the current block's EIP-1559 base fee so contracts can react to network fee levels."
tags: [evm, opcode, gas, fees, london]
---

# EIP-3198: BASEFEE opcode

> Adds an opcode that gives the EVM access to the block's base fee.

**TL;DR:** Added the BASEFEE opcode (0x48), which returns the current block's EIP-1559 base fee so contracts can react to network fee levels.

## What problem does it solve?

[EIP-1559](/eip-1559/) gave every block a protocol-set **base fee per gas**. That number lives in the block header, but without a new opcode a contract had no way to read it.

Contracts that care about gas prices had to rely on guesses, admin-updated constants or `tx.gasprice` (which the caller controls). Typical use cases the spec gives:

- **Keeper bounties**: a contract that pays people to "poke" it can set the reward to `basefee + x` or `basefee * (1 + x)`, so it always covers the cost of the call whatever market conditions are.
- **Gas price derivatives**: futures or options on gas can settle against an on-chain, manipulation-resistant price.
- **Fraud-proof systems**: state channels and optimistic rollups can lengthen challenge periods automatically when base fee is high and posting a challenge is expensive.

## How it works

One opcode, activated in the London upgrade together with EIP-1559:

| Opcode | Name | Inputs | Outputs | Gas |
| --- | --- | --- | --- | --- |
| `0x48` | `BASEFEE` | 0 | 1 | 2 (`G_base`) |

It pushes the base fee of the block currently being executed, in wei per gas, as a 32-byte word. The value is already known before execution starts (it is needed to validate transactions), so the opcode costs the same as other cheap environment reads like `NUMBER` or `TIMESTAMP`.

Example from the spec: if the base fee is 7 wei, bytecode `0x4800` (`BASEFEE`, `STOP`) leaves `7` on the stack and uses 2 gas.

## Sample code

In Solidity (0.8.7 and later) the opcode is exposed as `block.basefee`:

```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

contract PokeBounty {
    uint256 public constant POKE_GAS = 60_000;
    uint256 public lastPoke;

    receive() external payable {}

    function poke() external {
        require(block.timestamp >= lastPoke + 1 hours, "too soon");
        lastPoke = block.timestamp;
        // ... do the periodic work ...

        // Reimburse at base fee plus a 20% margin, independent of the caller's tip.
        uint256 reward = POKE_GAS * block.basefee * 12 / 10;
        (bool ok, ) = msg.sender.call{value: reward}("");
        require(ok, "pay failed");
    }

    function priorityFeePaid() external view returns (uint256) {
        return tx.gasprice - block.basefee; // the tip per gas this tx actually pays
    }
}
```

From off-chain code, the same value is in the block header (`baseFeePerGas`):

```ts
const block = await provider.getBlock("latest");
console.log(block!.baseFeePerGas); // bigint, wei per gas
```

## Things to know

- Status: **Final**. Live on mainnet since the London upgrade (August 2021).
- `tx.gasprice - block.basefee` gives the effective priority fee of the current transaction.
- In `eth_call` simulations some nodes run with a base fee of 0 when no gas price is supplied, so `block.basefee` may read 0 there. Do not treat that as the real network value.
- The base fee can move by up to 12.5 % per block, so a reward based on it is only a rough estimate of what the caller paid.
- Blob transactions have a separate blob base fee, exposed by the `BLOBBASEFEE` opcode (`block.blobbasefee`), not by this one.


---

This is an unofficial plain-language summary. Read the full specification: https://eips.ethereum.org/EIPS/eip-3198
