Skip to main content
This page is a placeholder. All examples on this page are currently AI-generated and are not correct. This documentation will be completed in the future with accurate, tested examples.

Overview

Opcode: 0x5d Introduced: Cancun (EIP-1153) TSTORE writes a 256-bit value to transient storage—a per-transaction key-value store that is automatically cleared when the transaction ends. Unlike persistent storage (SSTORE), transient storage:
  • Costs only 100 gas (fixed, no complex gas metering)
  • Is not persisted to blockchain state
  • Cannot be read by external calls (isolated per transaction)
  • Clears automatically at end of transaction
  • Cannot be called in static call context (like SSTORE)
Primary use cases:
  • Reentrancy guards (set/clear flags with minimal gas)
  • Callback context passing within transaction
  • Temporary counters and flags
  • Efficient multi-call coordination

Specification

Stack Input:
Stack Output:
Gas Cost: 100 (fixed, EIP-1153) Hardfork: Cancun+ (unavailable on earlier hardforks) Operation:

Behavior

TSTORE modifies an account’s transient storage and guarantees cleanup:
  1. Check static call context - Return WriteProtection error if in static context
  2. Pop key and value from stack
  3. Consume 100 gas (fixed, no refunds)
  4. Write to transient storage via host
  5. Auto-clear on transaction end (no cleanup needed)
  6. Increment PC

Transient Storage Scope

Transient storage is scoped to:
  • Per contract: Each contract has separate transient storage
  • Per transaction: Automatically cleared when transaction completes
  • Not persisted: Does not affect blockchain state
  • Not observable: External calls cannot access (isolated per call frame)
  • Static call protected: Cannot write in static context

Write Protection

TSTORE rejects writes in static call context (like SSTORE):

Examples

Basic Transient Write

Reentrancy Guard Lock

Guard Unlock

Multiple Values

Static Call Protection

Insufficient Gas

Stack Underflow

Gas Cost

Fixed Cost: 100 gas (always) Comparison:
TSTORE provides an efficient middle ground for temporary state.

Edge Cases

Max Uint256 Value

Zero Value Write

Overwrite

Hardfork Unavailable

Common Usage

Reentrancy Guard Implementation

Gas savings: 300 gas for guard (3 × TSTORE/TLOAD) vs 20000+ for persistent storage guard.

Callback Context

Temporary Counter

State Accumulation

Implementation

Testing

Test Coverage

Security

Write Protection in Static Calls

TSTORE correctly prevents all writes in STATICCALL context:

Reentrancy Guard Guarantees

Transient storage guards cannot be bypassed:

No State Leakage

Unlike persistent storage, transient storage doesn’t leak state:

Isolation Guarantees

Transient storage is strictly isolated:

Benchmarks

Storage write costs:
  • TSTORE: 100 gas (fixed)
  • SSTORE set: 20000 gas (200x more)
  • SSTORE update: 5000 gas (50x more)
  • MSTORE: 3 gas (33x cheaper but memory-only)
Reentrancy guard comparison:

References