ResearchCommon CLI Command Guide for Cosmos SDK-based Chains

Common CLI Command Guide for Cosmos SDK-based Chains

The Cosmos SDK offers a robust framework for building blockchain applications, and the command-line interface (CLI) is a crucial tool for interacting with networks built on this technology. Whether you’re managing a validator, sending transactions, or querying blockchain data, understanding the CLI commands can significantly enhance your operational efficiency. This article provides a comprehensive guide to common CLI commands used in Cosmos SDK-based chains, compiled from practical examples and discussions.

In the examples below the daemon onomyd is used. This will be different depending on the chain you are operating on, such as injectived

1. Setting Up and Managing Keys

Add a New Key

To create a new key (wallet), use the keys add command:

onomyd keys add <key-name>

This command generates a new key pair and provides you with an address, along with a mnemonic phrase that should be securely backed up.

Recover a Key Using Mnemonic

If you need to recover a key using a mnemonic phrase:

onomyd keys add <key-name> --recover

You will be prompted to enter your mnemonic phrase after executing this command.

List All Keys

To list all the keys in your keyring:

onomyd keys list

2. Staking and Delegation

Delegate Tokens

To delegate tokens to a validator:

onomyd tx staking delegate <validator-addr> <amount>anom --from <your-key-name> --chain-id <chain-id> --node <RPC-endpoint>

For example:

onomyd tx staking delegate onomyvaloper1xyz... 1000000000000000000anom --from <your-key-name> --chain-id onomy-mainnet-1 --node

Undelegate Tokens

To undelegate tokens:

onomyd tx staking undelegate <validator-addr> <amount>anom --from <your-key-name> --chain-id <chain-id> --node <RPC-endpoint>

Redelegate Tokens from One Validator to Another

onomyd tx staking redelegate <old-validator-addr> <new-validator-addr> <amount>anom--from <your-key-name> --chain-id <chain-id>

3. Querying Blockchain Data

Check Account Balance

To check the balance of an account:

onomyd query bank balances <account-address>

Query Delegations Made by an Address

onomyd query staking delegations <delegator-address>

Get Transaction Details by Hash

onomyd query tx <tx-hash>

4. Governance

Vote on a Proposal

To cast a vote on a governance proposal:

onomyd tx gov vote <proposal-id> <vote-option> --from <key-name> --chain-id <chain-id>

Options for <vote-option> include yes, no, no_with_veto, and abstain.

5. Transactions

Send Tokens

To send tokens from one account to another:

onomyd tx bank send <from-key-or-address> <to-address> <amount>anom --chain-id <chain-id>

Broadcast a Transaction

onomyd tx broadcast <tx-file>

This is used to broadcast a transaction from a signed transaction file.

6. Validator Commands

Create a New Validator

onomyd tx staking create-validator
--pubkey $(onomyd tendermint show-validator)
--moniker "the name of your validator"
--details "a description of your validator"
--identity "your PGP key (your pfp will be used in apps)" # optional
--website "" # optional
--security-contact "" # optional
--min-self-delegation 225000000000000000000000
--commission-rate "0.05"
--commission-max-rate "0.20"
--commission-max-change-rate "0.01"
--amount 225000000000000000000000anom
--from validator
--chain-id onomy-mainnet-1
--gas auto
--gas-adjustment 1.4
--gas-prices 0anom

Edit Validator Details

onomyd tx staking edit-validator --moniker <new-moniker> --from <key-name> --chain-id <chain-id>

Withdraw Rewards

To withdraw staking rewards including validator commissions:

onomyd tx distribution withdraw-rewards <validator-addr> --from <your-key-name> --commission --chain-id <chain-id> --node <RPC-endpoint> --yes


This guide covers essential CLI commands for interacting with Cosmos SDK-based chains. For detailed explanations and additional options, always refer to the official documentation of the specific Cosmos SDK blockchain you are interacting with.

Here’s a recommended network architecture that includes sentry nodes. Image courtesy of Stakefish.

Scroll up Drag View