Link Search Menu Expand Document

Queries

If the methods of the CosmWasmClient are no longer sufficient, you can also instantiate a QueryClient yourself. With the help of various extensions, different types of queries can be executed.

Example

import {
  SigningCosmWasmClient,
  setupStakingExtension,
  QueryClient,
} from "cosmwasm";

// Get all delegations of a delegator
const getAllDelegations = async (delegator, rpcUrl) => {
  // Instantiate tmClient
  const tmClient = await Tendermint34Client.connect(rpcUrl);

  // Create client with stakingExtension
  const client = QueryClient.withExtensions(tmClient, setupStakingExtension);

  return await client?.staking.delegatorDelegations(delegator);
};

const delegations = getAllDelegations("YourDelegatorAddress", "YourRpcUrl");

console.log(delegations);

Extensions

Depending on what query is needed, queries are divided into different extensions:

  • 🔗 AuthExtension Information about an account
  • 🔗 BankExtension Information about account balances, denoms and supply
  • 🔗 DistributionExtension Information about community pools, delagations/delegators and validators
  • 🔗 GovExtension Information about proposals, deposits and votes
  • 🔗 IbcExtension Information about IBC data
  • 🔗 MintExtension Information about inflation and provisions
  • 🔗 StakingExtension All information about staking related stuff
  • 🔗 TxExtension Information about transactions

🔗 Back to clients overview


Table of contents