Skip to main content

Query

safrochaind query is a read-only client. It hits the node specified by --node (default: tcp://localhost:26657) and returns gRPC results formatted as JSON / YAML / text. None of these commands sign or broadcast.

safrochaind query --help

Common namespaces

NamespacePurpose
query authaccounts, module accounts, sequence numbers
query bankbalances, supply, denom metadata
query stakingvalidators, delegations, redelegations, params
query distributionrewards, commission, community pool
query slashingsigning infos, params
query govproposals, votes, tallies, params
query mintinflation, annual provisions, params
query upgradeapplied/plan upgrades
query ibc-transferdenom traces, escrow addresses
query ibc client/connection/channelfull IBC graph
query feegrantfee grants between addresses
query authzexec authorisations
query groupx/group accounts and decisions
query consensusconsensus params
query blockblock-by-height (height = arg)
query txtx-by-hash
query txstx search by event

Cookbook

Account & sequence number

safrochaind query auth account addr_safro1abc... -o json \
| jq '.account.value | {address, account_number, sequence}'

Total supply (bank.total)

safrochaind query bank total --denom usaf

Inflation & community-pool size

safrochaind query mint inflation
safrochaind query distribution community-pool

Tx by hash

TX=AB12...
safrochaind query tx "$TX" -o json | jq '.code, .raw_log, .gas_used, .gas_wanted'

Search transactions by event

# all sends to a given recipient in the last block window
safrochaind query txs --query "transfer.recipient='addr_safro1abc...'" --limit 50
# all delegations from a given delegator
safrochaind query txs --query "delegate.delegator='addr_safro1abc...'" --limit 50
# all proposals created
safrochaind query txs --query "submit_proposal.proposal_id>=1"

The query DSL supports =, <, <=, >=, and combinations with spaces.

Block at a height

safrochaind query block --type=height 1000
safrochaind query block --type=hash <block-hash>

Validator signing info (downtime tracker)

safrochaind query slashing signing-infos -o json \
| jq '.info[] | select(.tombstoned == false) |
{address, missed_blocks_counter, jailed_until}'

missed_blocks_counter is reset every signed_blocks_window. If it exceeds signed_blocks_window * (1 - min_signed_per_window) the validator is jailed.

IBC client expiry

safrochaind query ibc client states -o json \
| jq -r '.client_states[] | "\(.client_id)\t\(.client_state.frozen_height.revision_height)\t\(.client_state.latest_height.revision_height)"'

Fee grants (someone is paying my fees)

ME=$(safrochaind keys show alice -a)
safrochaind query feegrant grants-by-grantee "$ME"

Performance tips

  • Use --height N to query historical state. Archive nodes keep it back to genesis; pruned nodes only keep the last pruning_keep_recent blocks.
  • Use -o json | jq for scripting; never grep raw text output.
  • For high-volume reads, run your own RPC node. See Run a Node → Join mainnet.