@ethereumjs/common / Common
Defined in: common.ts:45
Common class to access chain and hardfork parameters and to provide a unified and shared view on the network and hardfork state.
Use the Common.custom static constructor for creating simple custom chain Common objects (more complete custom chain setups can be created via the main constructor).
new Common(
opts
):Common
Defined in: common.ts:62
Common
readonly
customCrypto:CustomCrypto
Defined in: common.ts:53
readonly
DEFAULT_HARDFORK:string
Defined in: common.ts:46
events:
EventEmitter
<CommonEvent
>
Defined in: common.ts:60
activeOnBlock(
blockNumber
):boolean
Defined in: common.ts:472
Alias to hardforkIsActiveOnBlock when hardfork is set
BigIntLike
boolean
True if HF is active on block number
bootstrapNodes():
BootstrapNodeConfig
[]
Defined in: common.ts:729
Returns bootstrap nodes for the current chain
Dict with bootstrap nodes
chainId():
bigint
Defined in: common.ts:753
Returns the Id of current chain
bigint
chain Id
chainName():
string
Defined in: common.ts:761
Returns the name of current chain
string
chain name (lower case)
consensusAlgorithm():
string
Defined in: common.ts:802
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.ts:828
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.ts:780
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.ts:849
Returns a deep copy of this Common instance.
Common
dnsNetworks():
string
[]
Defined in: common.ts:737
Returns DNS networks for the current chain
string
[]
Array of DNS ENR urls
eipBlock(
eip
):null
|bigint
Defined in: common.ts:535
Returns the hardfork change block for eip
number
EIP number
null
| bigint
Block number or null if unscheduled
eips():
number
[]
Defined in: common.ts:770
Returns the additionally activated EIPs
(by using the eips
constructor option)
number
[]
List of EIPs
eipTimestamp(
eip
):null
|bigint
Defined in: common.ts:553
Returns the scheduled timestamp of the EIP (if scheduled and scheduled by timestamp)
number
EIP number
null
| bigint
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.ts:660
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}`
genesis():
GenesisBlockConfig
Defined in: common.ts:709
Returns the Genesis parameters of the current chain
Genesis dictionary
getHardforkBy(
opts
):string
Defined in: common.ts:169
Returns the hardfork either based on block number (older HFs) or timestamp (Shanghai upwards).
string
The name of the HF
gteHardfork(
hardfork
):boolean
Defined in: common.ts:503
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.ts:745
Returns the hardfork set
string
Hardfork name
hardforkBlock(
hardfork?
):null
|bigint
Defined in: common.ts:512
Returns the hardfork change block for hardfork provided or set
string
Hardfork name, optional if HF set
null
| bigint
Block number or null if unscheduled
hardforkForForkHash(
forkHash
):null
|HardforkTransitionConfig
Defined in: common.ts:680
string
Fork hash as a hex string
null
| HardforkTransitionConfig
Array with hardfork data (name, block, forkHash)
hardforkGteHardfork(
hardfork1
,hardfork2
):boolean
Defined in: common.ts:483
Sequence based check if given or set HF1 is greater than or equal HF2
Hardfork name or null (if set)
null |
string |
string
Hardfork name
boolean
True if HF1 gte HF2
hardforkIsActiveOnBlock(
hardfork
,blockNumber
):boolean
Defined in: common.ts:457
Checks if set or provided hardfork is active on block number
Hardfork name or null (for HF set)
null |
string |
BigIntLike
boolean
True if HF is active on block number
hardforks():
HardforkTransitionConfig
[]
Defined in: common.ts:717
Returns the hardforks for current chain
Array with arrays of hardforks
hardforkTimestamp(
hardfork?
):null
|bigint
Defined in: common.ts:521
string
null
| bigint
isActivatedEIP(
eip
):boolean
Defined in: common.ts:444
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?
):null
|bigint
Defined in: common.ts:571
Returns the change block for the next hardfork after the hardfork provided or set
string
Hardfork name, optional if HF set
null
| bigint
Block timestamp, number or null if not available
param(
name
):bigint
Defined in: common.ts:360
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.ts:430
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
):undefined
|bigint
Defined in: common.ts:410
Returns a parameter corresponding to an EIP
string
Parameter name (e.g. ‘minGasLimit’ for ‘gasConfig’ topic)
number
Number of the EIP
undefined
| bigint
The value requested (throws if not found)
paramByHardfork(
name
,hardfork
):bigint
Defined in: common.ts:376
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.ts:135
Fully resets the internal Common EIP params set with the values provided.
Example Format:
{
1559: {
initialBaseFee: 1000000000,
}
}
void
setEIPs(
eips
):void
Defined in: common.ts:275
Sets the active EIPs
number
[] = []
void
setForkHashes(
genesisHash
):void
Defined in: common.ts:692
Sets any missing forkHashes on the passed-in Common instance
Uint8Array
The genesis block hash
void
setHardfork(
hardfork
):void
Defined in: common.ts:144
Sets the hardfork to get params for
string
String identifier (e.g. ‘byzantium’) or Hardfork enum
void
setHardforkBy(
opts
):string
Defined in: common.ts:252
Sets a new hardfork either based on block number (older HFs) or timestamp (Shanghai upwards).
string
The name of the HF set
updateParams(
params
):void
Defined in: common.ts:108
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