🚀 Cosmos Blockchain Operations

Complete command reference for managing your deployed blockchain

🔧 Chain Control

Start/Stop Operations

Start Your Blockchain
cd ~/workspace/<chain-id> && ./run.sh
Starts your blockchain in the background
Stop Your Blockchain
kill $(cat ~/workspace/<chain-id>/spaceship.pid)
Safely stops your blockchain
Restart Blockchain
kill $(cat ~/workspace/<chain-id>/spaceship.pid) && sleep 5 && cd ~/workspace/<chain-id> && ./run.sh
Stops and restarts your blockchain

Status & Health Checks

Check Chain Status
<chain-name>d status
Shows current blockchain status and sync info
Check If Chain Is Running
ps aux | grep <chain-name>d
Shows if blockchain process is active
View Latest Blocks
curl -s http://localhost:26657/status | jq .result.sync_info
Shows sync status and latest block info
Check Node Health
curl http://localhost:26657/health
Quick health check endpoint

Logs & Debugging

View Live Logs
tail -f ~/workspace/<chain-id>/log/chain.log
Watch blockchain logs in real-time
Search Error Logs
grep -i "error\|fail\|panic" ~/workspace/<chain-id>/log/chain.log
Find errors in blockchain logs
View Last 100 Log Lines
tail -n 100 ~/workspace/<chain-id>/log/chain.log
Shows recent blockchain activity

⚡ Validator Operations

Validator Setup

Create Validator
<chain-name>d tx staking create-validator \ --amount=1000000stake \ --pubkey=$(<chain-name>d tendermint show-validator) \ --moniker="MyValidator" \ --chain-id=<chain-id> \ --commission-rate="0.10" \ --commission-max-rate="0.20" \ --commission-max-change-rate="0.01" \ --min-self-delegation="1" \ --gas="auto" \ --gas-prices="0.025stake" \ --from=<key-name>
Creates a new validator on your blockchain
Check Validator Status
<chain-name>d query staking validator $(<chain-name>d keys show <key-name> --bech val -a)
Shows your validator's current status
Show Validator Key
<chain-name>d tendermint show-validator
Displays your validator's public key

Delegation Management

Delegate Tokens
<chain-name>d tx staking delegate <validator-address> 1000000stake --from <key-name> --chain-id <chain-id>
Delegate tokens to a validator
Check Delegations
<chain-name>d query staking delegations $(<chain-name>d keys show <key-name> -a)
Shows all delegations for an account
Undelegate Tokens
<chain-name>d tx staking unbond <validator-address> 1000000stake --from <key-name> --chain-id <chain-id>
Undelegate tokens from a validator
Redelegate Tokens
<chain-name>d tx staking redelegate <src-validator> <dst-validator> 1000000stake --from <key-name> --chain-id <chain-id>
Move delegation from one validator to another
⚠️ Warning: Validator operations affect consensus. Test commands on testnet first!

👤 Account & Wallet Management

Key Management

Create New Account
<chain-name>d keys add <account-name>
Creates a new account with mnemonic phrase
List All Accounts
<chain-name>d keys list
Shows all accounts in your keyring
Show Account Address
<chain-name>d keys show <account-name> -a
Displays the address of an account
Recover Account from Mnemonic
<chain-name>d keys add <account-name> --recover
Recovers account using seed phrase
Export Private Key
<chain-name>d keys export <account-name>
Exports encrypted private key
Delete Account
<chain-name>d keys delete <account-name>
Permanently deletes an account

Balance & Transactions

Check Account Balance
<chain-name>d query bank balances $(<chain-name>d keys show <account-name> -a)
Shows all token balances for an account
Send Tokens
<chain-name>d tx bank send <from-address> <to-address> 1000000stake --chain-id <chain-id> --from <key-name>
Transfers tokens between accounts
Check Transaction
<chain-name>d query tx <transaction-hash>
Gets details of a specific transaction
Get Account Info
<chain-name>d query auth account $(<chain-name>d keys show <account-name> -a)
Shows account details including sequence number
🛑 Danger: Never share private keys or mnemonics. Store them securely offline!

