evmd

package module
v0.0.0-...-8811a72 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2026 License: Apache-2.0 Imports: 132 Imported by: 3

README

Example Cosmos EVM Chain

This directory contains an example chain that uses the Cosmos EVM modules. It is based on the simapp implementation on the Cosmos SDK repository, which itself is a simplified version of a Cosmos SDK-based blockchain.

This chain implementation is used to demonstrate the integration of Cosmos EVM as well as to provide a chain object for testing purposes within the repository.

Config

By default, this chain has the following configuration:

Option Value
Binary evmd
Chain ID cosmos_262144-1
Custom Opcodes -
Default Token Pairs 1 for the native token
Denomination atest
EVM permissioning permissionless
Enabled Precompiles all

Running The Chain

To run the example, execute the local node script found within this repository:

./local_node.sh [FLAGS]

Available flags are:

  • -y: Overwrite previous database
  • -n: Do not overwrite previous database
  • --no-install: Skip installation of the binary
  • --remote-debugging: Build a binary suitable for remote debugging

Connect to Wallet

For the sake of this example, we'll be using Metamask:

  1. Use the following seed phrase when adding a new wallet: gesture inject test cycle original hollow east ridge hen combine junk child bacon zero hope comfort vacuum milk pitch cage oppose unhappy lunar seat
  2. On the top left of the Metamask extension, click the Network button.
  3. Click Add custom network from the bottom of the modal.
  4. Under Default RPC URL, add the RPC URL as http://localhost:8545. Ensure your chain is running.
  5. Once added, copy the rest of the settings shown in the below images.

Button to select network Button to add network RPC URL Settings Overview of required settings

Available Cosmos SDK Modules

As mentioned above, this exemplary chain implementation is a reduced version of simapp. Specifically, instead of offering access to all Cosmos SDK modules, it just includes the following:

  • auth
  • authz
  • bank
  • capability
  • consensus
  • distribution
  • evidence
  • feegrant
  • genutil
  • gov
  • mint
  • params
  • slashing
  • staking
  • upgrade

Documentation

Index

Constants

View Source
const UpgradeName = "v0.5.0-to-v0.6.0"

UpgradeName defines the on-chain upgrade name for the sample EVMD upgrade from v0.5.0 to v0.6.0.

NOTE: This upgrade defines a reference implementation of what an upgrade could look like when an application is migrating from EVMD version v0.4.0 to v0.5.x

Variables

This section is empty.

Functions

func NewEVMGenesisState

func NewEVMGenesisState() *evmtypes.GenesisState

NewEVMGenesisState returns the default genesis state for the EVM module.

NOTE: for the example chain implementation we need to set the default EVM denomination, enable ALL precompiles, and include default preinstalls.

func NewErc20GenesisState

func NewErc20GenesisState() *erc20types.GenesisState

NewErc20GenesisState returns the default genesis state for the ERC20 module.

NOTE: for the example chain implementation we are also adding a default token pair, which is the base denomination of the chain (i.e. the WEVMOS contract).

func NewFeeMarketGenesisState

func NewFeeMarketGenesisState() *feemarkettypes.GenesisState

NewFeeMarketGenesisState returns the default genesis state for the feemarket module.

NOTE: for the example chain implementation we are disabling the base fee.

func NewMintGenesisState

func NewMintGenesisState() *minttypes.GenesisState

NewMintGenesisState returns the default genesis state for the mint module.

NOTE: for the example chain implementation we are also adding a default minter.

func SetupTestingApp

func SetupTestingApp(chainID string) func() (ibctesting.TestingApp, map[string]json.RawMessage)

SetupTestingApp initializes the IBC-go testing application need to keep this design to comply with the ibctesting SetupTestingApp func and be able to set the chainID for the tests properly

Types

type BankKeeper

type BankKeeper interface {
	evmtypes.BankKeeper
	cmn.BankKeeper
}

type EVMD

type EVMD struct {
	*baseapp.BaseApp

	// keepers
	AccountKeeper         authkeeper.AccountKeeper
	BankKeeper            bankkeeper.Keeper
	StakingKeeper         *stakingkeeper.Keeper
	SlashingKeeper        slashingkeeper.Keeper
	MintKeeper            mintkeeper.Keeper
	DistrKeeper           distrkeeper.Keeper
	GovKeeper             govkeeper.Keeper
	UpgradeKeeper         *upgradekeeper.Keeper
	AuthzKeeper           authzkeeper.Keeper
	EvidenceKeeper        evidencekeeper.Keeper
	FeeGrantKeeper        feegrantkeeper.Keeper
	ConsensusParamsKeeper consensusparamkeeper.Keeper

	// IBC keepers
	IBCKeeper      *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly
	TransferKeeper transferkeeper.Keeper
	CallbackKeeper ibccallbackskeeper.ContractKeeper

	// Cosmos EVM keepers
	FeeMarketKeeper   feemarketkeeper.Keeper
	EVMKeeper         *evmkeeper.Keeper
	Erc20Keeper       erc20keeper.Keeper
	PreciseBankKeeper precisebankkeeper.Keeper
	EVMMempool        *evmmempool.ExperimentalEVMMempool

	// the module manager
	ModuleManager      *module.Manager
	BasicModuleManager module.BasicManager
	// contains filtered or unexported fields
}

