Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/chain-liveness.yml
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ jobs:
ignite chain build --skip-proto

# init the chain
ignite chain init
ignite evm init

- name: Start Chain and Wait for Blocks
run: |
Expand Down Expand Up @@ -234,7 +234,7 @@ jobs:
fi

# count blocks in log
BLOCKS_FOUND=$(grep -c "block executed successfully" chain.log || true)
BLOCKS_FOUND=$(grep -c "executed block" chain.log || true)
echo "Found $BLOCKS_FOUND blocks so far (attempt $ATTEMPT/$MAX_ATTEMPTS)"
done

Expand Down Expand Up @@ -287,7 +287,7 @@ jobs:
echo "Bob's final balance: $FINAL_BALANCE"

# calculate and verify the expected balance
EXPECTED_BALANCE=$((INITIAL_BALANCE - 100))
EXPECTED_BALANCE=$((INITIAL_BALANCE - 10000100))
if [ "$FINAL_BALANCE" != "$EXPECTED_BALANCE" ]; then
echo "Error: Balance mismatch. Expected: $EXPECTED_BALANCE, Actual: $FINAL_BALANCE"
exit 1
Expand Down
5 changes: 5 additions & 0 deletions evm/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# EVM App Changelog

## [`v0.2.0](https://github.com/ignite/apps/releases/tag/evm/v0.2.0)