💻 Development & Smart Contracts

Module Development

Add New Module
cd ~/workspace/<chain-id> && ignite scaffold module <module-name>
Creates a new custom module
Add Message Type
ignite scaffold message <message-name> <field1> <field2> --module <module-name>
Adds a new message type to a module
Add Query
ignite scaffold query <query-name> <field1> <field2> --module <module-name>
Creates a new query endpoint
Add Data Type
ignite scaffold type <type-name> <field1> <field2> --module <module-name>
Adds a new data structure

Smart Contracts (CosmWasm)

Store Contract Code
<chain-name>d tx wasm store <contract.wasm> --from <key-name> --chain-id <chain-id> --gas auto --gas-adjustment 1.3
Uploads smart contract code to blockchain
Instantiate Contract
<chain-name>d tx wasm instantiate <code-id> '{"count":0}' --label "my contract" --from <key-name> --chain-id <chain-id> --gas auto
Creates a new instance of stored contract
Execute Contract
<chain-name>d tx wasm execute <contract-address> '{"increment":{}}' --from <key-name> --chain-id <chain-id>
Calls a contract function
Query Contract State
<chain-name>d query wasm contract-state smart <contract-address> '{"get_count":{}}'
Queries contract state

Blockchain Queries

Query Block by Height
<chain-name>d query block <height>
Gets block information at specific height
List All Validators
<chain-name>d query staking validators
Shows all validators on the network
Check Governance Proposals
<chain-name>d query gov proposals
Lists all governance proposals
💡 Tip: Replace <placeholders> with your actual values (chain-name, account-name, etc.)

📊 Monitoring & Performance

System Resources

Check Disk Usage
df -h ~/workspace/<chain-id>
Shows disk space usage for blockchain data
Monitor CPU & Memory
top -p $(pgrep <chain-name>d)
Real-time resource usage of blockchain process
Check System Load
uptime && free -h
Shows system load and available memory
Monitor Network Connections
netstat -an | grep :26656
Shows P2P network connections

Blockchain Metrics

Get Node Info
curl -s http://localhost:26657/status | jq
Comprehensive node status information
Check Peer Count
curl -s http://localhost:26657/net_info | jq .result.n_peers
Number of connected peers
Monitor Block Production
watch -n 5 'curl -s http://localhost:26657/status | jq .result.sync_info.latest_block_height'
Watch block height increase in real-time
Check Validator Voting Power
curl -s http://localhost:26657/validators | jq '.result.validators[] | {address: .address, voting_power: .voting_power}'
Shows voting power of all validators

Performance Analysis

Transaction Throughput
curl -s http://localhost:26657/block | jq '.result.block.data.txs | length'
Number of transactions in latest block
Average Block Time
echo "Check the time difference between recent blocks in the logs"
Analyze recent block timestamps for performance
Database Size
du -sh ~/workspace/<chain-id>/home/data
Size of blockchain database

🌐 IBC & Network Operations

IBC Setup

Create IBC Client
<chain-name>d tx ibc client create <client-state> <consensus-state> --from <key-name> --chain-id <chain-id>
Creates IBC light client for another chain
Open IBC Channel
<chain-name>d tx ibc channel open-init transfer <port-id> <channel-id> --from <key-name> --chain-id <chain-id>
Initiates IBC channel opening
List IBC Channels
<chain-name>d query ibc channel channels
Shows all IBC channels
IBC Transfer
<chain-name>d tx ibc-transfer transfer <src-port> <src-channel> <receiver> 1000token --from <key-name> --chain-id <chain-id>
Send tokens across IBC

Relayer Operations

Start Relayer
rly start <path-name>
Starts IBC relayer for specified path
Add Chain to Relayer
rly chains add <chain-id>
Configures relayer for new chain
Create Relayer Path
rly paths new <chain-a> <chain-b> <path-name>
Creates new IBC path between chains

Network Configuration