EVMD extends an ABCI application, but with most of its parameters exported.

func NewExampleApp

func NewExampleApp(
	logger log.Logger,
	db dbm.DB,
	traceStore io.Writer,
	loadLatest bool,
	appOpts servertypes.AppOptions,
	baseAppOptions ...func(*baseapp.BaseApp),
) *EVMD

NewExampleApp returns a reference to an initialized EVMD.

func Setup

func Setup(t *testing.T, chainID string, evmChainID uint64) *EVMD

Setup initializes a new EVMD. A Nop logger is set in EVMD.

func SetupWithGenesisValSet

func SetupWithGenesisValSet(t *testing.T, chainID string, evmChainID uint64, valSet *cmttypes.ValidatorSet, genAccs []authtypes.GenesisAccount, balances ...banktypes.Balance) *EVMD

SetupWithGenesisValSet initializes a new EVMD with a validator set and genesis accounts that also act as delegators. For simplicity, each validator is bonded with a delegation of one consensus engine unit in the default token of the simapp from first genesis account. A Nop logger is set in EVMD.

func (*EVMD) AppCodec

func (app *EVMD) AppCodec() codec.Codec

AppCodec returns EVMD's app codec.

NOTE: This is solely to be used for testing purposes as it may be desirable for modules to register their own custom testing types.

func (*EVMD) AutoCliOpts

func (app *EVMD) AutoCliOpts() autocli.AppOptions

AutoCliOpts returns the autocli options for the app.

func (*EVMD) BeginBlocker

func (app *EVMD) BeginBlocker(ctx sdk.Context) (sdk.BeginBlock, error)

BeginBlocker application updates every begin block

func (*EVMD) Close

func (app *EVMD) Close() error

Close unsubscribes from the CometBFT event bus (if set) and closes the mempool and underlying BaseApp.

func (*EVMD) Configurator

func (app *EVMD) Configurator() module.Configurator

func (*EVMD) DefaultGenesis

func (app *EVMD) DefaultGenesis() map[string]json.RawMessage

DefaultGenesis returns a default genesis from the registered AppModuleBasic's.

func (*EVMD) EndBlocker

func (app *EVMD) EndBlocker(ctx sdk.Context) (sdk.EndBlock, error)

EndBlocker application updates every end block

func (*EVMD) ExportAppStateAndValidators

func (app *EVMD) ExportAppStateAndValidators(forZeroHeight bool, jailAllowedAddrs []string, modulesToExport []string) (servertypes.ExportedApp, error)

ExportAppStateAndValidators exports the state of the application for a genesis file.

func (*EVMD) FinalizeBlock

func (app *EVMD) FinalizeBlock(req *abci.RequestFinalizeBlock) (res *abci.ResponseFinalizeBlock, err error)

func (*EVMD) GetAccountKeeper

func (app *EVMD) GetAccountKeeper() authkeeper.AccountKeeper

func (*EVMD) GetAnteHandler

func (app *EVMD) GetAnteHandler() sdk.AnteHandler

func (*EVMD) GetBankKeeper

func (app *EVMD) GetBankKeeper() bankkeeper.Keeper

func (*EVMD) GetBaseApp

func (app *EVMD) GetBaseApp() *baseapp.BaseApp

GetBaseApp implements the TestingApp interface.

func (*EVMD) GetCallbackKeeper

func (app *EVMD) GetCallbackKeeper() ibccallbackskeeper.ContractKeeper

func (*EVMD) GetConsensusParamsKeeper

func (app *EVMD) GetConsensusParamsKeeper() consensusparamkeeper.Keeper

func (*EVMD) GetDistrKeeper

func (app *EVMD) GetDistrKeeper() distrkeeper.Keeper

func (*EVMD) GetEVMKeeper

func (app *EVMD) GetEVMKeeper() *evmkeeper.Keeper

func (*EVMD) GetErc20Keeper

func (app *EVMD) GetErc20Keeper() *erc20keeper.Keeper

func (*EVMD) GetEvidenceKeeper

func (app *EVMD) GetEvidenceKeeper() *evidencekeeper.Keeper

func (*EVMD) GetFeeGrantKeeper

func (app *EVMD) GetFeeGrantKeeper() feegrantkeeper.Keeper

func (*EVMD) GetFeeMarketKeeper

func (app *EVMD) GetFeeMarketKeeper() *feemarketkeeper.Keeper

func (*EVMD) GetGovKeeper

func (app *EVMD) GetGovKeeper() govkeeper.Keeper

func (*EVMD) GetIBCKeeper

