Cosmos Operations & Governance
Practical Cosmos SDK operations including governance proposals, multisig accounts, and Cosmovisor setup.
Governance Proposals
Create Text Governance Proposal
1# Create proposal JSON
2cat > proposal.json <<EOF
3{
4 "title": "Enable IBC Transfer",
5 "description": "This proposal enables IBC transfer module for cross-chain transactions",
6 "deposit": "10000000uatom"
7}
8EOF
9
10# Submit proposal
11gaiad tx gov submit-proposal \
12 --title "Enable IBC Transfer" \
13 --description "This proposal enables IBC transfer module" \
14 --type Text \
15 --deposit 10000000uatom \
16 --from mykey \
17 --chain-id cosmoshub-4 \
18 --gas auto \
19 --gas-adjustment 1.5 \
20 --fees 5000uatom
21
22# Alternative: Submit from JSON file
23gaiad tx gov submit-legacy-proposal \
24 --proposal proposal.json \
25 --from mykey \
26 --chain-id cosmoshub-4
Create Parameter Change Proposal
1# Create param change proposal
2cat > param-change.json <<EOF
3{
4 "title": "Increase Max Validators",
5 "description": "Increase the maximum number of validators from 125 to 150",
6 "changes": [
7 {
8 "subspace": "staking",
9 "key": "MaxValidators",
10 "value": "150"
11 }
12 ],
13 "deposit": "10000000uatom"
14}
15EOF
16
17# Submit parameter change proposal
18gaiad tx gov submit-legacy-proposal param-change param-change.json \
19 --from mykey \
20 --chain-id cosmoshub-4 \
21 --gas auto \
22 --fees 5000uatom
Create Community Pool Spend Proposal
1cat > community-spend.json <<EOF
2{
3 "title": "Fund Development Team",
4 "description": "Allocate 100,000 ATOM to development team",
5 "recipient": "cosmos1abc...",
6 "amount": "100000000000uatom",
7 "deposit": "10000000uatom"
8}
9EOF
10
11gaiad tx gov submit-legacy-proposal community-pool-spend community-spend.json \
12 --from mykey \
13 --chain-id cosmoshub-4
Vote on Governance Proposal
Query Proposals
1# List all proposals
2gaiad query gov proposals
3
4# Query specific proposal
5gaiad query gov proposal 42
6
7# Query proposal status
8gaiad query gov proposal 42 --output json | jq '.status'
9
10# Query votes on proposal
11gaiad query gov votes 42
12
13# Query your vote
14gaiad query gov vote 42 cosmos1abc...
Cast Vote
1# Vote options: yes, no, abstain, no_with_veto
2gaiad tx gov vote 42 yes \
3 --from mykey \
4 --chain-id cosmoshub-4 \
5 --gas auto \
6 --fees 5000uatom
7
8# Vote with reason (SDK v0.46+)
9gaiad tx gov vote 42 yes \
10 --from mykey \
11 --metadata "I support this proposal because..." \
12 --chain-id cosmoshub-4
13
14# Weighted vote (SDK v0.43+)
15gaiad tx gov weighted-vote 42 \
16 yes=0.6,no=0.3,abstain=0.1 \
17 --from mykey \
18 --chain-id cosmoshub-4
Deposit to Proposal
1# Add deposit to reach minimum
2gaiad tx gov deposit 42 10000000uatom \
3 --from mykey \
4 --chain-id cosmoshub-4 \
5 --gas auto \
6 --fees 5000uatom
7
8# Query deposits
9gaiad query gov deposits 42
Create Software Upgrade Proposal
Prepare Upgrade Proposal
1# Create upgrade proposal JSON
2cat > upgrade-proposal.json <<EOF
3{
4 "title": "Upgrade to v10.0.0",
5 "description": "This proposal upgrades the chain to v10.0.0 with new features",
6 "plan": {
7 "name": "v10",
8 "height": "12345000",
9 "info": "https://github.com/cosmos/gaia/releases/tag/v10.0.0"
10 },
11 "deposit": "10000000uatom"
12}
13EOF
14
15# Submit software upgrade proposal
16gaiad tx gov submit-legacy-proposal software-upgrade v10 \
17 --title "Upgrade to v10.0.0" \
18 --description "Upgrade chain to v10.0.0" \
19 --upgrade-height 12345000 \
20 --upgrade-info '{"binaries":{"linux/amd64":"https://github.com/cosmos/gaia/releases/download/v10.0.0/gaiad-v10.0.0-linux-amd64"}}' \
21 --deposit 10000000uatom \
22 --from mykey \
23 --chain-id cosmoshub-4
24
25# Query upgrade plan
26gaiad query upgrade plan
Cancel Upgrade Proposal
1gaiad tx gov submit-legacy-proposal cancel-software-upgrade \
2 --title "Cancel v10 Upgrade" \
3 --description "Cancel the v10 upgrade due to critical bug" \
4 --deposit 10000000uatom \
5 --from mykey \
6 --chain-id cosmoshub-4
Multisig Accounts
Create Multisig Account
1# Create multisig account (2-of-3)
2gaiad keys add multisig1 \
3 --multisig key1,key2,key3 \
4 --multisig-threshold 2
5
6# Show multisig address
7gaiad keys show multisig1 -a
8
9# Example output: cosmos1abc123...
Multisig Account Structure
Create Transaction for Signing
Generate Unsigned Transaction
1# Create unsigned transaction
2gaiad tx bank send \
3 cosmos1multisig... \
4 cosmos1recipient... \
5 1000000uatom \
6 --from cosmos1multisig... \
7 --chain-id cosmoshub-4 \
8 --gas 200000 \
9 --fees 5000uatom \
10 --generate-only > unsigned.json
11
12# View unsigned transaction
13cat unsigned.json
Transaction JSON Structure
1{
2 "body": {
3 "messages": [
4 {
5 "@type": "/cosmos.bank.v1beta1.MsgSend",
6 "from_address": "cosmos1multisig...",
7 "to_address": "cosmos1recipient...",
8 "amount": [{"denom": "uatom", "amount": "1000000"}]
9 }
10 ],
11 "memo": "",
12 "timeout_height": "0",
13 "extension_options": [],
14 "non_critical_extension_options": []
15 },
16 "auth_info": {
17 "signer_infos": [],
18 "fee": {
19 "amount": [{"denom": "uatom", "amount": "5000"}],
20 "gas_limit": "200000",
21 "payer": "",
22 "granter": ""
23 }
24 },
25 "signatures": []
26}
Sign Transaction with Multisig
Individual Signing
1# Signer 1 signs the transaction
2gaiad tx sign unsigned.json \
3 --from key1 \
4 --multisig cosmos1multisig... \
5 --chain-id cosmoshub-4 \
6 --output-document key1-signature.json
7
8# Signer 2 signs the transaction
9gaiad tx sign unsigned.json \
10 --from key2 \
11 --multisig cosmos1multisig... \
12 --chain-id cosmoshub-4 \
13 --output-document key2-signature.json
14
15# Signer 3 signs (optional for 2-of-3)
16gaiad tx sign unsigned.json \
17 --from key3 \
18 --multisig cosmos1multisig... \
19 --chain-id cosmoshub-4 \
20 --output-document key3-signature.json
Collect Multisig Signatures
Combine Signatures
1# Collect signatures (need 2 out of 3)
2gaiad tx multisign unsigned.json multisig1 \
3 key1-signature.json \
4 key2-signature.json \
5 --chain-id cosmoshub-4 \
6 --output-document signed.json
7
8# Verify the multisig transaction
9gaiad tx validate-signatures signed.json
10
11# Broadcast the signed transaction
12gaiad tx broadcast signed.json \
13 --chain-id cosmoshub-4
Multisig Workflow
Setup Cosmovisor
Installation
1# Install Cosmovisor
2go install cosmossdk.io/tools/cosmovisor/cmd/cosmovisor@latest
3
4# Verify installation
5cosmovisor version
Directory Structure
1# Create Cosmovisor directory structure
2mkdir -p ~/.gaia/cosmovisor/genesis/bin
3mkdir -p ~/.gaia/cosmovisor/upgrades
4
5# Directory layout:
6# .gaia/
7# βββ cosmovisor/
8# βββ genesis/
9# β βββ bin/
10# β βββ gaiad
11# βββ upgrades/
12# βββ v9/
13# β βββ bin/
14# β βββ gaiad
15# βββ v10/
16# βββ bin/
17# βββ gaiad
Setup Genesis Binary
1# Copy current binary to genesis
2cp $(which gaiad) ~/.gaia/cosmovisor/genesis/bin/
3
4# Verify
5~/.gaia/cosmovisor/genesis/bin/gaiad version
Configure Cosmovisor
1# Set environment variables
2export DAEMON_NAME=gaiad
3export DAEMON_HOME=$HOME/.gaia
4export DAEMON_ALLOW_DOWNLOAD_BINARIES=false
5export DAEMON_RESTART_AFTER_UPGRADE=true
6export DAEMON_LOG_BUFFER_SIZE=512
7
8# Add to ~/.bashrc or ~/.zshrc
9cat >> ~/.bashrc <<EOF
10export DAEMON_NAME=gaiad
11export DAEMON_HOME=\$HOME/.gaia
12export DAEMON_ALLOW_DOWNLOAD_BINARIES=false
13export DAEMON_RESTART_AFTER_UPGRADE=true
14EOF
Prepare Upgrade Binary
1# Download new version
2wget https://github.com/cosmos/gaia/releases/download/v10.0.0/gaiad-v10.0.0-linux-amd64
3
4# Create upgrade directory
5mkdir -p ~/.gaia/cosmovisor/upgrades/v10/bin
6
7# Copy binary
8cp gaiad-v10.0.0-linux-amd64 ~/.gaia/cosmovisor/upgrades/v10/bin/gaiad
9chmod +x ~/.gaia/cosmovisor/upgrades/v10/bin/gaiad
10
11# Verify
12~/.gaia/cosmovisor/upgrades/v10/bin/gaiad version
Systemd Service
1# Create systemd service
2sudo tee /etc/systemd/system/cosmovisor.service > /dev/null <<EOF
3[Unit]
4Description=Cosmovisor daemon
5After=network-online.target
6
7[Service]
8User=$USER
9ExecStart=$(which cosmovisor) run start
10Restart=always
11RestartSec=3
12LimitNOFILE=4096
13Environment="DAEMON_NAME=gaiad"
14Environment="DAEMON_HOME=$HOME/.gaia"
15Environment="DAEMON_ALLOW_DOWNLOAD_BINARIES=false"
16Environment="DAEMON_RESTART_AFTER_UPGRADE=true"
17
18[Install]
19WantedBy=multi-user.target
20EOF
21
22# Reload systemd
23sudo systemctl daemon-reload
24
25# Enable service
26sudo systemctl enable cosmovisor
27
28# Start service
29sudo systemctl start cosmovisor
30
31# Check status
32sudo systemctl status cosmovisor
33
34# View logs
35sudo journalctl -u cosmovisor -f
Cosmovisor Upgrade Flow
Manual Upgrade Test
1# Test upgrade manually
2cosmovisor run start --home ~/.gaia
3
4# Check current version
5cosmovisor run version
6
7# After upgrade height
8# Cosmovisor automatically switches to new binary
Advanced Multisig Operations
Multisig Governance Vote
1# Create unsigned vote transaction
2gaiad tx gov vote 42 yes \
3 --from cosmos1multisig... \
4 --chain-id cosmoshub-4 \
5 --generate-only > vote-unsigned.json
6
7# Sign by multiple parties
8gaiad tx sign vote-unsigned.json \
9 --from key1 \
10 --multisig cosmos1multisig... \
11 --chain-id cosmoshub-4 \
12 --output-document vote-sig1.json
13
14gaiad tx sign vote-unsigned.json \
15 --from key2 \
16 --multisig cosmos1multisig... \
17 --chain-id cosmoshub-4 \
18 --output-document vote-sig2.json
19
20# Combine and broadcast
21gaiad tx multisign vote-unsigned.json multisig1 \
22 vote-sig1.json vote-sig2.json \
23 --chain-id cosmoshub-4 \
24 --output-document vote-signed.json
25
26gaiad tx broadcast vote-signed.json
Multisig Delegation
1# Create delegation transaction
2gaiad tx staking delegate \
3 cosmosvaloper1abc... \
4 1000000uatom \
5 --from cosmos1multisig... \
6 --chain-id cosmoshub-4 \
7 --generate-only > delegate-unsigned.json
8
9# Follow same signing process as above
Troubleshooting
Common Issues
1# Check account sequence
2gaiad query auth account cosmos1multisig...
3
4# If sequence mismatch, recreate transaction with correct sequence
5gaiad tx bank send ... \
6 --sequence 42 \
7 --generate-only > unsigned.json
8
9# Verify multisig configuration
10gaiad keys show multisig1 --multisig-threshold
11
12# Check signature validity
13gaiad tx validate-signatures signed.json
14
15# Simulate transaction before broadcasting
16gaiad tx simulate signed.json
Cosmovisor Debugging
1# Check Cosmovisor status
2cosmovisor version
3
4# List available upgrades
5ls -la ~/.gaia/cosmovisor/upgrades/
6
7# Check current binary
8cosmovisor run version
9
10# Manual upgrade test
11DAEMON_NAME=gaiad cosmovisor run start --home ~/.gaia
12
13# View upgrade info
14gaiad query upgrade plan
Related Snippets
- Blockchain Platforms Overview
Core principles and ideas of major blockchain platforms - Ignite CLI for Cosmos SDK
Ignite CLI commands for building Cosmos SDK blockchains. Quick reference for β¦