Function getCosmWasmClient

Returns a interface used to interact with the CosmWASM Contracts on chain. getCosmWasmClient contains helper functions to get a CosmWasmClient. Thi should be used for querying smart contracts only. If you need to call a contracts execute msg, see the SigningCosmWasmClient below.

import { DirectSecp256k1HdWallet } from "@cosmjs/proto-signing";
import { getCosmWasmClient } from "@sei-js/cosmjs";

// Create a CosmWasmClient
const cosmWasmClient = await getCosmWasmClient(RPC_URL);

Build the queryMsg according to the contracts specific query specifications. Each contract will define its own queryable state, so check the contract documentation for the correct query message format by examining the contract source code or documentation.

// Create the query msg json based on contract specific query specifications
const queryMsg = {
tokens: {
owner: address,
},
};

// Query a smart contract state
const queryResponse = cosmWasmClient.queryContractSmart(CONTRACT_ADDR, queryMsg);
  • Parameters

    • rpcEndpoint: string | HttpEndpoint

      The url of the RPC Endpoint used to connect to the Sei chain.

    Returns Promise<CosmWasmClient>

    A CosmWasmClient used to interact with the Sei chain.