Skip to main content

Documentation Index

Fetch the complete documentation index at: https://voltaire.tevm.sh/llms.txt

Use this file to discover all available pages before exploring further.

Try it Live

Run Hardfork examples in the interactive playground

    Usage Patterns

    Feature Exclusion

    Exclude features not yet available:
    import { Hardfork, LONDON } from 'tevm'
    
    const fork = Hardfork(config.hardfork)
    
    if (fork.isBefore(LONDON)) {
      // Use legacy transaction format (no EIP-1559)
      return {
        type: 0,
        gasPrice: calculateGasPrice()
      }
    }
    
    // Use EIP-1559 format
    return {
      type: 2,
      maxFeePerGas,
      maxPriorityFeePerGas
    }
    

    Network Configuration

    Check for pre-feature versions:
    import { Hardfork, SHANGHAI } from 'tevm'
    
    function checkPUSH0Support(fork: BrandedHardfork) {
      if (fork.isBefore(SHANGHAI)) {
        console.warn("PUSH0 opcode not available before Shanghai")
        return false
      }
      return true
    }
    

    Validation

    Validate against breaking changes:
    import { Hardfork, MERGE } from 'tevm'
    
    function validateMiningConfig(fork: BrandedHardfork, config: MiningConfig) {
      if (!fork.isBefore(MERGE) && config.mining) {
        throw new Error("Mining not supported after Merge (Proof of Stake)")
      }
    }
    

    Chronological Ordering

    Uses chronological deployment order:
    BERLIN (10) < LONDON (11) < MERGE (14) < SHANGHAI (15) < CANCUN (16)
    

    Strict Inequality

    Important: isBefore returns false when versions are equal:
    import { LONDON } from 'tevm'
    
    LONDON.isBefore(LONDON)  // false - not strictly before itself
    
    For “less than or equal”, use lte or negate isAfter:
    import { LONDON, CANCUN } from 'tevm'
    
    // Less than or equal
    LONDON.lte(LONDON)           // true
    !LONDON.isAfter(LONDON)      // true
    
    // Strictly less than
    LONDON.isBefore(LONDON)      // false
    LONDON.isBefore(CANCUN)      // true
    

    Performance

    Time Complexity: O(1) - Array index comparison Typical Time: ~10-20ns per call

    See Also

    • isAtLeast - Check if greater than or equal
    • isAfter - Check if strictly greater than
    • lt - Alias for isBefore (less than)
    • lte - Less than or equal