@ethereumjs/blockchain / BlockchainOptions
Defined in: types.ts:143
This are the options that the Blockchain constructor can receive.
optional
common:Common
Defined in: types.ts:150
Specify the chain and hardfork by passing a Common instance.
If not provided this defaults to chain mainnet
and hardfork chainstart
optional
consensusDict:ConsensusDict
Defined in: types.ts:211
Optional dictionary with consensus objects (adhering to the Consensus interface) if consensus validation is wished for certain consensus algorithms.
Since consensus validation moved to the Ethereum consensus layer with Proof-of-Stake
consensus is not validated by default. For ConsensusAlgorithm.Ethash
and
ConsensusAlgorithm.Clique
consensus validation can be activated by passing in the
respective consensus validation objects EthashConsensus
or CliqueConsensus
.
import { CliqueConsensus, createBlockchain } from '@ethereumjs/blockchain'
import type { ConsensusDict } from '@ethereumjs/blockchain'
const consensusDict: ConsensusDict = {}
consensusDict[ConsensusAlgorithm.Clique] = new CliqueConsensus()
const blockchain = await createBlockchain({ common, consensusDict })
Additionally it is possible to provide a fully custom consensus implementation.
Note that this needs a custom Common
object passed to the blockchain where
the ConsensusAlgorithm
string matches the string used here.
optional
db:DB
<string
|number
|Uint8Array
<ArrayBufferLike
>,string
|Uint8Array
<ArrayBufferLike
> |DBObject
>
Defined in: types.ts:167
Database to store blocks and metadata.
Can be any database implementation that adheres to the DB
interface
optional
genesisBlock:Block
Defined in: types.ts:102
The blockchain only initializes successfully if it has a genesis block. If
there is no block available in the DB and a genesisBlock
is provided,
then the provided genesisBlock
will be used as genesis. If no block is
present in the DB and no block is provided, then the genesis block as
provided from the common
will be used.
optional
genesisState:GenesisState
Defined in: types.ts:128
If you are using a custom chain Common, pass the genesis state.
Pattern 1 (with genesis state see GenesisState for format):
{
'0x0...01': '0x100', // For EoA
}
Pattern 2 (with complex genesis state, containing contract accounts and storage). Note that in AccountState there are two accepted types. This allows to easily insert accounts in the genesis state:
A complex genesis state with Contract and EoA states would have the following format:
{
'0x0...01': '0x100', // For EoA
'0x0...02': ['0x1', '0xRUNTIME_BYTECODE', [[storageKey1, storageValue1], [storageKey2, storageValue2]]] // For contracts
}
optional
genesisStateRoot:Uint8Array
<ArrayBufferLike
>
Defined in: types.ts:133
State root of the genesis state
GenesisOptions
.genesisStateRoot
optional
hardforkByHeadBlockNumber:boolean
Defined in: types.ts:161
Set the HF to the fork determined by the head block and update on head updates.
Note: for HFs where the transition is also determined by a total difficulty threshold (merge HF) the calculated TD is additionally taken into account for HF determination.
Default: false
(HF is set to whatever default HF is set by the Common instance)
optional
validateBlocks:boolean
Defined in: types.ts:175
This flag indicates if protocol-given consistency checks on block headers and included uncles and transactions should be performed, see Block#validate for details.
optional
validateConsensus:boolean
Defined in: types.ts:187
Validate the consensus with the respective consensus implementation passed
to consensusDict
(see respective option) CasperConsensus
(which effectively
does nothing) is available by default.
For the build-in validation classes the following validations take place.
false
.