> ## 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.

# Hardfork.isBefore

> Check if hardfork is before a target version (strictly less than)

<Card title="Try it Live" icon="play" href="https://playground.tevm.sh?example=primitives/hardfork.ts">
  Run Hardfork examples in the interactive playground
</Card>

<Tabs />

## Usage Patterns

### Feature Exclusion

Exclude features not yet available:

```typescript theme={null}
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:

```typescript theme={null}
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:

```typescript theme={null}
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:

```typescript theme={null}
import { LONDON } from 'tevm'

LONDON.isBefore(LONDON)  // false - not strictly before itself
```

For "less than or equal", use [lte](/primitives/hardfork/lte) or negate [isAfter](/primitives/hardfork/is-after):

```typescript theme={null}
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](/primitives/hardfork/is-at-least) - Check if greater than or equal
* [isAfter](/primitives/hardfork/is-after) - Check if strictly greater than
* [lt](/primitives/hardfork/lt) - Alias for isBefore (less than)
* [lte](/primitives/hardfork/lte) - Less than or equal
