Link Search Menu Expand Document

CosmWasmClient

About

The class CosmWasmClient is exported from the CosmJS package @cosmjs/cosmwasm-stargate (🔗 Link). It already comes with a handful of methods that can be used to execute frequently used queries.

It is used only to execute queries. NOT to work with signed transactions. If you are looking for the documentation for this, please see the 🔗 CosmWasmSigningClient documentation.

To execute extended queries, please refer to the 🔗 Query documentation.

Usage

import { CosmWasmClient } from "cosmwasm";

// This is your rpc endpoint
const rpcEndpoint = "https://rpc.cliffnet.cosmwasm.com:443/";

async function main() {
  const client = await CosmWasmClient.connect(rpcEndpoint);
  console.log(client);
}

main();

Available Methods

General

Method Description Params
.connect() Returns the client. tmClient: Tendermint34Client
.getChainId() Get current chain’s ID. none
.getHeight() Get current height of the chain. none
.getAccount() Get more information about an account. searchAddress: string
.getSequence()   address: string
.getBlock()   height?: number
.getBalance()   address: string, searchDenom: string

Transactions

Method Description Params
.getTx()   id: string
.searchTx()   query: SearchTxQuery, filter: SearchTxFilter = {}
.txsQuery()   query: string

Codes

Method Description Params
.getCodes()   none
.getCodeDetails()   codeId: number

Smart Contracts

Method Description Params
.getContracts()   cideId: number
.getContract()   address: string
.queryContractRaw()   address: string, key: Uint8Array
.queryContractSmart()   address: string, queryMsg: Record<string, unknown>