Transaction Execution

How MegaEVM differs from standard Ethereum — contract size limits, gas forwarding, SELFDESTRUCT semantics, and precompile overrides.

MegaEVM is MegaETH's execution environment. It is fully compatible with Ethereum smart contracts while introducing optimizations for MegaETH's unique architecture.

Overview

MegaEVM builds on established standards. Its latest hardfork, Rex3, is based on Optimism Isthmusarrow-up-right, which in turn is adapted from Ethereum Praguearrow-up-right. This means:

  • All standard Solidity contracts work on MegaETH.

  • Standard development tools (Hardhat, Foundry, Remix, etc.) are compatible.

  • Existing Ethereum libraries and patterns apply.

MegaEVM introduces a few changes to accommodate MegaETH's low fees and high capacity. The most important change is the multidimensional gas model and resource limits. In MegaEVM, transactions consume two types of gas: compute gas, which models computation at large and is identically defined as Ethereum's gas; and storage gas, a new concept that models the storage subsystem in particular. Similarly, MegaEVM caps resource usage of transactions and blocks using rules that each target an individual type of resource. Developers should consider these changes in contrast to Ethereum's EVM, where gas is the singular metric for metering and limiting resource consumption.

Key Differences at a Glance

Feature
Ethereum
MegaETH
Remarks

Max contract size

24 KB

512 KB

Max initcode size

48 KB

536 KB

Gas forwarding rule

63/64

98/100

As defined in EIP-150arrow-up-right.

SELFDESTRUCT

Deprecated

EIP-6780 semantics

Active only within the creating transaction, per EIP-6780arrow-up-right.

Gas model

Unidimensional

Multidimensional

Compute gas and storage gas. Compute gas is identical to Ethereum's gas.

Resource limits

Unidimensional

Multidimensional

4 limits in addition to total gas limit specified by sender.

Base intrinsic gas

21,000

60,000

21,000 compute gas plus 39,000 storage gas.

For the full gas model details, see Gas Model.

Access to Volatile Data

Reading volatile data — block.timestamp, block.number, oracle storage, or the beneficiary account — caps the transaction's total compute gas to 20,000,000. This ensures transactions with external dependencies yield quickly and don't block parallel execution.

For the full list of triggers, best practices for structuring contracts around this cap, and Solidity examples, see Volatile Data Access. For the formal specification, see Gas Detentionarrow-up-right.

Increased Contract Size Limit

MegaETH supports contracts up to 512 KB in size, increased from 24 KB in Ethereum. For the formal specification, see Contract Limitsarrow-up-right.

SELFDESTRUCT with EIP-6780 Semantics

The SELFDESTRUCT opcode follows EIP-6780arrow-up-right semantics. It only destroys a contract when called within the same transaction that created the contract. In all other cases, SELFDESTRUCT behaves as a simple Ether transfer without destroying the contract or clearing its storage. For the formal specification, see SELFDESTRUCTarrow-up-right.

No Storage Gas Refund for SSTORE Resets

On Ethereum, resetting a storage slot to its original value within the same transaction refunds part of the gas. On MegaETH, storage gas is not refunded when a slot is set back to its original value — the full storage gas cost is still charged.

circle-check

"98/100" Rule for Gas Forwarding

MegaETH allows a caller to forward at most 98/100 of remaining gas to a callee. The parameter is 63/64 in Ethereum.

triangle-exclamation

For the formal specification, see Gas Forwardingarrow-up-right.

Precompile Gas Overrides

MegaETH inherits all precompiles from Optimism Isthmus, which includes Ethereum Prague precompiles, EIP-2537 BLS12-381 precompiles, and RIP-7212 P256VERIFY. Two precompiles have adjusted gas costs:

Precompile
Address
Cost Override

KZG Point Evaluation

0x0A

100,000 gas (2× the standard Prague cost of 50,000)

ModExp

0x05

EIP-7883arrow-up-right gas schedule (raises the cost floor for large-exponent calls)

For the formal specification, see Precompilesarrow-up-right.

Last updated