Skip to main content

Try it Live

Run Hardfork examples in the interactive playground
New to hardforks? Read the Fundamentals guide for an introduction to Ethereum protocol upgrades, activation mechanisms, and feature timeline.
Ethereum hardforks are protocol upgrades that change EVM behavior, gas costs, or add features. This module provides type-safe hardfork identification, version comparison, and feature detection.

Hardfork Type

Hardforks are represented as branded strings:

Core Operations

Version Comparison:
Feature Detection:
String Parsing:

API Methods

Constructors

Comparison Methods

Feature Detection

Collection Operations

  • allNames() - Get all hardfork names (chronological order)
  • allIds() - Get all hardfork IDs (chronological order)
  • range(start, end) - Get hardforks between two versions (inclusive)
  • min(forks) - Find earliest hardfork in array
  • max(forks) - Find latest hardfork in array

Constants

All hardfork constants available:

Quick Examples

Version Gating

Network Configuration

Upgrade Path

Additional Documentation

Tree-Shaking

Import only what you need for optimal bundle size:
Each comparison method, feature detector, and utility is independently exported. Import only the hardfork detection logic your application needs.

Performance

All operations are O(1):
  • Comparisons: Simple array index lookups (~10-20ns)
  • Feature detection: Single comparison + branch (~15-30ns)
  • String parsing: Hash table lookup (~50-100ns)
  • String conversion: Array index (~20-40ns)
No WASM implementation - pure TypeScript is optimal for these operations. WASM overhead (1-2μs) would make operations 10-100x slower.

Implementation

  • Type: Branded string (string & { __tag: "Hardfork" })
  • Storage: Chronologically ordered array
  • Comparison: Array index comparison
  • Parsing: Hash table with lowercase keys
  • Aliases: “paris” → MERGE, “constantinoplefix” → PETERSBURG

Best Practices

  1. Use feature detection over version checks
  2. Validate user input
  3. Normalize for storage
  4. Use convenience forms for readability
  • Hardfork (Effect) - Effect.ts integration with Schema validation
  • Network - Chain ID and network configuration
  • Transaction - Transaction type selection based on hardfork
  • Block - Block structure changes per hardfork