Add Persistent Peers
sed -i 's/persistent_peers = ""/persistent_peers = "<node-id>@<ip>:26656"/' ~/workspace/<chain-id>/home/config/config.toml
Adds persistent peer connections
Set External Address
sed -i 's/external_address = ""/external_address = "<your-ip>:26656"/' ~/workspace/<chain-id>/home/config/config.toml
Sets external IP for peer discovery
Show Node ID
<chain-name>d tendermint show-node-id
Displays your node's ID for peer connections
🌐 IBC Info: Inter-Blockchain Communication enables your chain to connect with other Cosmos chains

🔒 Security & Access Control

Firewall Configuration

Setup Basic Firewall
sudo ufw enable && sudo ufw allow 22 && sudo ufw allow 26656 && sudo ufw allow 26657
Enables firewall with essential ports
Check Firewall Status
sudo ufw status
Shows current firewall rules
Allow RPC Access (Careful!)
sudo ufw allow from <trusted-ip> to any port 26657
Allows RPC access from specific IP only

Key Security

Backup Validator Key
cp ~/workspace/<chain-id>/home/config/priv_validator_key.json ~/validator_key_backup.json
Creates backup of validator private key
Secure Key Permissions
chmod 600 ~/workspace/<chain-id>/home/config/priv_validator_key.json
Sets secure permissions on validator key
Create Key Backup
<chain-name>d keys export <key-name> > keyfile_backup.txt
Exports encrypted account key

Access Control

Disable External RPC
sed -i 's/laddr = "tcp:\/\/0.0.0.0:26657"/laddr = "tcp:\/\/127.0.0.1:26657"/' ~/workspace/<chain-id>/home/config/config.toml
Restricts RPC to localhost only
Disable Unsafe RPC Methods
sed -i 's/unsafe = true/unsafe = false/' ~/workspace/<chain-id>/home/config/config.toml
Disables potentially dangerous RPC endpoints
Set CORS Policy
sed -i 's/cors_allowed_origins = \[\]/cors_allowed_origins = \["https:\/\/yourdomain.com"\]/' ~/workspace/<chain-id>/home/config/config.toml
Restricts web access to specific domains
🔥 Critical: Never expose your validator key or share it online. Always backup keys securely!

🔧 Maintenance & Upgrades

Backup Operations

Full Data Backup
tar -czf chain-backup-$(date +%Y%m%d).tar.gz ~/workspace/<chain-id>/home
Creates complete backup of blockchain data
Export Genesis
<chain-name>d export > genesis_export.json
Exports current chain state to genesis file
Backup Keys Only
cp -r ~/workspace/<chain-id>/home/keyring-file ~/keyring-backup-$(date +%Y%m%d)
Backs up only the keyring data

Database Maintenance

Reset Chain Data
<chain-name>d tendermint unsafe-reset-all --home ~/workspace/<chain-id>/home
Completely resets blockchain data (DANGEROUS!)
Compact Database
<chain-name>d compact-db --home ~/workspace/<chain-id>/home
Optimizes database storage
Prune Old Blocks
sed -i 's/pruning = "default"/pruning = "custom"/' ~/workspace/<chain-id>/home/config/app.toml && sed -i 's/pruning-keep-recent = "0"/pruning-keep-recent = "100"/' ~/workspace/<chain-id>/home/config/app.toml
Configures block pruning to save space

Software Updates

Update Ignite CLI
curl https://get.ignite.com/cli@latest! | bash
Updates Ignite CLI to latest version
Rebuild Chain Binary
cd ~/workspace/<chain-id> && ignite chain build
Rebuilds blockchain binary with latest code
Check Version
<chain-name>d version
Shows current blockchain software version

System Maintenance

Clean Log Files
find ~/workspace/<chain-id>/log -name "*.log" -mtime +7 -delete
Removes log files older than 7 days
Update System Packages
sudo apt update && sudo apt upgrade -y
Updates VPS system packages
Check System Resources
df -h && free -h && uptime
Shows disk, memory, and system status
⚠️ Warning: Always backup before performing maintenance operations!