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: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:- PUSH0 (0x5f): 2 gas
- 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
- TypeScript
Edge Cases
Empty Stack
Single Item Stack
Out of Gas
Maximum Stack Depth
References
- Yellow Paper - Section 9.1 (Stack Operations)
- EVM Codes - POP
- Solidity Assembly - pop

