Querying account balance

Retrieve account balances given an address.

In this example, we will be retrieving the balances of the following address:

For this example, we will be querying balances of address: swth16kazgeq55j49tsqer0ffxhyupkxca0sq3c4cll

JavaScript SDK

See Initializing CarbonSDK for details on instantiating the JavaScript SDK.

Query balance using gRPC query module

const balances = await sdk.query.bank.AllBalances({
  address: "swth16kazgeq55j49tsqer0ffxhyupkxca0sq3c4cll",
});
// result
{
    "denom": string
    "amount": string
}

Query balance using Stargate client

// sdk.query.chain is actually a StargateClient

const address = "swth16kazgeq55j49tsqer0ffxhyupkxca0sq3c4cll";
const balances = await sdk.query.chain.getAllBalances(address);
// result
{
    "balances": [{
        "denom": string
        "amount": string
    }],
    "pagination": {
        "nextKey": Uint8Array
        "total": Long
    }
}

RESTful gRPC

Check out the Carbon RPC reference for a list of available REST endpoints.

Query all balances for address

GET https://api.carbon.network/cosmos/bank/v1beta1/balances/{address}

Path Parameters

NameTypeDescription

address*

String

Carbon address

{
  "balances": [
    {
      "denom": "swth",
      "amount": "99988998800000000"
    }
  ],
  "pagination": {
    "next_key": null,
    "total": "1"
  }
}

Command-line Interface

Use carbond --help for a list of available commands

carbond query bank balances <address>
 carbond query bank balances swth16kazgeq55j49tsqer0ffxhyupkxca0sq3c4cll
balances:
- amount: "100000000000000000"
  denom: btc
- amount: "100000000000000000000000000"
  denom: eth
- amount: "1000000000000000000000"
  denom: iusd
- amount: "4999899900000000"
  denom: swth
pagination:
  next_key: null
  total: "0"

Last updated