Overview
Address:0x0000000000000000000000000000000000000004
Introduced: Frontier
The Identity precompile is the simplest precompile - it returns the input data unchanged. While this may seem trivial, it serves important purposes for data copying, memory operations, and gas accounting in the EVM.
Gas Cost
Formula:15 + 3 * ceil(input_length / 32)
- Base cost:
15gas - Per-word cost:
3gas per 32-byte word - Partial words round up
- 0 bytes: 15 gas
- 32 bytes: 18 gas (15 + 3*1)
- 33 bytes: 21 gas (15 + 3*2)
- 64 bytes: 21 gas (15 + 3*2)
Input Format
Accepts arbitrary-length byte array. No restrictions on input size or content.Output Format
Identical to input - returns input bytes unchanged.Usage Example
Error Conditions
- Out of gas (insufficient for 15 + 3 * ceil(len/32))
Use Cases
- Data copying: Efficient way to copy data between memory locations
- Gas metering: Test gas consumption for data operations
- Calldata to memory: Copy calldata to memory efficiently
- Proxy contracts: Forward data without modification
- Testing: Validate precompile execution mechanics
Implementation Details
- Zig: Simple allocate + copy operation using allocator.dupe
- TypeScript: Creates new Uint8Array copy of input
- Integration: Standalone, no dependencies
- Optimization: Most efficient data copy operation in EVM
Performance Characteristics
The Identity precompile is the cheapest way to copy data in the EVM:- Base cost: 15 gas
- Per-byte cost: ~0.09375 gas/byte
- More efficient than CODECOPY (3 gas/word + memory expansion)
- Cheaper than manual byte-by-byte copying
Why Does Identity Exist?
While it seems trivial, Identity serves several purposes:- Efficient memory operations: Copying data via precompile avoids expensive EVM opcodes
- Gas accounting: Provides predictable gas cost for data operations
- Testing: Validates precompile calling mechanism
- Historical: Part of original Ethereum design, maintained for compatibility
Comparison with Other Copy Operations
| Operation | Base Gas | Per-Word Gas | Use Case |
|---|---|---|---|
| IDENTITY | 15 | 3 | General data copy |
| CALLDATACOPY | 3 | 3 | Calldata to memory |
| CODECOPY | 3 | 3 | Code to memory |
| MCOPY (EIP-5656) | 3 | 3 | Memory to memory |
Test Vectors
References
Specifications
- Yellow Paper - Appendix E (Precompiled Contracts)
- EIP-5656: MCOPY Opcode

