How to check my balance with GraphQL

Preparation

  • A agent address: All of balances stored in a agent’s address.
    • i.e., 0x6132331720A774274d6E51CaeAd375068cC00505
  • A currency type to check
    • i.e., NCG
  • GraphQL server url

Step by step

Step #1

Open or connect to a GraphQL server.

Open the DOCS.


Search balance in DOCS and you can see the StateQuery.balance query.

Step #2

Let’s type the StateQuery.balance query in coding area!

Search Address on DOCS.

Type address as an argument of the balance query.

Search CurrencyInputType on DOCS.

Type currency as an argument of the balance query. We’ll can get the minters address like this.

Type quantity in the body of the balance query.

And click the play button to send the query.

Then here we can get the result.

Here is the query.

query
{
  stateQuery
  {
    balance
    (
      address: "0x6132331720A774274d6E51CaeAd375068cC00505",
      currency:
      {
        ticker: "NCG",
        decimalPlaces: 2,
        minters:
        [
          "0x47D082a115c63E7b58B1532d20E631538eaFADde"
        ]
      }
    )
    {
      quantity
    }
  }
}

Get currency’s minters addresses

This query did not released yet.(PR link)

query
{
  addressQuery
  {
    currencyMintersAddress(currency: NCG)
  }
}