Documentation Index
Fetch the complete documentation index at: https://voltaire.tevm.sh/llms.txt
Use this file to discover all available pages before exploring further.
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)
- Reentrancy guards (set/clear flags with minimal gas)
- Callback context passing within transaction
- Temporary counters and flags
- Efficient multi-call coordination
Specification
Stack Input:Behavior
TSTORE modifies an account’s transient storage and guarantees cleanup:- Check static call context - Return WriteProtection error if in static context
- Pop key and value from stack
- Consume 100 gas (fixed, no refunds)
- Write to transient storage via host
- Auto-clear on transaction end (no cleanup needed)
- 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)| Operation | Cost | Notes |
|---|---|---|
| TSTORE | 100 | Fixed, no refunds |
| SSTORE set | 20000 | New entry, 200x more |
| SSTORE update | 5000 | Existing entry, 50x more |
| SSTORE clear | 5000 + refund | With 4800 refund |
| MSTORE | 3 | 33x cheaper but memory-only |
Edge Cases
Max Uint256 Value
Zero Value Write
Overwrite
Hardfork Unavailable
Common Usage
Reentrancy Guard Implementation
Callback Context
Temporary Counter
State Accumulation
Implementation
- TypeScript
Testing
Test Coverage
Security
Write Protection in Static Calls
TSTORE correctly prevents all writes inSTATICCALL 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)
| Approach | Cost | Cleanup | Notes |
|---|---|---|---|
| TSTORE guard | 300 gas | Auto | Recommended (EIP-1153) |
| SSTORE guard | 20000+ | Manual | Expensive, complex |
| OpenZeppelin | 3500+ gas | Manual | Library overhead |
| No guard | 0 gas | N/A | Vulnerable to reentrancy |

