Skip to main content
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

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: 15 gas
  • Per-word cost: 3 gas per 32-byte word
  • Partial words round up
Examples:
  • 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:
  1. Efficient memory operations: Copying data via precompile avoids expensive EVM opcodes
  2. Gas accounting: Provides predictable gas cost for data operations
  3. Testing: Validates precompile calling mechanism
  4. Historical: Part of original Ethereum design, maintained for compatibility

Comparison with Other Copy Operations

OperationBase GasPer-Word GasUse Case
IDENTITY153General data copy
CALLDATACOPY33Calldata to memory
CODECOPY33Code to memory
MCOPY (EIP-5656)33Memory to memory
Identity has higher base cost but same per-word cost. Use MCOPY (if available) for memory-to-memory copies.

Test Vectors

References

Specifications