HomeEIPs
EIPsEIP-3198
EIP-3198

BASEFEE opcode

FinalStandards Track: Core
Created: 2021-01-13
Requires: EIP-1559
Abdelhamid Bakhta (@abdelhamidbakhta), Vitalik Buterin (@vbuterin)
DiscussionsOriginal linkEdit
1 min read

The EIP-3198 proposal suggests implementing a BASEFEE opcode that starts with a base fee amount and adjusts it up and down based on network congestion. This allows wallets to auto-set gas fees for users in a reliable way, reducing the need for complex fee estimation algorithms and frequent fee overpayment. The base fee changes are constrained, making the maximum difference in base fee from block to block predictable. Additionally, the base fee is always burned, ensuring that only ETH can be used to pay for transactions and reducing risks associated with miner extractable value. This proposal aims to improve the efficiency of Ethereum's fee market by providing a more stable fee metric that is computed inside the protocol.

Videos

PEEPanEIP #31: EIP-3198: BASE FEE opcode with Ratan Rai Sur

Original

Simple Summary

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

Abstract

Add a BASEFEE (0x48) that returns the value of the base fee of the current block it is executing in.

Motivation

The intended use case would be for contracts to get the value of the base fee. This feature would enable or improve existing use cases, such as:

  • Contracts that need to set bounties for anyone to "poke" them with a transaction could set the bounty to be BASEFEE + x, or BASEFEE * (1 + x). This makes the mechanism more reliable, because they will always pay "enough" regardless of market conditions.
  • Gas futures can be implemented based on it. This would be more precise than gastokens.
  • Improve the security for state channels, plasma, optirolls and other fraud proof driven solutions. Having the BASEFEE as an input allows you to lengthen the challenge period automatically if you see that the BASEFEE is high.

Specification

Add a BASEFEE opcode at (0x48), with gas cost G_base.

OpInputOutputCost
0x48012

Rationale

Gas cost

The value of the base fee is needed to process transactions. That means it's value is already available before running the EVM code. The opcode does not add extra complexity and additional read/write operations, hence the choice of G_base gas cost.

Backwards Compatibility

There are no known backward compatibility issues with this opcode.

Test Cases

Nominal case

Assuming current block base fee is 7 wei. This should push the value 7 (left padded byte32) to the stack.

Bytecode: 0x4800 (BASEFEE, STOP)

PcOpCostStackRStack
0BASEFEE2[][]
1STOP0[7][]

Output: 0x Consumed gas: 2

Security Considerations

The value of the base fee is not sensitive and is publicly accessible in the block header. There are no known security implications with this opcode.

Copyright and related rights waived via CC0.

Further reading
Anyone may contribute to propose contents.
Go propose
Adopted by projects
Anyone may contribute to propose contents.
Go propose

Not miss a beat of EIPs' update?

Subscribe EIPs Fun to receive the latest updates of EIPs Good for Buidlers to follow up.

View all
Serve EIP builders, scale Ethereum.
Resources
GitHub
Supported by