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: 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:
  1. Sets execution state to stopped
  2. Preserves all state changes (storage, logs, balance transfers)
  3. Returns no output data (empty return buffer)
  4. Remaining gas is NOT refunded (consumed by transaction)
  5. Control returns to caller with success status
Key Characteristics:
  • No stack items consumed or produced
  • No memory access
  • No output data
  • Cannot be reverted (final state)

Examples

Basic Stop

Constructor Pattern

Compiled bytecode (simplified):

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
Gas Consumption Example:
Comparison:
  • 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):
Bytecode pattern:

Fallback Without Return

State Update Only

Compiles to:

Unreachable Code Guard

Implementation

Testing

Test Coverage

Security

State Finality

STOP makes all state changes final - they cannot be reverted:
Better approach:

Gas Griefing

STOP doesn’t refund remaining gas - can be used in gas griefing:
Not a vulnerability in practice:
  • 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
RETURN:
  • 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:
Bytecode structure:

Function Without Return

Compiles to:

Unreachable Code Elimination

Compilers eliminate code after STOP:
Optimized bytecode:

References