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 decimalsParameters
address — Address. The account to query.
denom — Denom. The token denomination.
height — number, 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
getBalances— all balances for an address as aCoinsrecordgetSupply— total supply of one denom- Concepts: Encoding & Types