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: 0x3e
Introduced: Byzantium (EIP-211)
RETURNDATACOPY copies return data from the most recent external call into memory.
Specification
Stack Input:
Stack Output:
Gas Cost: 3 + memory expansion + (length / 32) * 3
Behavior
Copies length 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 word
Common Usage
Efficient Proxy
Security
Out-of-Bounds Reverts
Unlike CALLDATACOPY/CODECOPY, RETURNDATACOPY reverts on out-of-bounds:
Safe Pattern
Implementation
Edge Cases
Empty Return Data
Partial Copy
References