Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

queryApp

Send a generic typed query against the app and receive the matching QueryResponse variant.

Signature

function queryApp(
  client: Client,
  parameters: {
    query: Json
    height?: number
  },
): Promise<QueryResponse>

Example

import { createPublicClient, createTransport, testnet } from "@left-curve/sdk"
import type { Address } from "@left-curve/sdk"
 
const client = createPublicClient({ chain: testnet, transport: createTransport() })
const address: Address = "0x1234567890abcdef1234567890abcdef12345678"
 
const res = await client.queryApp({
  query: { balance: { address, denom: "dango" } },
})
if ("balance" in res) {
  console.log(res.balance.amount)
}

Parameters

queryJson. A QueryRequest variant — e.g. { balance: { address, denom } }, { contracts: {...} }, { wasmSmart: {...} }.

heightnumber, optional. Block height to query at. Default 0 (latest).

Returns

QueryResponse — a discriminated union. Narrow with the in operator to extract the matching variant.

Notes

  • Most callers use the typed wrappers (getBalance, getContractInfo, etc.). Use queryApp directly only for variants that lack a wrapper or for batched multi queries.
  • The SDK does not auto-narrow the response — you must check the variant name.

See also