@ethereumjs/common / Common
Defined in: common/src/common.ts:49
Common class to access chain and hardfork parameters and to provide a unified and shared view on the network and hardfork state.
Use the createCustomCommon constructor for creating simple custom chain Common objects (more complete custom chain setups can be created via the main constructor).
Use the createCommonFromGethGenesis constructor for creating a Common object from a Geth genesis file.
new Common(
opts):Common
Defined in: common/src/common.ts:66
Common
readonlycustomCrypto:CustomCrypto
Defined in: common/src/common.ts:57
readonlyDEFAULT_HARDFORK:string
Defined in: common/src/common.ts:50
events:
EventEmitter<CommonEvent>
Defined in: common/src/common.ts:64
activeOnBlock(
blockNumber):boolean
Defined in: common/src/common.ts:511
Alias to hardforkIsActiveOnBlock when hardfork is set
BigIntLike
boolean
True if HF is active on block number
bootstrapNodes():
BootstrapNodeConfig[]
Defined in: common/src/common.ts:788
Returns bootstrap nodes for the current chain.
Array of bootstrap node configs
chainId():
bigint
Defined in: common/src/common.ts:812
Returns the Id of current chain
bigint
chain Id
chainName():
string
Defined in: common/src/common.ts:820
Returns the name of current chain
string
chain name (lower case)
consensusAlgorithm():
string
Defined in: common/src/common.ts:861
Returns the concrete consensus implementation algorithm or protocol for the network e.g. "ethash" for "pow" consensus type, "clique" for "poa" consensus type or "casper" for "pos" consensus type.
Note: This value can update along a Hardfork.
string
consensusConfig():
object
Defined in: common/src/common.ts:887
Returns a dictionary with consensus configuration parameters based on the consensus algorithm
Expected returns (parameters must be present in the respective chain JSON files):
ethash: empty object clique: period, epoch casper: empty object
Note: This value can update along a Hardfork.
object
consensusType():
string
Defined in: common/src/common.ts:839
Returns the consensus type of the network Possible values: "pow"|"poa"|"pos"
Note: This value can update along a Hardfork.
string
copy():
Common
Defined in: common/src/common.ts:908
Returns a deep copy of this Common instance.
Common
dnsNetworks():
string[]
Defined in: common/src/common.ts:796
Returns DNS networks for the current chain
string[]
Array of DNS ENR urls
eipBlock(
eip):bigint|null
Defined in: common/src/common.ts:578
Returns the hardfork change block for eip
number
EIP number
bigint | null
Block number or null if unscheduled
eips():
number[]
Defined in: common/src/common.ts:829
Returns the additionally activated EIPs
(by using the eips constructor option)
number[]
List of EIPs
eipTimestamp(
eip):bigint|null
Defined in: common/src/common.ts:596
Returns the scheduled timestamp of the EIP (if scheduled and scheduled by timestamp)
number
EIP number
bigint | null
Scheduled timestamp. If this EIP is unscheduled, or the EIP is scheduled by block number, then it returns null.
forkHash(
hardfork?,genesisHash?):`0x${string}`
Defined in: common/src/common.ts:712
Returns an eth/64 compliant fork hash (EIP-2124)
string
Hardfork name, optional if HF set
Uint8Array<ArrayBufferLike>
Genesis block hash of the network, optional if already defined and not needed to be calculated
`0x${string}`
Fork hash as a hex string
genesis():
GenesisBlockConfig
Defined in: common/src/common.ts:760
Returns the Genesis parameters of the current chain
Genesis dictionary
getBlobGasSchedule():
BpoSchedule
Defined in: common/src/common.ts:459
Returns the blob gas schedule for the current hardfork
The blob gas schedule
getHardforkBy(
opts):string
Defined in: common/src/common.ts:173
Returns the hardfork either based on block number (older HFs) or timestamp (Shanghai upwards).
Block number or timestamp
string
The name of the HF
gteHardfork(
hardfork):boolean
Defined in: common/src/common.ts:541
Alias to hardforkGteHardfork when hardfork is set
string
Hardfork name
boolean
True if hardfork set is greater than hardfork provided
hardfork():
string
Defined in: common/src/common.ts:804
Returns the hardfork set
string
Hardfork name
hardforkBlock(
hardfork?):bigint|null
Defined in: common/src/common.ts:550
Returns the hardfork change block for hardfork provided or set
string
Hardfork name, optional if HF set
bigint | null
Block number or null if unscheduled
hardforkForForkHash(
forkHash):HardforkTransitionConfig|null
Defined in: common/src/common.ts:732
string
Fork hash as a hex string
HardforkTransitionConfig | null
Array with hardfork data (name, block, forkHash)
hardforkGteHardfork(
hardfork1,hardfork2):boolean
Defined in: common/src/common.ts:521
Sequence based check if given or set HF1 is greater than or equal HF2
Hardfork name or null (if set)
string | null
string
Hardfork name
boolean
True if HF1 gte HF2
hardforkIsActiveOnBlock(
hardfork,blockNumber):boolean
Defined in: common/src/common.ts:496
Checks if set or provided hardfork is active on block number
Hardfork name or null (for HF set)
string | null
BigIntLike
boolean
True if HF is active on block number
hardforks():
HardforkTransitionConfig[]
Defined in: common/src/common.ts:768
Returns the hardfork definitions for the current chain.
Array of hardfork transition configs
hardforkTimestamp(
hardfork?):bigint|null
Defined in: common/src/common.ts:564
Returns the timestamp at which a given hardfork is scheduled (if any).
string
Hardfork name, optional if HF set
bigint | null
Timestamp or null if the hardfork is not timestamp-based
isActivatedEIP(
eip):boolean
Defined in: common/src/common.ts:483
Checks if an EIP is activated by either being included in the EIPs manually passed in with the CommonOpts.eips or in a hardfork currently being active
Note: this method only works for EIPs being supported by the CommonOpts.eips constructor option
number
boolean
nextHardforkBlockOrTimestamp(
hardfork?):bigint|null
Defined in: common/src/common.ts:617
Returns the block number or timestamp at which the next hardfork will occur. For pre-merge hardforks, returns the block number. For post-merge hardforks, returns the timestamp. Returns null if there is no next hardfork.
string
Hardfork name, optional if HF set
bigint | null
Block number or timestamp, or null if not available
param(
name):bigint
Defined in: common/src/common.ts:380
Returns a parameter for the current chain setup
If the parameter is present in an EIP, the EIP always takes precedence. Otherwise the parameter is taken from the latest applied HF with a change on the respective parameter.
string
Parameter name (e.g. 'minGasLimit')
bigint
The value requested (throws if not found)
paramByBlock(
name,blockNumber,timestamp?):bigint
Defined in: common/src/common.ts:450
Returns a parameter for the hardfork active on block number or optional provided total difficulty (Merge HF)
string
Parameter name
BigIntLike
Block number
BigIntLike
bigint
The value requested or BigInt(0) if not found
paramByEIP(
name,eip):bigint|undefined
Defined in: common/src/common.ts:430
Returns a parameter corresponding to an EIP
string
Parameter name (e.g. 'minGasLimit' for 'gasConfig' topic)
number
Number of the EIP
bigint | undefined
The value requested (throws if not found)
paramByHardfork(
name,hardfork):bigint
Defined in: common/src/common.ts:396
Returns the parameter corresponding to a hardfork
string
Parameter name (e.g. 'minGasLimit')
string
Hardfork name
bigint
The value requested (throws if not found)
resetParams(
params):void
Defined in: common/src/common.ts:139
Fully resets the internal Common EIP params set with the values provided.
Example Format:
{
1559: {
initialBaseFee: 1000000000,
}
}void
setEIPs(
eips):void
Defined in: common/src/common.ts:279
Sets the active EIPs
number[] = []
void
setForkHashes(
genesisHash):void
Defined in: common/src/common.ts:743
Sets any missing forkHashes on this Common instance.
Uint8Array
The genesis block hash
void
setHardfork(
hardfork):void
Defined in: common/src/common.ts:148
Sets the hardfork to get params for
string
String identifier (e.g. 'byzantium') or Hardfork enum
void
setHardforkBy(
opts):string
Defined in: common/src/common.ts:256
Sets a new hardfork either based on block number (older HFs) or timestamp (Shanghai upwards).
Block number or timestamp
string
The name of the HF set
updateParams(
params):void
Defined in: common/src/common.ts:112
Update the internal Common EIP params set. Existing values will get preserved unless there is a new value for a parameter provided with params.
Example Format:
{
1559: {
initialBaseFee: 1000000000,
}
}void