func (app *EVMD) GetIBCKeeper() *ibckeeper.Keeper

GetIBCKeeper implements the TestingApp interface.

func (*EVMD) GetKey

func (app *EVMD) GetKey(storeKey string) *storetypes.KVStoreKey

GetKey returns the KVStoreKey for the provided store key.

NOTE: This is solely to be used for testing purposes.

func (*EVMD) GetMempool

func (app *EVMD) GetMempool() sdkmempool.ExtMempool

func (*EVMD) GetMintKeeper

func (app *EVMD) GetMintKeeper() mintkeeper.Keeper

func (*EVMD) GetPreciseBankKeeper

func (app *EVMD) GetPreciseBankKeeper() *precisebankkeeper.Keeper

func (*EVMD) GetSlashingKeeper

func (app *EVMD) GetSlashingKeeper() slashingkeeper.Keeper

func (*EVMD) GetStakingKeeper

func (app *EVMD) GetStakingKeeper() *stakingkeeper.Keeper

func (*EVMD) GetStakingKeeperSDK

func (app *EVMD) GetStakingKeeperSDK() stakingkeeper.Keeper

GetStakingKeeperSDK implements the TestingApp interface.

func (*EVMD) GetTransferKeeper

func (app *EVMD) GetTransferKeeper() transferkeeper.Keeper

func (*EVMD) GetTxConfig

func (app *EVMD) GetTxConfig() client.TxConfig

GetTxConfig implements the TestingApp interface.

func (*EVMD) InitChainer

func (app *EVMD) InitChainer(ctx sdk.Context, req *abci.RequestInitChain) (*abci.ResponseInitChain, error)

InitChainer application update at chain initialization

func (*EVMD) InterfaceRegistry

func (app *EVMD) InterfaceRegistry() types.InterfaceRegistry

InterfaceRegistry returns EVMD's InterfaceRegistry

func (*EVMD) LegacyAmino

func (app *EVMD) LegacyAmino() *codec.LegacyAmino

LegacyAmino returns EVMD's amino codec.

NOTE: This is solely to be used for testing purposes as it may be desirable for modules to register their own custom testing types.

func (*EVMD) LoadHeight

func (app *EVMD) LoadHeight(height int64) error

LoadHeight loads a particular height

func (*EVMD) Name

func (app *EVMD) Name() string

Name returns the name of the App

func (*EVMD) PreBlocker

func (app *EVMD) PreBlocker(ctx sdk.Context, _ *abci.RequestFinalizeBlock) (*sdk.ResponsePreBlock, error)

func (*EVMD) RegisterAPIRoutes

func (app *EVMD) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig)

RegisterAPIRoutes registers all application module routes with the provided API server.

func (*EVMD) RegisterNodeService

func (app *EVMD) RegisterNodeService(clientCtx client.Context, cfg config.Config)

func (*EVMD) RegisterPendingTxListener

func (app *EVMD) RegisterPendingTxListener(listener func(common.Hash))

RegisterPendingTxListener is used by json-rpc server to listen to pending transactions callback.

func (*EVMD) RegisterTendermintService

func (app *EVMD) RegisterTendermintService(clientCtx client.Context)

RegisterTendermintService implements the Application.RegisterTendermintService method.

func (*EVMD) RegisterTxService

func (app *EVMD) RegisterTxService(clientCtx client.Context)

RegisterTxService implements the Application.RegisterTxService method.

func (EVMD) RegisterUpgradeHandlers

func (app EVMD) RegisterUpgradeHandlers()

func (*EVMD) SetErc20Keeper

func (app *EVMD) SetErc20Keeper(erc20Keeper erc20keeper.Keeper)

func (*EVMD) SetTransferKeeper

func (app *EVMD) SetTransferKeeper(transferKeeper transferkeeper.Keeper)

func (*EVMD) SimulationManager

func (app *EVMD) SimulationManager() *module.SimulationManager

SimulationManager implements the SimulationApp interface

func (*EVMD) TxConfig

func (app *EVMD) TxConfig() client.TxConfig

TxConfig returns EVMD's TxConfig

type GenesisState

type GenesisState map[string]json.RawMessage

GenesisState of the blockchain is represented here as a map of raw json messages key'd by an identifier string. The identifier is used to determine which module genesis information belongs to so it may be appropriately routed during init chain. Within this application default genesis information is retrieved from the ModuleBasicManager which populates json from each BasicModule object provided to it during init.

type SetupOptions

type SetupOptions struct {
	Logger  log.Logger
	DB      *dbm.MemDB
	AppOpts servertypes.AppOptions
}

SetupOptions defines arguments that are passed into `Simapp` constructor.

Directories

Path Synopsis
cmd
evmd command
tests
ibc
network
Package network implements and exposes a fully operational in-process CometBFT test network that consists of at least one or potentially many validators.
Package network implements and exposes a fully operational in-process CometBFT test network that consists of at least one or potentially many validators.

Jump to

Keyboard shortcuts

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