Step 4: Displaying Chain-Aggregated Balances

You can access the relevant API endpoint for aggregated balances here.

This API aggregates balances across the chains supported by the application and takes resource locks into account. When funds on the source chain are locked for asynchronous cross-chain execution, the balance may differ from the direct sum of RPC-based balances.

Example client-side query for retrieving balances:

fetch(`https://be.onebalance.io/api/balances/aggregated-balance?address=${'<ONEBALANCE SCA ADDRESS HERE>'}`, {
    headers: {
      "x-api-key": '<YOUR ONEBALANCE API KEY HERE>',
    },
  })

The address expected in the Search Params of the request is the OneBalance SCA you have retrieved from the /predict-address endpoint previously.

For more details, see the implementation in our sample application here.

Last updated