~$ crypto-under-the-hood

# The machinery behind the coins

~/notes / consensus and blocks

Gas Refunds and Storage Economics

Clearing storage used to earn a refund large enough to create a market in it. The constraints introduced since explain the current design.

Ivan Kruse · · 2 min

Clearing a storage slot returns some gas, because the network no longer has to store it. That mechanism has a history worth knowing.

The original design

Writing a new storage slot cost a large amount of gas. Clearing one refunded a substantial fraction.

The intent was to price the real cost: a written slot burdens every node indefinitely, and clearing one relieves that burden.

The unintended consequence

The refund created an arbitrage. Contracts were deployed whose sole purpose was to write storage when gas was cheap and clear it when gas was expensive, capturing the difference.

These became known as gas tokens. They worked, they were widely used, and they made the state growth problem worse by incentivising writing storage specifically in order to clear it later.

The constraints introduced

Refunds were capped as a proportion of the transaction’s total gas, which limited how much could be captured in a single transaction.

Refunds for certain operations were reduced or removed entirely.

The combined effect made the gas token strategy uneconomic, which was the objective.

What remains

Clearing storage still returns gas, within the cap. Contracts that genuinely clean up after themselves still benefit.

The pricing still does not fully reflect the perpetual cost of storage, which is why state growth remains an unsolved problem.

The deeper issue

A one-time fee for permanent storage is a mismatch. The writer pays once; every node pays forever.

Proposals to address it include state expiry, where untouched entries become inactive and must be revived with a proof, and statelessness, where nodes verify using witnesses rather than holding state.

Neither is deployed at scale on a major network, and the engineering for both is years of work.

Why this is a good case study

It demonstrates a pattern that recurs throughout protocol design: a mechanism introduced for one reason creates an economic incentive nobody anticipated, and the incentive is exploited at scale within months.

Every parameter in a public protocol is a price, and every price creates a market. Designers who do not think in those terms produce mechanisms that get used in ways they did not intend.

The user-facing relevance

Almost none directly. The reason to understand it is that it explains why contract gas costs are sometimes surprising, and why the same operation can cost different amounts depending on whether it writes new storage or updates existing storage.

The confirmation screen shows the estimate before signing, which is where that surprise is visible and avoidable.

# Corrections and technical nitpicks are welcome. Send them over. They get published with the fix.

gasstorageeconomics

# related notes