Resources common to all Wanchain implementations
Succeeds the old wanchain/common library.
npm install wanchainjs-common
All parameters can be accessed through the
Common class which can be required through the
main package and instantiated either with just the
chain (e.g. 'mainnet') or the
together with a specific
Here are some simple usage examples:
const Common =// Instantiate with only the chainlet c = 'ropsten'c // 500// Chain and hardfork providedc = 'ropsten' 'byzantium'c // 3000000000000000000// Access genesis data for Ropsten networkchash // 0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d// Get bootstrap nodes for chain/networkc // Array with current nodes
It is encouraged to also explicitly set the
supportedHardforks if the initializing library
only supports a certain range of
let c = 'ropsten' null 'byzantium' 'constantinople'
This will e.g. throw an error when a param is requested for an unsupported hardfork and like this prevents unpredicted behaviour.
See the API documentation for a full list of functions for accessing specific chain and
depending hardfork parameters. There are also additional helper functions like
paramByBlock (topic, name, blockNumber) or
hardforkIsActiveOnBlock (hardfork, blockNumber)
blockNumber based access to parameters.
There are currently parameter changes by the following past and future hardfork by the library supported:
For hardfork-specific parameter access with the
you can use the following
See one of the hardfork files like
byzantium.json in the
for an overview. For consistency, the chain start (
chainstart) is considered an own
The hardfork-specific json files only contain the deltas from
shouldn't be accessed directly until you have a specific reason for it.
Note: The list of
gasPrices and gas price changes on hardforks is consistent
but not complete, so there are currently gas price values missing (PRs welcome!).
- Private/custom chain parameters
The following chain-specific parameters are provided:
genesisblock header values
To get an overview of the different parameters have a look at one of the chain-specifc
mainnet.json in the
If you want to set up a common instance with parameters for a private/custom chain you can pass a
dictionary - conforming to the parameter format described above - with your custom values in
the constructor or the
setChain() method for the
There is no separate config file for bootstrap nodes like in the old
Instead use the
common.bootstrapNodes() function to get nodes for a specific chain/network.
Network-specific genesis files are located in the
Due to the large file sizes genesis states are not directly included in the
but have to be accessed directly, e.g.:
const mainnetGenesisState =
Or by choosing dynamically:
const genesisStates =const mainnetGenesisState = genesisStates'mainnet'const mainnetGenesisState = genesisStatesgenesisStates'names'1 // alternative via chain Id