---
eip: 2200
label: EIP-2200
title: Structured Definitions for Net Gas Metering
status: Final
type: Standards Track
category: Core
created: 2019-07-18
official: https://eips.ethereum.org/EIPS/eip-2200
source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-2200.md
canonical: https://eips.huatuo.xyz/eip-2200/
lang: en
tldr: "The net gas metering rules for SSTORE that went live in Istanbul: repeated writes to the same slot in a transaction are cheap, with refunds for restoring values and a stipend guard against reentrancy."
tags: [gas, sstore, storage, core, istanbul]
---

# EIP-2200: Structured Definitions for Net Gas Metering

> This is an EIP that implements net gas metering. It's a combined version of [EIP-1283] and [EIP-1706], with a structured definition so as to make it interoperable with other gas changes such as [EIP-1884].

**TL;DR:** The net gas metering rules for SSTORE that went live in Istanbul: repeated writes to the same slot in a transaction are cheap, with refunds for restoring values and a stipend guard against reentrancy.

## What problem does it solve?

Writing a storage slot used to cost a full 5,000 or 20,000 gas every time, even if the same slot was written several times in one transaction. Reentrancy locks, counters and values passed between call frames all paid far more than the work clients actually did.

[EIP-1283](/eip-1283/) fixed that with "net gas metering" but was pulled from Constantinople: a write to an already-changed slot cost only 200 gas, which fits inside the 2,300 gas stipend that Solidity's `transfer`/`send` gives the recipient. Contracts that relied on "the stipend is too small to change state" could become reentrant.

EIP-2200 combines EIP-1283 with [EIP-1706](/eip-1706/)'s fix and rewrites the rules with named parameters so later repricings can plug in cleanly. It shipped in Istanbul (December 2019).

## How it works

Parameters at Istanbul:

| Name | Value |
| --- | --- |
| `SLOAD_GAS` | 800 (raised from 200, matching [EIP-1884](/eip-1884/)) |
| `SSTORE_SET_GAS` | 20,000 |
| `SSTORE_RESET_GAS` | 5,000 |
| `SSTORE_CLEARS_SCHEDULE` | 15,000 |

For each `SSTORE`, using the slot's *original* value (start of transaction), *current* value and *new* value:

0. If gas left ≤ 2,300 (the call stipend), fail with out-of-gas. This is the reentrancy guard.
1. `current == new` (no-op): charge `SLOAD_GAS`.
2. `original == current` (first change): charge `SSTORE_SET_GAS` if original is 0, else `SSTORE_RESET_GAS` (and refund `SSTORE_CLEARS_SCHEDULE` if new is 0).
3. Otherwise the slot is dirty: charge `SLOAD_GAS` and adjust refunds: undo or grant the clear refund as the value moves to or from 0, and if `new == original` refund `SET_GAS − SLOAD_GAS` or `RESET_GAS − SLOAD_GAS`.

## Sample code

The Istanbul rule as Python-style pseudocode:

```python
SLOAD_GAS, SET, RESET, CLEARS = 800, 20000, 5000, 15000
STIPEND = 2300

def sstore(gasleft, original, current, new, refund):
    if gasleft <= STIPEND:
        raise OutOfGas()
    if current == new:
        return SLOAD_GAS, refund
    if original == current:
        if original == 0:
            return SET, refund
        if new == 0:
            refund += CLEARS
        return RESET, refund
    if original != 0:
        if current == 0:
            refund -= CLEARS
        if new == 0:
            refund += CLEARS
    if original == new:
        refund += (SET - SLOAD_GAS) if original == 0 else (RESET - SLOAD_GAS)
    return SLOAD_GAS, refund
```

## Things to know

- Status is **Final** and it is the basis of today's `SSTORE` pricing, but the numbers have moved on. [EIP-2929](/eip-2929/) (Berlin) folded in cold/warm access costs, and [EIP-3529](/eip-3529/) (London) cut `SSTORE_CLEARS_SCHEDULE` to 4,800 and capped total refunds at one fifth of gas used.
- The structure (no-op / fresh / dirty, original vs current value) is unchanged, which is exactly why the spec switched to named parameters.
- Gas estimation must account for the stipend check: any `SSTORE` needs more than 2,300 gas left, even if the write itself is cheap.
- Refunds are paid at the end of the transaction, not when the `SSTORE` runs.


---

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