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

getBalance

Read the balance of a single denom for an address.

Signature

function getBalance(
  client: Client,
  parameters: {
    address: Address
    denom: Denom
    height?: number
  },
): Promise<string>

Example

import { createPublicClient, createTransport, testnet } from "@left-curve/sdk"
import { Decimal } from "@left-curve/utils"
import type { Address } from "@left-curve/sdk"
 
const client = createPublicClient({ chain: testnet, transport: createTransport() })
const address: Address = "0x1234567890abcdef1234567890abcdef12345678"
 
const amount = await client.getBalance({ address, denom: "dango" })
 
// Parse with Decimal or BigInt for arithmetic
const human = Decimal(amount).div(Decimal(10).pow(6)) // assuming 6 decimals

Parameters

addressAddress. The account to query.

denomDenom. The token denomination.

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

Returns

string — the balance in base units, exactly as returned by the chain. Parse with BigInt or Decimal before doing arithmetic.

See also