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: 0x50
Introduced: Frontier (EVM genesis)
POP removes the top item from the stack without using its value. Used to discard unneeded computation results or clean up the stack.
Specification
Stack Input:
Stack Output:
Gas Cost: 2 (GasQuickStep)
Operation:
Behavior
POP discards the top stack item. The value is not returned or used - it simply removes one item from the stack depth.
Key characteristics:
- Requires stack depth ≥ 1
- Does not return the popped value
- Decreases stack depth by 1
- Cannot fail on empty stack (reverts with StackUnderflow)
Examples
Basic Usage
Solidity Compilation
Assembly Usage
Gas Cost
Cost: 2 gas (GasQuickStep)
POP is one of the cheapest stack operations, same tier as:
Cheaper than:
- PUSH1-32 (0x60-0x7f): 3 gas
- DUP1-16 (0x80-0x8f): 3 gas
- SWAP1-16 (0x90-0x9f): 3 gas
Common Usage
Discarding Return Values
Stack Cleanup
Optimizing Storage Reads
Security
Stack Underflow Protection
Double Spending Prevention
Gas Waste
Optimization
Avoid Unnecessary Pushes
Reorder to Minimize POPs
Implementation
Edge Cases
Empty Stack
Single Item Stack
Out of Gas
Maximum Stack Depth
References