Introduction

Hi, I'm cardene, a software engineer and technical writer focused on blockchain and AI.

I've also authored Japanese technical books on specification-driven development with LLMs and decentralized application (DApp) development.

I also build and publish a variety of tools, libraries, and open-source projects.

This article examines EIP-1283, a proposal to reduce unnecessary gas consumption by adjusting SSTORE costs according to actual storage changes.

This article translates, summarizes, and expands on the following specification.

More EIP explainers:

Overview

EIP-1283 proposes revising gas metering for the SSTORE instruction, which writes to contract storage. The goal is to better reflect the actual costs of storage operations and support more efficient smart contract development.

It introduces net gas metering, which reduces the cost of repeated writes to the same slot within one transaction. Unlike the approach in EIP-1087, it avoids requiring a separate dirty map, making the design easier to integrate into different EVM implementations.

Historical context: the figures in this article describe EIP-1283, not the current Ethereum gas schedule. EIP-1283 was disabled at Constantinople/Petersburg and its approach was subsequently revised through EIP-2200 and later gas-schedule changes.

Motivation

The previous SSTORE pricing scheme did not suit every EVM implementation or application. Temporary changes and repeated writes to the same slot within a transaction could incur excessive gas charges.

EIP-1283 uses the original storage value, the current value, and the refund counter. The new value being written determines the state transition.

This makes pricing better reflect storage changes. For example, reentrancy locks and batches of transfers within one contract often modify storage repeatedly during a single call. Subsequent writes could previously be unnecessarily expensive.

Temporary data passed between a subcall and its parent call frame, such as error information, could also benefit. Such data may no longer be needed after the transaction, so charging as if every intermediate change were permanent is inefficient.

The proposal aims to make storage pricing more practical and compatible with existing client implementations.

Specification

SSTORE consumes gas when writing to a storage slot. EIP-1283 redefines the pricing rules to account for the state of the slot and adjust charges and refunds accordingly.

This is particularly useful for contracts that update the same slot repeatedly in one transaction.

Definitions

Three values are important:

  • Original value — the value at the beginning of the transaction, before its changes.
  • Current value — the value immediately before the SSTORE instruction.
  • New value — the value to be written by SSTORE.

The relationship between these values determines the gas cost and refund adjustments.

New gas charging logic

When the current and new values are equal, the operation is a no-op and costs 200 gas under the proposed schedule.

When they differ, the following rules apply.

First modification of a slot (original equals current)

The slot is in its original state in this transaction.

If the original value is zero, the write costs 20,000 gas. If the original value is nonzero, the write costs 5,000 gas. If the new value is zero in the latter case, 15,000 gas is added to the refund counter.

Modifying an already changed slot (original differs from current)

The slot is considered dirty, and the base cost is 200 gas.

When the original value is nonzero:

  • If the current value is zero and the new value is nonzero, subtract 15,000 gas from the refund counter.
  • If the current value is nonzero and the new value is zero, add 15,000 gas to the refund counter.

If the new value equals the original value, the slot is reset:

  • Add 19,800 gas to the refund counter when the original value is zero.
  • Add 4,800 gas when the original value is nonzero.

Refund counter and implementation considerations

Under the historical rules, the actual refund was capped at half the gas consumed by the transaction. A transaction-level refund counter remains nonnegative.

An implementation that uses one counter for the whole transaction can use an unsigned value. An implementation that maintains per-call-frame counters and merges them into parent frames may need signed counters because individual frame counters can temporarily become negative.

The proposal makes the cost of storage operations dependent on their actual transitions, improving efficiency for contracts that frequently update storage.

New SSTORE pricing scheme

The proposal divides SSTORE operations into three categories and defines the charge and refund behavior for each.

Three SSTORE state types

  • No-op — the current and new values are equal. The operation costs 200 gas and does not change the slot.
  • Fresh — the current value equals the original value, but the new value differs. The slot may be unmodified or have been reset to its original value.
  • Dirty — the current value differs from the original value, and the operation modifies it again.

These categories cover the possible relationships between the original, current, and new values.

Transitioning from Fresh to Dirty

A slot initially has its original value. Its first modification incurs the conventional 20,000 or 5,000 gas charge. Subsequent modifications to a dirty slot cost 200 gas, with refund adjustments.

For a nonzero original value, moving from a current value of zero to a nonzero value cancels the earlier clearing refund. Moving to zero adds that refund.

Because slots start in their original state, these adjustments account for earlier transitions rather than canceling refunds that were never recorded.

State transitions and gas tables

SSTORE state transitions

The following tables organize the charges by original, current, and new values.

Original value is zero
new value current = original (0) current ≠ original
≠0 20000 gas(new write) 200 gas(Dirty)
0 200 gas(No-op) 200 gas, 19800 refund(reset)
Original value is nonzero
new value = original current = original current ≠ original current = 0
same(original) 200 gas 200 gas, 4800 refund 200 gas, -10200 refund
≠ original, ≠ 0 5000 gas 200 gas 200 gas, -15000 refund
0 5000 gas, 15000 refund 200 gas, 15000 refund 200 gas

