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: 0x39
Introduced: Frontier (EVM genesis)
CODECOPY copies a specified range of the currently executing code to memory.
Specification
Stack Input:
Stack Output:
Gas Cost: 3 + memory expansion + (length / 32) * 3 (rounded up)
Behavior
Copies length bytes from executing code at offset to memory at destOffset. Zero-pads if code bounds exceeded.
Examples
Copy Runtime Code
CREATE2 Factory
Gas Cost
Base: 3 gas
Memory expansion: Variable
Copy cost: 3 gas per 32-byte word
Implementation
References