Skip to main content

Try it Live

Run Hardfork examples in the interactive playground

    Operator-Style API

    gte mimics the >= operator for clearer code:
    import { CANCUN, LONDON } from 'tevm'
    
    // Operator-style (reads like >= operator)
    if (CANCUN.gte(LONDON)) {
      // ...
    }
    
    // Equivalent semantic form
    if (CANCUN.isAtLeast(LONDON)) {
      // ...
    }
    

    Usage Patterns

    Feature Gating

    import { Hardfork, LONDON } from 'tevm'
    
    const fork = Hardfork(config.hardfork)
    
    if (fork.gte(LONDON)) {
      // EIP-1559 available
    }
    

    Network Configuration

    import { Hardfork, SHANGHAI } from 'tevm'
    
    function validateVersion(fork: BrandedHardfork) {
      if (!fork.gte(SHANGHAI)) {
        throw new Error("Requires Shanghai or later")
      }
    }
    

    Chronological Ordering

    Uses chronological deployment order:
    FRONTIER (0) < HOMESTEAD (1) < ... < CANCUN (16) < PRAGUE (17)
    

    Performance

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

    See Also

    • isAtLeast - Semantic equivalent
    • gt - Strictly greater than
    • lte - Less than or equal