The tables show the charges and refund adjustments for different transitions. Resets and clearing nonzero slots are notable examples of refund-counter changes.

The tables reproduce the historical source. No-op cases take precedence over the other rules; a write of the existing value does not generate a clearing refund.

Additional explanation

EIP-1283 seeks benefits similar to those motivating EIP-1087 and EIP-1153: more efficient handling of temporary storage data.

EIP-1087 required tracking modifications using a dirty map. Explicitly tracking every modification can add memory and processing overhead and complicate some client implementations.

EIP-1283 instead bases its calculations on three values:

  • The original value at the beginning of the transaction.
  • The current value before SSTORE.
  • The new value to be written.

These values allow clients to determine the transitions and refund adjustments without introducing a separate dirty map.

Following changes such as EIP-658, many clients already track state changes in memory. In such implementations, explicitly enumerating every storage change may add unnecessary overhead.

The proposal argues that, compared with the earlier gas schedule it evaluated, net metering does not increase net storage costs and covers the temporary-storage cases motivating EIP-1087. Clients supporting the earlier approach may need minor refactoring but not a separate tracking structure.

Comparing gas consumption with EIP-1087

The original article gives the following examples.

  • Setting slot 0 from zero to 1 and resetting it to zero: 20,000 + 200 − 19,800 = 400 gas before applying the transaction-wide refund cap.
  • Incrementing slot 0: 20,000 + 5 × 200 = 21,000 gas in the illustrated calculation, which assumes one initial write followed by five further writes. Five writes in total would instead cost 20,800 gas under those assumptions.
  • Transferring balances A → B → C when all accounts initially have nonzero balances: 5,000 × 3 + 200 − 4,800 = 10,400 gas in the illustrated scenario.

These calculations concern storage operations under the proposal, not complete transaction fees.

Compatibility

Implementing EIP-1283 requires a hard fork. The proposal expected no increase in net storage costs relative to the earlier schedule and reductions for many contracts. Its later replacement and subsequent fork changes must be considered when estimating gas today.

Tests

The proposal provides 17 test cases: 15 with two consecutive SSTORE operations and two with three operations to check resetting and rewriting storage.

Test case table

The table records bytecode, gas consumed, refund-counter adjustments, and storage values after each operation.

Bytecode Gas used Refund Original First Second Third
0x60006000556000600055 412 0 0 0 0
0x60006000556001600055 20212 0 0 0 1
0x60016000556000600055 20212 19800 0 1 0
0x60016000556002600055 20212 0 0 1 2
0x60016000556001600055 20212 0 0 1 1
0x60006000556000600055 5212 15000 1 0 0
0x60006000556001600055 5212 4800 1 0 1
0x60006000556002600055 5212 0 1 0 2
0x60026000556000600055 5212 15000 1 2 0
0x60026000556003600055 5212 0 1 2 3
0x60026000556001600055 5212 4800 1 2 1
0x60026000556002600055 5212 0 1 2 2
0x60016000556000600055 5212 15000 1 1 0
0x60016000556002600055 5212 0 1 1 2
0x60016000556001600055 412 0 1 1 1
0x600160005560006000556001600055 40218 19800 0 1 0 1
0x600060005560016000556000600055 10218 19800 1 0 1 0

Purpose and observations

The tests cover:

  • No-op writes, which incur minimal gas without a new refund.
  • Fresh writes, which cost 20,000 gas when the original value is zero.
  • Resets, which can add up to 19,800 gas to the refund counter in the historical schedule.
  • Dirty-slot modifications, which incur 200 gas per additional write.

Examples include:

  • 0 → 1 → 0: resetting the initially empty slot adds 19,800 to the refund counter.
  • 1 → 0 → 1: returning to the original nonzero value cancels the clearing refund and adds the reset refund, leaving a net refund of 4,800.
  • 1 → 0 → 0: the initial clearing adds 15,000 to the refund counter; the following no-op adds no further refund.

Overview of the mathematical proof

EIP-1283 uses an inductive argument to establish the net gas accounting for a sequence of operations. Let N denote the number of SSTORE operations, excluding other opcode costs and the transaction-wide refund cap.

Original value is zero

  • If the final value is zero, the net charge is 200 × N.
  • If the final value is nonzero, the net charge is 20,000 + 200 × (N − 1).

Original value is nonzero

  • If the final value equals the original value, the net charge is 200 × N.
  • If the final value is zero, it is 5,000 − 15,000 + 200 × (N − 1).
  • If the final value is a different nonzero value, it is 5,000 + 200 × (N − 1).

The negative net amount in the clearing case is a refund-accounting result, not a negative transaction fee. The actual refund remains subject to the transaction-wide limit.

The proof shows that the relationship holds at every step.

Citation

Wei Tang (@sorpaas), "EIP-1283: Net gas metering for SSTORE without dirty maps," Ethereum Improvement Proposals, no. 1283, August 2018. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-1283.

Conclusion

EIP-1283 proposes adapting SSTORE gas costs to actual storage transitions to reduce unnecessary costs within a transaction.

If you have questions, feel free to contact me on Twitter.

Twitter @cardene777

I also publish material on the following platforms.

https://chaldene.net/