Logos Kit

Read balances and data

Balances for shared accounts, public account data, and status.

Reads are module calls: they never open the wallet and return quickly.

Balances

kit.api.getWalletBalance(root.account).then(function (b) {
    root.balance = b.amount          // "1000000000": lepta, so 1 LGO (a string: u128 never becomes a JS number)
    root.synced = b.synced           // false while a private account is still syncing
})

// A token: pass its definition account.
kit.api.getWalletBalance(root.account, tokenDefinition).then(function (b) { … })
Field
amountThe raw integer amount, as a decimal string: lepta for the native token (1 LGO = 10^9 lepta), a token's base units otherwise
assetThe token definition, or native
syncedPrivate accounts: whether the wallet has caught up with the chain
asOfBlockThe block the balance is from

Private handles (pvt_…) work too, if the user shared that account.

Format with the SDK's helpers, never with JS numbers:

kit.sdk.formatUnits(b.amount, 9) + " LGO"   // "1000000000" → "1 LGO"
kit.sdk.parseUnits("2.5", 9)                // what the user typed in LGO → "2500000000" lepta
kit.sdk.formatUnits("1500000", 6)           // a token with 6 decimals: "1.5"

The native token is LGO, with 9 decimals. formatUnits shows up to 9, rounds nothing and trims trailing zeros: 1 lepta is 0.000000001 LGO.

Public account data

kit.api.readAccount(accountId, programId).then(function (a) {
    // { nonce, data }: the account's data under that program, as bytes
})

The network

kit.chain                            // "lez:testnet", follows the wallet
kit.api.getChainId()                 // ask the wallet directly

See Follow the network.

In TypeScript

The same reads work from Node against any sequencer. From a browser they work only against endpoints that send CORS headers. The official testnet's RPC doesn't, so Logos Kit runs a relay for it that does: https://lez-testnet.84.46.247.92.sslip.io.

import { createClient, http, nodeActions } from '@logos-kit/client'

const node = createClient({
  transport: http('https://lez-testnet.84.46.247.92.sslip.io'),   // from Node, https://testnet.lez.logos.co works too
  chain: 'lez:testnet',
}).extend(nodeActions)

const height = await node.getBlockNumber()

See TypeScript client.

On this page