Overview
Opcode:0x3e
Introduced: Byzantium (EIP-211)
RETURNDATACOPY copies return data from the most recent external call into memory.
Specification
Stack Input:Behavior
Copieslength bytes from return data at offset to memory at destOffset. Reverts if offset + length exceeds return data size.
Key difference from other copy opcodes:
- Does NOT zero-pad - reverts on out-of-bounds access
- Strict bounds checking prevents reading beyond return data
Examples
Basic Usage
Proxy Forwarding
Error Bubbling
Gas Cost
Base: 3 gas Memory expansion: Variable Copy cost: 3 gas per 32-byte wordCommon Usage
Efficient Proxy
Security
Out-of-Bounds Reverts
Unlike CALLDATACOPY/CODECOPY, RETURNDATACOPY reverts on out-of-bounds:Safe Pattern
Implementation
- TypeScript
Edge Cases
Empty Return Data
Partial Copy
References
- EIP-211 - RETURNDATASIZE and RETURNDATACOPY opcodes
- EVM Codes - RETURNDATACOPY
- Yellow Paper - Byzantium changes

