Try it Live
Run Hardfork examples in the interactive playground
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Check if hardfork is at least a target version (greater than or equal)
FRONTIER (0) < HOMESTEAD (1) < DAO (2) < ... < CANCUN (16) < PRAGUE (17)
import { Hardfork, LONDON } from 'tevm'
const fork = Hardfork(config.hardfork)
if (!fork.isAtLeast(LONDON)) {
throw new Error("EIP-1559 requires London or later")
}
// Safe to use EIP-1559 features
import { Hardfork, SHANGHAI } from 'tevm'
function validateNetworkConfig(clientFork: BrandedHardfork, networkFork: BrandedHardfork) {
if (!clientFork.isAtLeast(networkFork)) {
throw new Error(
`Client must support at least ${Hardfork.toString(networkFork)}, ` +
`but only supports ${Hardfork.toString(clientFork)}`
)
}
}
validateNetworkConfig(SHANGHAI, LONDON) // OK
validateNetworkConfig(LONDON, SHANGHAI) // Throws error
import { Hardfork, LONDON, CANCUN } from 'tevm'
function selectTxType(fork: BrandedHardfork): number {
if (fork.isAtLeast(CANCUN)) {
return 3 // Blob transaction
}
if (fork.isAtLeast(LONDON)) {
return 2 // EIP-1559
}
return 0 // Legacy
}
Was this page helpful?
