Ignite CLI for Cosmos SDK
Ignite CLI commands for building Cosmos SDK blockchains. Quick reference for blockchain development workflow.
Installation
1# Install Ignite CLI
2curl https://get.ignite.com/cli! | bash
3
4# Or with Homebrew (macOS)
5brew install ignite
6
7# Verify installation
8ignite version
Scaffold New Blockchain
1# Create new blockchain
2ignite scaffold chain github.com/username/mychain
3
4# Create with specific options
5ignite scaffold chain github.com/username/mychain \
6 --no-module \
7 --address-prefix mychain
8
9# Navigate to project
10cd mychain
Scaffold Modules
1# Create new module
2ignite scaffold module blog
3
4# Create module with IBC
5ignite scaffold module blog --ibc
6
7# Create module with dependencies
8ignite scaffold module blog --dep account,bank
Scaffold Types & Messages
1# Scaffold a list (CRUD)
2ignite scaffold list post title body --module blog
3
4# Scaffold a map
5ignite scaffold map product name:string price:uint --module store
6
7# Scaffold a single type
8ignite scaffold single config maxPosts:uint --module blog
9
10# Scaffold a message (transaction)
11ignite scaffold message create-post title body --module blog
12
13# Scaffold a query
14ignite scaffold query posts --response posts:Post --module blog
15
16# Scaffold with custom types
17ignite scaffold list comment postID:uint body creator --module blog
Scaffold IBC
1# Scaffold IBC packet
2ignite scaffold packet ibcPost title body --module blog
3
4# Scaffold IBC packet with acknowledgement
5ignite scaffold packet ibcPost title body --ack postID:uint --module blog
6
7# Scaffold IBC module
8ignite scaffold module blog --ibc
9ignite scaffold packet sendPost title:string content:string --module blog
Build & Serve
1# Start development chain
2ignite chain serve
3
4# Serve with specific config
5ignite chain serve -c config.yml
6
7# Serve with reset
8ignite chain serve --reset-once
9
10# Serve with verbose output
11ignite chain serve -v
12
13# Build binary only
14ignite chain build
15
16# Build with specific output
17ignite chain build --output ./build
18
19# Install binary to $GOPATH/bin
20ignite chain build --release
Chain Initialization
1# Initialize chain
2ignite chain init
3
4# Initialize with custom home directory
5ignite chain init --home ~/.mychain
6
7# Clear chain data
8ignite chain init --reset-once
Testing
1# Run tests
2ignite chain test
3
4# Run specific test
5ignite chain test ./x/blog/keeper/...
6
7# Run with coverage
8ignite chain test --coverage
Code Generation
1# Generate code (proto, OpenAPI, etc.)
2ignite generate proto-go
3
4# Generate OpenAPI spec
5ignite generate openapi
6
7# Generate TypeScript client
8ignite generate ts-client
9
10# Generate all
11ignite generate
Relayer (IBC)
1# Configure relayer
2ignite relayer configure
3
4# Start relayer
5ignite relayer connect
6
7# Check relayer status
8ignite relayer status
Network
1# Join a network
2ignite network chain join <chain-id>
3
4# Publish chain
5ignite network chain publish github.com/username/mychain
6
7# List available chains
8ignite network chain list
9
10# Show chain info
11ignite network chain show <chain-id>
Accounts & Transactions
1# Create account
2ignite account create alice
3
4# List accounts
5ignite account list
6
7# Show account details
8ignite account show alice
9
10# Send transaction
11mychaind tx blog create-post "Hello" "World" \
12 --from alice \
13 --chain-id mychain \
14 --yes
15
16# Query
17mychaind query blog list-post
Configuration Files
config.yml
1version: 1
2
3build:
4 binary: mychaind
5 proto:
6 path: proto
7 third_party_paths:
8 - third_party/proto
9 - proto_vendor
10
11accounts:
12 - name: alice
13 coins:
14 - 100000000stake
15 - 1000000token
16 - name: bob
17 coins:
18 - 50000000stake
19
20validator:
21 name: alice
22 staked: 100000000stake
23
24faucet:
25 name: bob
26 coins:
27 - 5stake
28 - 100token
29 port: 4500
30
31genesis:
32 chain_id: mychain-1
33 app_state:
34 staking:
35 params:
36 bond_denom: stake
Project Structure
1mychain/
2βββ app/ # Application logic
3β βββ app.go
4β βββ encoding.go
5βββ cmd/
6β βββ mychaind/ # CLI binary
7β βββ main.go
8βββ proto/ # Protocol Buffers
9β βββ mychain/
10β βββ blog/
11β βββ genesis.proto
12β βββ query.proto
13β βββ tx.proto
14β βββ types.proto
15βββ x/ # Custom modules
16β βββ blog/
17β βββ client/
18β βββ keeper/
19β βββ types/
20β βββ module.go
21βββ testutil/ # Test utilities
22βββ docs/ # Documentation
23βββ config.yml # Ignite config
24βββ go.mod
Common Workflows
Create Blog Module
1# 1. Scaffold chain
2ignite scaffold chain github.com/username/blogchain
3cd blogchain
4
5# 2. Scaffold blog module
6ignite scaffold module blog
7
8# 3. Scaffold post type
9ignite scaffold list post title body creator --module blog
10
11# 4. Scaffold comment type
12ignite scaffold list comment postID:uint body creator --module blog
13
14# 5. Add custom message
15ignite scaffold message like-post postID:uint --module blog
16
17# 6. Start chain
18ignite chain serve
19
20# 7. Test
21blogchaind tx blog create-post "First Post" "Hello World" --from alice --yes
22blogchaind query blog list-post
Create IBC-Enabled Module
1# 1. Scaffold chain
2ignite scaffold chain github.com/username/ibcchain
3cd ibcchain
4
5# 2. Scaffold IBC module
6ignite scaffold module ibcblog --ibc
7
8# 3. Scaffold IBC packet
9ignite scaffold packet sendPost title:string content:string \
10 --ack postID:uint \
11 --module ibcblog
12
13# 4. Start chain
14ignite chain serve
15
16# 5. Configure relayer (in another terminal)
17ignite relayer configure
18ignite relayer connect
Troubleshooting
1# Clear cache and rebuild
2ignite chain serve --reset-once
3
4# Check for errors
5ignite chain build --verbose
6
7# View logs
8tail -f ~/.mychain/logs/mychain.log
9
10# Reset everything
11rm -rf ~/.mychain
12ignite chain serve --reset-once
13
14# Update dependencies
15go mod tidy
16go mod download
Makefile Integration
1.PHONY: serve build test proto clean
2
3serve:
4 ignite chain serve
5
6serve-reset:
7 ignite chain serve --reset-once
8
9build:
10 ignite chain build
11
12test:
13 ignite chain test
14
15proto:
16 ignite generate proto-go
17
18ts-client:
19 ignite generate ts-client
20
21clean:
22 rm -rf ~/.mychain
23 rm -rf build/
Best Practices
1β
Use semantic versioning for modules
2β
Write tests for keeper functions
3β
Document proto files with comments
4β
Use events for important state changes
5β
Validate input in message handlers
6β
Use proper error handling
7β
Keep modules focused and small
8β
Use IBC for cross-chain communication
Related Snippets
- Blockchain Platforms Overview
Core principles and ideas of major blockchain platforms - Cosmos Operations & Governance
Practical Cosmos SDK operations including governance proposals, multisig β¦