---
eip: 3332
label: EIP-3332
title: MEDGASPRICE Opcode
status: Withdrawn
type: Standards Track
category: Core
created: 2021-03-05
official: https://eips.ethereum.org/EIPS/eip-3332
source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-3332.md
canonical: https://eips.huatuo.xyz/eip-3332/
lang: en
tldr: "A withdrawn proposal for a MEDGASPRICE opcode returning the parent block's median gas price, so contracts could cap the gas price of incoming calls and blunt front-running."
tags: [evm, opcode, gas, mev, withdrawn]
---

# EIP-3332: MEDGASPRICE Opcode

> An opcode for getting the median gas price of the parent block.

**TL;DR:** A withdrawn proposal for a MEDGASPRICE opcode returning the parent block's median gas price, so contracts could cap the gas price of incoming calls and blunt front-running.

## What problem does it solve?

Some actions pay a reward to whoever does them first, for example submitting a fraud proof to an optimistic rollup. A bot watching the mempool can copy such a transaction, attach a much higher gas price and steal the reward. That discourages honest participants from doing the actual verification work.

A natural defence is to reject calls that pay "too much" for gas, so a copycat cannot simply outbid. But a contract needs a reference price to set that cap. The options were a hard-coded constant (soon outdated) or an admin who updates it (trust, extra transactions). EIP-3332 proposed letting the EVM report a market price directly.

## How it works

- New opcode `MEDGASPRICE` at `0x46`, 0 inputs, 1 output, cost 8 gas.
- It pushes the **median gas price of the parent block**. It looks at the parent because the current block is still being built.
- After [EIP-1559](/eip-1559/), it was meant to return the median `effective_gas_price` of the previous block. Combined with `BASEFEE` from [EIP-3198](/eip-3198/), a contract could subtract the base fee to bound the priority fee instead.

The intended pattern from the spec:

```solidity
function submitFraudProof(bytes calldata proof) public {
    require(tx.gasprice <= maxGasPrice());
    // verify and reward
}

function maxGasPrice() public view returns (uint) {
    return 3 * block.medgasprice; // hypothetical binding for MEDGASPRICE
}
```

## Sample code

`MEDGASPRICE` never existed. With today's opcodes, a contract can apply the same idea by capping the **priority fee** relative to the base fee:

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

contract CappedReward {
    uint256 public constant MAX_TIP = 2 gwei;

    function submitFraudProof(bytes calldata proof) external {
        // tx.gasprice is the effective price paid; block.basefee comes from EIP-3198.
        require(tx.gasprice - block.basefee <= MAX_TIP, "tip too high");
        // ... verify proof and pay reward ...
    }
}
```

## Things to know

- Status: **Withdrawn**. It was never adopted.
- Opcode `0x46` was already assigned to `CHAINID` by [EIP-1344](/eip-1344/) (Istanbul), so the proposed number could not have been used as written.
- The spec itself lists the limits of gas-price caps: they only help if block producers order equal-price transactions fairly, and they can be defeated simply by reordering. A rapidly changing median can also make honest transactions fail or become vulnerable again.
- Today most front-running happens through private order flow and block builders, where a gas price cap gives little protection. Commit-reveal schemes or binding the reward to the submitter's identity are more robust.


---

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