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

Opcode: 0x3f Introduced: Constantinople (EIP-1052) EXTCODEHASH returns the keccak256 hash of an account’s bytecode, or 0 for empty accounts.

Specification

Stack Input:
Stack Output:
Gas Cost: Variable (hardfork-dependent)
  • Constantinople: 400 gas
  • Istanbul (EIP-1884): 700 gas
  • Berlin (EIP-2929): 2600 gas (cold) / 100 gas (warm)

Behavior

Returns keccak256(account.code) for contracts, or 0 for:
  • EOAs (externally owned accounts)
  • Non-existent accounts
  • Empty code (code.length == 0)
More efficient than EXTCODESIZE + EXTCODECOPY + KECCAK256 for code verification.

Examples

Basic Usage

Implementation Verification

Factory Pattern

Gas Cost

Historical evolution: Comparison to alternatives:

Common Usage

Contract Identity Check

Minimal Proxy Detection

Upgrade Validation

Security

Empty Account Returns 0

Constructor Bypass

Like EXTCODESIZE, returns 0 during contract construction:

Code Immutability Check

Implementation

Edge Cases

EOA Hash

Non-Existent Account

Empty Code Contract

Some contracts may have zero-length code (rare):

References