Skip to main content
CosmJS provides two ways to query on-chain data: convenience methods on the high-level clients (StargateClient, CosmWasmClient) and a low-level QueryClient with composable module extensions. Choose the approach that fits your needs — high-level methods for common tasks, extensions for full module coverage.

Prerequisites

  • @cosmjs/stargate installed (npm install @cosmjs/stargate)
  • A connected client (see Connect to a Chain)

Quick Start

High-Level Client Methods

StargateClient bundles the most common queries behind simple methods. These cover bank, staking, auth, and transaction queries out of the box. CosmWasmClient extends these with contract-specific queries:

Using QueryClient with Extensions

For queries beyond what the high-level clients expose, build a QueryClient with the exact extensions you need. This gives you typed access to every query endpoint in each Cosmos SDK module.
Extensions are merged into the QueryClient instance. Each one adds a namespace — queryClient.bank, queryClient.staking, queryClient.gov, etc. You can compose up to 18 extensions in a single call.

Combining Multiple Extensions

You can compose any combination of extensions to build a query client tailored to your needs:
Each extension is independently typed — TypeScript knows exactly which namespaces and methods are available based on the setup functions you pass.

Next Steps

Bank Queries

Token balances, supply, and denomination metadata.

Staking Queries

Validators, delegations, unbonding, and staking pool.

Governance Queries

Proposals, votes, deposits, and tallies.

Account Queries

Account info, auth extension, and custom parsers.

Distribution & Mint

Staking rewards, commission, inflation, and community pool.

IBC Queries

Channels, connections, clients, and transfer denominations.

Transaction Queries

Search, decode, and inspect transactions and events.

CosmWasm Queries

Smart contract state and metadata queries.

Pagination

Navigate large result sets page by page.

Blocks & Chain Info

Block data, chain status, and CometBFT RPC.

Custom Extensions

Write query extensions for custom chain modules.

Error Handling

Handle missing data, NotFound errors, and broadcast failures.