chainconfig

package
v1.16.39 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 5, 2026 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package chainconfig provides chain configuration utilities.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidChainConfig indicates the chain configuration is invalid
	ErrInvalidChainConfig = errors.New("invalid chain configuration")

	// ErrMissingChainID indicates the chain ID is missing
	ErrMissingChainID = errors.New("chain ID is required")

	// ErrInvalidGasLimit indicates the gas limit is invalid
	ErrInvalidGasLimit = errors.New("gas limit must be greater than 0")

	// ErrInvalidPrecompile indicates a precompile configuration is invalid
	ErrInvalidPrecompile = errors.New("invalid precompile configuration")

	// ErrInvalidAllocation indicates an allocation is invalid
	ErrInvalidAllocation = errors.New("invalid allocation")
)
View Source
var ChainConfigPresets = map[string]func(*big.Int) *params.ChainConfig{
	"mainnet": MainnetChainConfig,
	"testnet": TestnetChainConfig,
	"local":   LocalChainConfig,
}

ChainConfigPresets provides preset configurations for common scenarios

Functions

func CreateAirdropGenesis

func CreateAirdropGenesis(
	chainConfig *params.ChainConfig,
	airdropAddresses []common.Address,
	airdropAmount *big.Int,
) *core.Genesis

CreateAirdropGenesis creates a genesis with airdrop allocations

func CreateDevGenesis

func CreateDevGenesis(chainID *big.Int) *core.Genesis

CreateDevGenesis creates a genesis suitable for development

func DefaultChainConfig

func DefaultChainConfig() *params.ChainConfig

DefaultChainConfig returns the default EVM chain configuration

func DefaultGenesis

func DefaultGenesis() *core.Genesis

DefaultGenesis creates a default genesis configuration

func GetPresetChainConfig

func GetPresetChainConfig(preset string, chainID *big.Int) *params.ChainConfig

GetPresetChainConfig returns a preset chain configuration by name

func LocalChainConfig

func LocalChainConfig(chainID *big.Int) *params.ChainConfig

LocalChainConfig returns a chain configuration suitable for local development

func MainnetChainConfig

func MainnetChainConfig(chainID *big.Int) *params.ChainConfig

MainnetChainConfig returns a chain configuration suitable for mainnet

func ParseGenesis

func ParseGenesis(data []byte) (*core.Genesis, error)

ParseGenesis parses genesis from JSON bytes

func TestnetChainConfig

func TestnetChainConfig(chainID *big.Int) *params.ChainConfig

TestnetChainConfig returns a chain configuration suitable for testnet

func ValidateGenesis

func ValidateGenesis(genesis *core.Genesis) error

ValidateGenesis validates a genesis configuration

Types

type ChainConfigBuilder

type ChainConfigBuilder struct {
	// contains filtered or unexported fields
}

ChainConfigBuilder helps construct EVM chain configurations

func NewChainConfigBuilder

func NewChainConfigBuilder() *ChainConfigBuilder

NewChainConfigBuilder creates a new chain config builder with EVM defaults

func (*ChainConfigBuilder) Build

Build returns the constructed chain configuration

func (*ChainConfigBuilder) GetAllowFeeRecipients

func (b *ChainConfigBuilder) GetAllowFeeRecipients() bool

GetAllowFeeRecipients returns the allow fee recipients setting

func (*ChainConfigBuilder) GetFeeConfig

func (b *ChainConfigBuilder) GetFeeConfig() interface{}

GetFeeConfig returns the fee configuration

func (*ChainConfigBuilder) GetNetworkUpgrades

func (b *ChainConfigBuilder) GetNetworkUpgrades() map[string]interface{}

GetNetworkUpgrades returns the network upgrade configurations

func (*ChainConfigBuilder) GetPrecompiles

func (b *ChainConfigBuilder) GetPrecompiles() map[string]interface{}

GetPrecompiles returns the precompile configurations

func (*ChainConfigBuilder) WithAllowFeeRecipients

func (b *ChainConfigBuilder) WithAllowFeeRecipients(allow bool) *ChainConfigBuilder

WithAllowFeeRecipients enables/disables fee recipients

func (*ChainConfigBuilder) WithChainID

func (b *ChainConfigBuilder) WithChainID(chainID *big.Int) *ChainConfigBuilder

WithChainID sets the chain ID

func (*ChainConfigBuilder) WithFeeConfig

func (b *ChainConfigBuilder) WithFeeConfig(feeConfig interface{}) *ChainConfigBuilder

WithFeeConfig sets the fee configuration

func (*ChainConfigBuilder) WithNetworkUpgrade

func (b *ChainConfigBuilder) WithNetworkUpgrade(name string, timestamp *big.Int) *ChainConfigBuilder

WithNetworkUpgrade adds a network upgrade configuration

func (*ChainConfigBuilder) WithPrecompile

func (b *ChainConfigBuilder) WithPrecompile(address common.Address, config interface{}) *ChainConfigBuilder

WithPrecompile adds a precompile configuration

type GenesisBuilder

type GenesisBuilder struct {
	// contains filtered or unexported fields
}

GenesisBuilder helps construct EVM genesis configurations

func NewGenesisBuilder

func NewGenesisBuilder() *GenesisBuilder

NewGenesisBuilder creates a new genesis builder with defaults

func (*GenesisBuilder) Build

func (b *GenesisBuilder) Build() *core.Genesis

Build returns the constructed genesis

func (*GenesisBuilder) ToJSON

func (b *GenesisBuilder) ToJSON() ([]byte, error)

ToJSON converts the genesis to JSON bytes

func (*GenesisBuilder) WithAllocation

func (b *GenesisBuilder) WithAllocation(address common.Address, balance *big.Int) *GenesisBuilder

WithAllocation adds an account allocation

func (*GenesisBuilder) WithAllocations

func (b *GenesisBuilder) WithAllocations(allocations map[common.Address]*big.Int) *GenesisBuilder

WithAllocations adds multiple account allocations

func (*GenesisBuilder) WithChainConfig

func (b *GenesisBuilder) WithChainConfig(config *params.ChainConfig) *GenesisBuilder

WithChainConfig sets the chain configuration

func (*GenesisBuilder) WithContract

func (b *GenesisBuilder) WithContract(address common.Address, balance *big.Int, code []byte, storage map[common.Hash]common.Hash) *GenesisBuilder

WithContract adds a contract with code and storage

func (*GenesisBuilder) WithExtraData

func (b *GenesisBuilder) WithExtraData(extraData []byte) *GenesisBuilder

WithExtraData sets the extra data

func (*GenesisBuilder) WithGasLimit

func (b *GenesisBuilder) WithGasLimit(gasLimit uint64) *GenesisBuilder

WithGasLimit sets the gas limit

func (*GenesisBuilder) WithTimestamp

func (b *GenesisBuilder) WithTimestamp(timestamp uint64) *GenesisBuilder

WithTimestamp sets the genesis timestamp

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL