Common class to access chain and hardfork parameters
Common
- _chooseHardfork
- _getHardfork
- _isSupportedHardfork
- activeHardfork
- activeHardforks
- activeOnBlock
- bootstrapNodes
- chainId
- chainName
- consensus
- finality
- genesis
- gteHardfork
- hardfork
- hardforkBlock
- hardforkGteHardfork
- hardforkIsActiveOnBlock
- hardforkIsActiveOnChain
- hardforks
- isHardforkBlock
- networkId
- param
- paramByBlock
- setChain
- setHardfork
- forCustomChain
⊕ new Common(chain: string
| number
| object
, hardfork?: string
| null
, supportedHardforks?: Array
<string
>): Common
Defined in index.ts:62
constructor:
Parameters:
Name | Type | Description |
---|---|---|
chain | string | number | object |
String ('mainnet') or Number (1) chain |
Optional hardfork |
string | null |
String identifier ('byzantium') for hardfork (optional) |
Optional supportedHardforks |
Array <string > |
Limit parameter returns to the given hardforks (optional) |
Returns: Common
▸ _chooseHardfork(hardfork?: string
| null
, onlySupported?: undefined
| false
| true
): string
Defined in index.ts:131
Internal helper function to choose between hardfork set and hardfork provided as param
Parameters:
Name | Type | Description |
---|---|---|
Optional hardfork |
string | null |
Hardfork given to function as a parameter |
Optional onlySupported |
undefined | false | true |
Returns: string
Hardfork chosen to be used
▸ _getHardfork(hardfork: string
): any
Defined in index.ts:150
Internal helper function, returns the params for the given hardfork for the chain set
Parameters:
Name | Type | Description |
---|---|---|
hardfork | string |
Hardfork name |
Returns: any
Dictionary with hardfork params
▸ _isSupportedHardfork(hardfork: string
| null
): boolean
Defined in index.ts:163
Internal helper function to check if a hardfork is set to be supported by the library
Parameters:
Name | Type | Description |
---|---|---|
hardfork | string | null |
Hardfork name |
Returns: boolean
True if hardfork is supported
▸ activeHardfork(blockNumber?: number
| null
, opts?: hardforkOptions): string
Defined in index.ts:327
Returns the latest active hardfork name for chain or block or throws if unavailable
Parameters:
Name | Type | Description |
---|---|---|
Optional blockNumber |
number | null |
up to block if provided, otherwise for the whole chain |
Optional opts |
hardforkOptions | Hardfork options (onlyActive unused) |
Returns: string
Hardfork name
▸ activeHardforks(blockNumber?: number
| null
, opts?: hardforkOptions): Array
<any
>
Defined in index.ts:307
Returns the active hardfork switches for the current chain
Parameters:
Name | Type | Description |
---|---|---|
Optional blockNumber |
number | null |
up to block if provided, otherwise for the whole chain |
Optional opts |
hardforkOptions | Hardfork options (onlyActive unused) |
Returns: Array
<any
>
Array with hardfork arrays
▸ activeOnBlock(blockNumber: number
, opts?: hardforkOptions): boolean
Defined in index.ts:237
Alias to hardforkIsActiveOnBlock when hardfork is set
Parameters:
Name | Type | Description |
---|---|---|
blockNumber | number |
- |
Optional opts |
hardforkOptions | Hardfork options (onlyActive unused) |
Returns: boolean
True if HF is active on block number
▸ bootstrapNodes(): any
Defined in index.ts:402
Returns bootstrap nodes for the current chain
Returns: any
Dict with bootstrap nodes
▸ chainId(): number
Defined in index.ts:418
Returns the Id of current chain
Returns: number
chain Id
▸ chainName(): string
Defined in index.ts:426
Returns the name of current chain
Returns: string
chain name (lower case)
▸ consensus(hardfork?: undefined
| string
): string
Defined in index.ts:367
Provide the consensus type for the hardfork set or provided as param
Parameters:
Name | Type | Description |
---|---|---|
Optional hardfork |
undefined | string |
Hardfork name, optional if hardfork set |
Returns: string
Consensus type (e.g. 'pow', 'poa')
▸ finality(hardfork?: undefined
| string
): string
Defined in index.ts:377
Provide the finality type for the hardfork set or provided as param
Parameters:
Name | Type | Description |
---|---|---|
Optional hardfork |
undefined | string |
Hardfork name, optional if hardfork set |
Returns: string
Finality type (e.g. 'pos', null of no finality)
▸ genesis(): any
Defined in index.ts:386
Returns the Genesis parameters of current chain
Returns: any
Genesis dictionary
▸ gteHardfork(hardfork: string
, opts?: hardforkOptions): boolean
Defined in index.ts:281
Alias to hardforkGteHardfork when hardfork is set
Parameters:
Name | Type | Description |
---|---|---|
hardfork | string |
Hardfork name |
Optional opts |
hardforkOptions | Hardfork options |
Returns: boolean
True if hardfork set is greater than hardfork provided
▸ hardfork(): string
| null
Defined in index.ts:410
Returns the hardfork set
Returns: string
| null
Hardfork name
▸ hardforkBlock(hardfork?: undefined
| string
): number
Defined in index.ts:342
Returns the hardfork change block for hardfork provided or set
Parameters:
Name | Type | Description |
---|---|---|
Optional hardfork |
undefined | string |
Hardfork name, optional if HF set |
Returns: number
Block number
▸ hardforkGteHardfork(hardfork1: string
| null
, hardfork2: string
, opts?: hardforkOptions): boolean
Defined in index.ts:248
Sequence based check if given or set HF1 is greater than or equal HF2
Parameters:
Name | Type | Description |
---|---|---|
hardfork1 | string | null |
Hardfork name or null (if set) |
hardfork2 | string |
Hardfork name |
Optional opts |
hardforkOptions | Hardfork options |
Returns: boolean
True if HF1 gte HF2
▸ hardforkIsActiveOnBlock(hardfork: string
| null
, blockNumber: number
, opts?: hardforkOptions): boolean
Defined in index.ts:218
Checks if set or provided hardfork is active on block number
Parameters:
Name | Type | Description |
---|---|---|
hardfork | string | null |
Hardfork name or null (for HF set) |
blockNumber | number |
- |
Optional opts |
hardforkOptions | Hardfork options (onlyActive unused) |
Returns: boolean
True if HF is active on block number
▸ hardforkIsActiveOnChain(hardfork?: string
| null
, opts?: hardforkOptions): boolean
Defined in index.ts:291
Checks if given or set hardfork is active on the chain
Parameters:
Name | Type | Description |
---|---|---|
Optional hardfork |
string | null |
Hardfork name, optional if HF set |
Optional opts |
hardforkOptions | Hardfork options (onlyActive unused) |
Returns: boolean
True if hardfork is active on the chain
▸ hardforks(): any
Defined in index.ts:394
Returns the hardforks for current chain
Returns: any
Array with arrays of hardforks
▸ isHardforkBlock(blockNumber: number
, hardfork?: undefined
| string
): boolean
Defined in index.ts:353
True if block number provided is the hardfork (given or set) change block of the current chain
Parameters:
Name | Type | Description |
---|---|---|
blockNumber | number |
Number of the block to check |
Optional hardfork |
undefined | string |
Hardfork name, optional if HF set |
Returns: boolean
True if blockNumber is HF block
▸ networkId(): number
Defined in index.ts:434
Returns the Id of current network
Returns: number
network Id
▸ param(topic: string
, name: string
, hardfork?: undefined
| string
): any
Defined in index.ts:180
Returns the parameter corresponding to a hardfork
Parameters:
Name | Type | Description |
---|---|---|
topic | string |
Parameter topic ('gasConfig', 'gasPrices', 'vm', 'pow', 'casper', 'sharding') |
name | string |
Parameter name (e.g. 'minGasLimit' for 'gasConfig' topic) |
Optional hardfork |
undefined | string |
Hardfork name, optional if hardfork set |
Returns: any
▸ paramByBlock(topic: string
, name: string
, blockNumber: number
): any
Defined in index.ts:205
Returns a parameter for the hardfork active on block number
Parameters:
Name | Type | Description |
---|---|---|
topic | string |
Parameter topic |
name | string |
Parameter name |
blockNumber | number |
Block number |
Returns: any
▸ setChain(chain: string
| number
| object
): any
Defined in index.ts:89
Sets the chain
Parameters:
Name | Type | Description |
---|---|---|
chain | string | number | object |
String ('mainnet') or Number (1) chain representation. Or, a Dictionary of chain parameters for a private network. |
Returns: any
The dictionary with parameters set as chain
▸ setHardfork(hardfork: string
| null
): void
Defined in index.ts:110
Sets the hardfork to get params for
Parameters:
Name | Type | Description |
---|---|---|
hardfork | string | null |
String identifier ('byzantium') |
Returns: void
▸ forCustomChain(baseChain: string
| number
, customChainParams: Partial
<Chain>, hardfork?: string
| null
, supportedHardforks?: Array
<string
>): Common
Defined in index.ts:30
Creates a Common object for a custom chain, based on a standard one. It uses all the Chain params from [[baseChain]] except the ones overridden in [[customChainParams]].
Parameters:
Name | Type | Description |
---|---|---|
baseChain | string | number |
The name (`mainnet`) or id (`1`) of a standard chain used to base the custom chain params on. |
customChainParams | Partial <Chain> |
The custom parameters of the chain. |
Optional hardfork |
string | null |
String identifier ('byzantium') for hardfork (optional) |
Optional supportedHardforks |
Array <string > |
Limit parameter returns to the given hardforks (optional) |
Returns: Common