This guide will walk you through how to get the native balance associated with a specific wallet address on the C-chain network using the Data API.

Step 1: Set Up AvaCloud

First, ensure that you have set up AvaCloud and have access to your API key. If you’re new to Avacloud, create an account and obtain an API key.

Step 2: Retrieve the Native Balance of an Address

To obtain the native balance of a wallet address you can use Get native token balance endpoint. You’ll need to specify the chainId and the address for which you want to retrieve the balance.

Here’s how you can do it:

Response

{
  "nativeTokenBalance": {
    "chainId": "43114",
    "name": "Avalanche",
    "symbol": "AVAX",
    "decimals": 18,
    "price": {
      "currencyCode": "usd",
      "value": 26.32
    },
    "balance": "3316667947990566036",
    "balanceValue": {
      "currencyCode": "usd",
      "value": 87.29
    },
    "logoUri": "https://images.ctfassets.net/gcj8jwzm6086/5VHupNKwnDYJvqMENeV7iJ/3e4b8ff10b69bfa31e70080a4b142cd0/avalanche-avax-logo.svg"
  }
}

Congratulations 🎉 You’ve successfully retrieved the native balance of a wallet address using just a few lines of code with the AvaCloud Data API!