> ## Documentation Index
> Fetch the complete documentation index at: https://docs.monad.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Opcode Pricing

## Summary

Monad is a highly optimized system that introduces efficiencies across all dimensions -
compute, state access, and bandwidth utilization. However, the multiplier relative to legacy
EVM systems is not equal across all dimensions. As a result, some opcode gas price
changes are needed so that applications can unlock the full potential of the chain.

To minimize the number of gas price changes, rather than adjusting the gas pricing of almost
all opcodes down, Monad instead adjusts a few opcode prices up. This has the same relative
effect as discounting almost all opcodes.

The following costs are changed:

* [Cold access to state](#cold-access-cost)
* [A few precompiles](#precompiles)
* [Memory expansion](#memory-expansion)

All other costs are as on Ethereum; [evm.codes](https://www.evm.codes/) is a helpful reference.

<Note>
  These changes are covered formally in the
  [Monad Initial Spec Proposal](https://category-labs.github.io/category-research/monad-initial-spec-proposal.pdf)
</Note>

## Why are changes needed?

The EVM's current pricing model needs adaptation to support a high-performance, low-fee regime.
The pricing model assigns a weight (gas amount) to each opcode based on perceived costliness to
the system, then charges the user only based on the calculated sum of weights. As resource
scarcity changes - and especially in the event of a completely new system - those weightings
must be revised.

The changes described in this page make the minimal set of adjustments to allow Monad to
deliver high performance and low fees, while minimizing disruption to users and protecting
the system against DOS attacks.

## Cold access cost

To account for the relatively higher cost of state reads from disk when compared to computation in the Monad execution client,
the cost for "cold" account and storage access costs changes:

| Access Type | Ethereum | Monad |
| ----------- | -------- | ----- |
| Account     | 2600     | 10100 |
| Storage     | 2100     | 8100  |

The following opcodes are impacted because of the differed gas costs:

* Account access: `BALANCE`, `EXTCODESIZE`, `EXTCODECOPY`, `EXTCODEHASH`, `CALL`, `CALLCODE`,
  `DELEGATECALL`, `STATICCALL`, `SELFDESTRUCT`
* Storage access: `SLOAD`, `SSTORE`

<Note>
  Gas costs for warm account access (100 gas) and storage access (100 gas) are the same on Monad as on Ethereum.
</Note>

## Precompiles

A few [precompiles](/developer-essentials/precompiles) have been repriced to accurately reflect their relative costs in execution.

| Precompile   | Address | Ethereum            | Monad               | Multiplier |
| ------------ | ------- | ------------------- | ------------------- | ---------- |
| `ecRecover`  | `0x01`  | 3000                | 6000                | 2          |
| `ecAdd`      | `0x06`  | 150\*               | 300\*               | 2          |
| `ecMul`      | `0x07`  | 6000\*              | 30,000\*            | 5          |
| `ecPairing`  | `0x08`  | 45,000\*            | 225,000\*           | 5          |
| `blake2f`    | `0x09`  | $\text{rounds} * 1$ | $\text{rounds} * 2$ | 2          |
| `point eval` | `0x0a`  | 50,000              | 200,000             | 4          |

∗: Per input/operation, as defined in the respective precompile specification

## Memory expansion

Memory expansion is priced linearly, and the memory a transaction can use is capped at 8 MB
(8,388,608 bytes).

| Item           | Ethereum                 | Monad                |
| -------------- | ------------------------ | -------------------- |
| Expansion cost | $3w + w^2 / 512$         | $w / 2$              |
| Memory limit   | Bounded by the gas limit | 8 MB per transaction |

where $w$ is the memory size in 32-byte words. Expanding all the way to the 8 MB cap costs 131,072 gas.

Memory is counted cumulatively across call frames: the memory available to a child call is 8 MB
minus the memory already used by the current call and its parents. Memory returns to the pool
once a call returns.

Exceeding the limit halts the call frame exceptionally, consuming all the gas that frame
was given and reverting its state changes. From the caller's perspective this is
indistinguishable from an ordinary out-of-gas.

<Note>
  These changes are activated in the [`MONAD_NINE`](/developer-essentials/changelog/releases#v0-13-0-monad_nine) revision.
</Note>
