createCommon
createCommon(
options):object
Common is the main representation of chain specific configuration for tevm clients.
createCommon creates a typesafe ethereumjs Common object used by the EVM to access chain and hardfork parameters and to provide a unified and shared view on the network and hardfork state. Tevm common extends the viem chain interface
Parameters
• options: CommonOptions
Returns
object
blockExplorers?
optionalblockExplorers:object
Collection of block explorers
Index Signature
[key: string]: ChainBlockExplorer
blockExplorers.default
blockExplorers.default:
ChainBlockExplorer
contracts?
optionalcontracts:object
Collection of contracts
contracts.ensRegistry?
optionalcontracts.ensRegistry:ChainContract
contracts.ensUniversalResolver?
optionalcontracts.ensUniversalResolver:ChainContract
contracts.multicall3?
optionalcontracts.multicall3:ChainContract
copy()
copy: () => { blockExplorers?: { [key: string]: ChainBlockExplorer; default: ChainBlockExplorer; } | undefined; contracts?: { [x: string]: ChainContract | { …; } | undefined; ensRegistry?: ChainContract | undefined; ensUniversalResolver?: ChainContract | undefined; multicall3?: ChainContract | undefined; } | undefined; … 11…
Returns
{ blockExplorers?: { [key: string]: ChainBlockExplorer; default: ChainBlockExplorer; } | undefined; contracts?: { [x: string]: ChainContract | { …; } | undefined; ensRegistry?: ChainContract | undefined; ensUniversalResolver?: ChainContract | undefined; multicall3?: ChainContract | undefined; } | undefined; … 11…
custom?
optionalcustom:Record<string,unknown>
Custom chain data.
ethjsCommon
ethjsCommon:
Common
fees?
optionalfees:ChainFees<undefined|ChainFormatters>
Modifies how fees are derived.
formatters?
optionalformatters:ChainFormatters
Modifies how data is formatted and typed (e.g. blocks and transactions)
id
id:
number
ID in number form
name
name:
string
Human-readable name
nativeCurrency
nativeCurrency:
ChainNativeCurrency
Currency used by chain
rpcUrls
rpcUrls:
object
Collection of RPC endpoints
Index Signature
[key: string]: ChainRpcUrls
rpcUrls.default
rpcUrls.default:
ChainRpcUrls
serializers?
optionalserializers:ChainSerializers<undefined|ChainFormatters,TransactionSerializable>
Modifies how data is serialized (e.g. transactions).
sourceId?
optionalsourceId:number
Source Chain ID (ie. the L1 chain)
testnet?
optionaltestnet:boolean
Flag for test networks
Throws
only if invalid params are passed
Examples
import { createCommon } from 'tevm/common'
const common = createCommon({ customCrypto: {}, loggingLevel: 'debug', hardfork: 'london', eips: [420], id: 69, name: 'MyChain', ...})Since common are stateful consider copying it before using it
import { createCommon } from 'tevm/common'const common = createCommon({ ... })
const commonCopy = common.copy()To use with ethereumjs use the ethjsCommon property
import { VM } from '@ethereumjs/vm'import { createMemoryClient } from 'tevm'
const common = createCommon({ ... })
const vm = new VM({ common: common.ethjsCommon,})