- [#256](https://github.com/ignite/apps/pull/256) Upgrade `cosmos/evm` to v0.6.0.
- Follow those instructions if you scaffolded your chain with Ignite EVM App `v0.1.x`.

## [`v0.1.2`](https://github.com/ignite/apps/releases/tag/evm/v0.1.2)

- [#239](https://github.com/ignite/apps/pull/239) Set default token decimal to 18 as recommended.
Expand Down
6 changes: 6 additions & 0 deletions evm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,9 @@ cd gm
ignite app install -g github.com/ignite/apps/evm
ignite evm add
```

After scaffolding the EVM integration, initialize the chain with proper EVM genesis (bank denom metadata is set with 18 decimals based on the chain's default denom):

```sh
ignite evm init
```
2 changes: 1 addition & 1 deletion evm/cmd/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func AddHandler(ctx context.Context, cmd *plugin.ExecutedCommand) error {
return err
}

if finish(ctx, session, c.AppPath()) != nil {
if err := finish(ctx, session, c.AppPath()); err != nil {
return err
}

Expand Down
14 changes: 14 additions & 0 deletions evm/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,20 @@ func GetCommands() []*plugin.Command {
},
},
},
{
Use: "init",
Short: "Initialize the chain with EVM genesis",
Long: "Initialize the chain genesis with proper bank denom metadata for EVM compatibility",
Flags: []*plugin.Flag{
{
Name: flagPath,
Usage: "path of the app",
Shorthand: "p",
Type: plugin.FlagTypeString,
DefaultValue: ".",
},
},
},
},
},
}
Expand Down
121 changes: 121 additions & 0 deletions evm/cmd/init.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
package cmd

import (
"context"
"encoding/json"
"fmt"
"path/filepath"
"strings"

sdk "github.com/cosmos/cosmos-sdk/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"

"github.com/ignite/cli/v29/ignite/pkg/cliui"
"github.com/ignite/cli/v29/ignite/pkg/cliui/colors"
"github.com/ignite/cli/v29/ignite/services/chain"
"github.com/ignite/cli/v29/ignite/services/plugin"
)

const eighteenDecimals = 18

func InitHandler(ctx context.Context, cmd *plugin.ExecutedCommand) error {
flags := plugin.Flags(cmd.Flags)

session := cliui.New()
defer session.End()

appPath, err := flags.GetString(flagPath)
if err != nil {
return err
}
absPath, err := filepath.Abs(appPath)
if err != nil {
return err
}

c, err := chain.New(absPath, chain.CollectEvents(session.EventBus()))
if err != nil {
return err
}

igniteConfig, err := c.Config()
if err != nil {
return err
}

denom := igniteConfig.DefaultDenom
if denom == "" {
denom = sdk.DefaultBondDenom
}

if err := c.Init(ctx, chain.InitArgsAll); err != nil {
return err
}

genesisPath, err := c.GenesisPath()
if err != nil {
return err
}

genesis, err := genutiltypes.AppGenesisFromFile(genesisPath)
if err != nil {
return err
}

var appState map[string]json.RawMessage
if err := json.Unmarshal(genesis.AppState, &appState); err != nil {
return err
}

bankGenesisBz, ok := appState[banktypes.ModuleName]
if !ok {
return fmt.Errorf("bank module not found in genesis app state")
}

var bankGenesis banktypes.GenesisState
if err := json.Unmarshal(bankGenesisBz, &bankGenesis); err != nil {
return err
}

displayDenom := denom
if strings.HasPrefix(denom, "u") && len(denom) > 1 {
displayDenom = denom[1:]
}

bankGenesis.DenomMetadata = []banktypes.Metadata{
{
Description: fmt.Sprintf("Native 18-decimal denom metadata for %s EVM chain", denom),
Base: denom,
DenomUnits: []*banktypes.DenomUnit{
{Denom: denom, Exponent: 0},
{Denom: displayDenom, Exponent: eighteenDecimals},
},
Name: displayDenom,
Symbol: strings.ToUpper(displayDenom),
Display: displayDenom,
},
}

bankGenesisBz, err = json.Marshal(bankGenesis)
if err != nil {
return err
}
appState[banktypes.ModuleName] = bankGenesisBz

genesis.AppState, err = json.Marshal(appState)
if err != nil {
return err
}

if err := genesis.SaveAs(genesisPath); err != nil {
return err
}

home, err := c.Home()
if err != nil {
return err
}

return session.Printf("🗃 Initialized. Checkout your chain's home (data) directory: %s\n", colors.Info(home))
}
30 changes: 16 additions & 14 deletions evm/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/gobuffalo/genny/v2 v2.1.0
github.com/gobuffalo/plush/v4 v4.1.22
github.com/hashicorp/go-plugin v1.6.3
github.com/ignite/cli/v29 v29.8.0
github.com/ignite/cli/v29 v29.9.2
github.com/stretchr/testify v1.11.1
)

Expand All @@ -23,7 +23,7 @@ require (
cosmossdk.io/store v1.1.2 // indirect
cosmossdk.io/x/tx v0.14.0 // indirect
dario.cat/mergo v1.0.1 // indirect
filippo.io/edwards25519 v1.1.0 // indirect
filippo.io/edwards25519 v1.1.1 // indirect
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
github.com/99designs/keyring v1.2.2 // indirect
github.com/DataDog/datadog-go v3.2.0+incompatible // indirect
Expand All @@ -50,7 +50,7 @@ require (
github.com/charmbracelet/x/ansi v0.8.0 // indirect
github.com/charmbracelet/x/cellbuf v0.0.13 // indirect
github.com/charmbracelet/x/term v0.2.1 // indirect
github.com/cloudflare/circl v1.6.1 // indirect
github.com/cloudflare/circl v1.6.3 // indirect
github.com/cloudwego/base64x v0.1.6 // indirect
github.com/cockroachdb/errors v1.12.0 // indirect
github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce // indirect
Expand Down Expand Up @@ -136,6 +136,7 @@ require (
github.com/hashicorp/go-hclog v1.6.3 // indirect
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
github.com/hashicorp/go-metrics v0.5.4 // indirect
github.com/hashicorp/go-uuid v1.0.2 // indirect
github.com/hashicorp/golang-lru v1.0.2 // indirect
github.com/hashicorp/yamux v0.1.2 // indirect
github.com/hdevalence/ed25519consensus v0.2.0 // indirect
Expand Down Expand Up @@ -208,6 +209,7 @@ require (
github.com/tendermint/go-amino v0.16.0 // indirect
github.com/tidwall/btree v1.7.0 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.11 // indirect
github.com/xanzy/ssh-agent v0.3.3 // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
github.com/zondax/golem v0.27.0 // indirect
Expand All @@ -221,19 +223,19 @@ require (
go.yaml.in/yaml/v2 v2.4.2 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/arch v0.17.0 // indirect
golang.org/x/crypto v0.45.0 // indirect
golang.org/x/crypto v0.46.0 // indirect
golang.org/x/exp v0.0.0-20250718183923-645b1fa84792 // indirect
golang.org/x/mod v0.29.0 // indirect
golang.org/x/net v0.47.0 // indirect
golang.org/x/sync v0.18.0 // indirect
golang.org/x/sys v0.38.0 // indirect
golang.org/x/term v0.37.0 // indirect
golang.org/x/text v0.31.0 // indirect
golang.org/x/tools v0.38.0 // indirect
golang.org/x/mod v0.30.0 // indirect
golang.org/x/net v0.48.0 // indirect
golang.org/x/sync v0.19.0 // indirect
golang.org/x/sys v0.39.0 // indirect
golang.org/x/term v0.38.0 // indirect
golang.org/x/text v0.32.0 // indirect
golang.org/x/tools v0.39.0 // indirect
google.golang.org/genproto v0.0.0-20250603155806-513f23925822 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20250728155136-f173205681a0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250818200422-3122310a409c // indirect
google.golang.org/grpc v1.75.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20251202230838-ff82c1b0f217 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20251202230838-ff82c1b0f217 // indirect
google.golang.org/grpc v1.79.3 // indirect
google.golang.org/protobuf v1.36.10 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
Loading
Loading