Overview
Opcode:0x00
Introduced: Frontier (EVM genesis)
STOP halts execution successfully without returning any output data. All state changes are preserved, remaining gas is consumed, and execution terminates with a success status.
This is the simplest termination opcode - equivalent to falling off the end of bytecode or explicitly signaling completion without a return value.
Specification
Stack Input: None Stack Output: None Gas Cost: 0 (execution halted before gas consumption) Operation:Behavior
STOP immediately terminates execution:- Sets execution state to stopped
- Preserves all state changes (storage, logs, balance transfers)
- Returns no output data (empty return buffer)
- Remaining gas is NOT refunded (consumed by transaction)
- Control returns to caller with success status
- No stack items consumed or produced
- No memory access
- No output data
- Cannot be reverted (final state)
Examples
Basic Stop
Constructor Pattern
Function Without Return
Explicit Termination
Gas Cost
Cost: 0 gas STOP is technically free because execution halts immediately. However, the transaction still consumes:- Base transaction gas (21000)
- Gas for executed opcodes before STOP
- Remaining gas is NOT refunded
- STOP: 0 gas (halts execution)
- RETURN: Memory expansion cost
- REVERT: Memory expansion cost + refunds remaining gas
Edge Cases
Empty Stack
Already Stopped
With Output Buffer
Common Usage
Constructor Termination
Every contract constructor ends with STOP (implicit or explicit):Fallback Without Return
State Update Only
Unreachable Code Guard
Implementation
- TypeScript
Testing
Test Coverage
Security
State Finality
STOP makes all state changes final - they cannot be reverted:Gas Griefing
STOP doesn’t refund remaining gas - can be used in gas griefing:- Gas stipend for external calls (2300) prevents this
- Caller controls gas limit
- Only affects caller, not contract state
STOP vs RETURN
STOP:- No output data
- Simpler (no memory access)
- Slightly cheaper (no memory expansion)
- Use for: void functions, constructors, state-only operations
- Returns output data
- Requires memory operations
- Dynamic gas cost
- Use for: view functions, getter methods, function return values
Compiler Behavior
Solidity Implicit STOP
Solidity adds STOP at the end of constructor code:Function Without Return
Unreachable Code Elimination
Compilers eliminate code after STOP:References
- Yellow Paper - Section 9.4.4 (STOP instruction)
- EVM Codes - STOP
- Solidity Docs - Assembly

