---
eip: 1884
label: EIP-1884
title: Repricing for trie-size-dependent opcodes
status: Final
type: Standards Track
category: Core
created: 2019-03-28
requires: 150, 1052
official: https://eips.ethereum.org/EIPS/eip-1884
source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1884.md
canonical: https://eips.huatuo.xyz/eip-1884/
lang: en
tldr: Istanbul-era repricing that raised SLOAD, BALANCE and EXTCODEHASH gas costs to match the real cost of reading a growing state trie, and added the cheap SELFBALANCE opcode.
tags: [gas, opcodes, state, core, istanbul]
---

# EIP-1884: Repricing for trie-size-dependent opcodes

> This EIP proposes repricing certain opcodes, to obtain a good balance between gas expenditure and resource consumption.

**TL;DR:** Istanbul-era repricing that raised SLOAD, BALANCE and EXTCODEHASH gas costs to match the real cost of reading a growing state trie, and added the cheap SELFBALANCE opcode.

## What problem does it solve?

Opcodes that read the state trie got slower as Ethereum's state grew, but their gas prices stayed the same. Measurements from go-ethereum full syncs showed storage and account reads dominating block processing time. `SLOAD` had become more than twice as slow per unit of gas as it was right after its last repricing in [EIP-150](/eip-150/).

Underpriced operations are dangerous: an attacker can fill blocks with them and make blocks slow to process. They also make processing time per gas uneven, which limits how high the block gas limit can safely go.

## How it works

Activated in the Istanbul hard fork:

| Opcode | Before | After |
| --- | --- | --- |
| `SLOAD` (`0x54`) | 200 | **800** |
| `BALANCE` (`0x31`) | 400 | **700** |
| `EXTCODEHASH` (`0x3f`) | 400 | **700** |
| `SELFBALANCE` (`0x47`, new) | — | **5** |

- `BALANCE` was raised to 700 to match `EXTCODESIZE`, which already cost 700.
- `EXTCODEHASH` ([EIP-1052](/eip-1052/)) was priced the same as `BALANCE` because it performs the same account lookup, so it rose too.
- `SELFBALANCE` takes no arguments and pushes the current contract's balance. Checking your own balance is cheap because the account is already loaded, so it no longer needs to pay the price of an arbitrary lookup. It sits at `0x47` because the `0x3X` range was full, and costs 5 rather than 2 because balance can change during execution and still needs a cached lookup.

## Sample code

Solidity compilers targeting Istanbul or later compile `address(this).balance` to `SELFBALANCE` automatically. In inline assembly it is available directly:

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

contract Vault {
    function myBalance() external view returns (uint256 bal) {
        assembly {
            bal := selfbalance() // 5 gas, vs. balance(address()) for an external lookup
        }
    }
}
```

The fallback-function pitfall this EIP exposed:

```solidity
contract Fragile {
    uint256 public counter;
    // Called via transfer()/send(), which forward only a 2300 gas stipend.
    // An SLOAD (and SSTORE) here can exceed the stipend after a repricing -> the transfer reverts.
    receive() external payable { counter += 1; }
}
```

## Things to know

- Status is **Final**. It shipped in Istanbul alongside other changes such as [EIP-2200](/eip-2200/) net gas metering.
- It was a breaking change for contracts that assumed fixed gas costs. Fallback functions that read storage could run out of gas under the 2300 stipend forwarded by `transfer`/`send`. This is a main reason those methods are now discouraged in favour of `call`.
- The spec checked [ERC-165](/eip-165/)'s 30,000-gas limit for `supportsInterface` and judged that typical implementations would stay well within it.
- These prices were reworked again in Berlin by [EIP-2929](/eip-2929/), which introduced cold/warm access pricing (for example, a cold `SLOAD` costs 2100 and a warm one 100).


---

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