How to Get All Token Balances Using Axelar API? Complete Guide

With the growing popularity of blockchain technologies more and more new networks, scaling solutions, and crypto tokens come to market. If this technological upheaval has deeply integrated into your everyday life, as well as your development and business processes, you might know how it can be inconvenient sometimes to keep everything organized. Different blockchains usually exist in Silo (an isolated point in a system where data is kept segregated) and hardly communicate with each other. That’s why having innovative interoperability solutions such as Axelar is crucial NOWadays. As people speaking different languages need a translator to make communication possible and easy, different blockchain networks also need some kind of translator such as Axelar for similar reasons. 

In this article, we are going to provide you with an explanation of how to get all your coin balances organized by using some methods available on the Axelar network. However, before we’ll dive deep into the subject of the article let’s explore what Axelar Network is.

Table of Contents

    What Is the Axelar Network?

    The Axelar Network is a decentralized communication protocol designed to provide interoperability between different blockchains. It enables various networks to communicate and share information seamlessly, including transferring assets and executing cross-chain smart contracts. For developers and users within the blockchain ecosystem, Axelar stands as a bridge that connects isolated blockchain networks, allowing them to work together in a unified environment. To better understand the principles of Axelar Network, think of it as:

    • Blockchain that connects blockchains
    • “Internet of blockchains“
    • A translator for blockchain protocol languages
    • “An air traffic control system that handles transportation, routing, and customs/border control (validation) between blockchains”

    The network is built on a foundation of decentralized validators and delegators, developer tools such as SDKs and APIs, secure smart contracts, aiming to streamline the integration and interaction with various blockchains for developers. It’s designed to offer dApp creators seamless cross-chain compatibility and enable users to smoothly engage with dApps across different blockchain platforms.

    AXL, the native utility token of the Axelar Network, facilitates transaction processing within the network. Additionally, it serves purposes in staking and the decentralized decision-making process due to Axelar’s Delegated Proof-of-Stake consensus mechanism.

    Axelar API Check Balance Methods

    Axelar’s native blockchain is a Cosmos-based network designed to enhance the compatibility of different blockchains. In order to interact with the network and perform on-chain activities you can utilize Axelar RPC and LCD nodes via Cosmos API methods. There are various methods available that you can explore at NOWNodes documentation including Axear’s Tendermint methods.

    Axelar offers several methods to check token balances on its network. By utilizing Axelar’s API, one can easily retrieve token balances, ensuring a smooth and efficient way to interact with blockchain assets.

    So, there are two basic methods perfectly suitable for what you are looking for – check all token balances available on Axelar’s wallet address. 

    • /cosmos/bank/v1beta1/balances/{address}
      • AllBalances queries the balance of all coins for a single account address. 
    • /cosmos/bank/v1beta1/spendable_balances/{address}
      • SpendableBalances queries the spendable balance of all coins for a given account address.
    Make sure that you use the required Axelar wallet address utilizing these methods, any other crypto wallet address won’t work.

    Further, we will break down these methods in detail, but before utilizing these methods in practice, there’s one crucial step that you can not miss – accessing Axelar RPC full nodes. There are two ways to connect to the Axelar network: 

    1. Run your own Axelar node,
    2. Use third-party node providers like NOWNodes.

    Considering that option 1 is extremely time-consuming, resource-intensive, and financially expensive, we highly recommend you use node providers such as NOWNodes. Our Blockchain-as-a-Service solution that provides access to Full Nodes is practically designed to save your time and money, preventing you from taking responsibility for running your own nodes in cases when you don’t need to, as well as to make your Web3 development and crypto business processes as easy as possible. 

    How to Use Axelar RPC Nodes Endpoints with NOWNodes? A Full Tutorial

    NOWNodes is a blockchain-as-a-service solution that lets users access Full Nodes and Blockbook Explorers via API. The service provides a high-quality infrastructure that is quick, cost-effective, and reliable. We have Service Quality Standards available for all partners.

    In order to utilize Axelar blockchain API endpoints and obtain access to Axelar nodes, you need to connect to the Axelar network via NOWNodes’ endpoints. Here’s a step-by-step guide on how you could do this:

    Step 1: Visit NOWNodes and Sign Up

    Begin by visiting the NOWNodes website (https://nownodes.io/) and sign up with your email address. The registration process is pretty simple and unified: after creating your account, you need to verify your email address.

    Step 2: Sign Up for an Account at the NOWNodes Website and Create an API Key

    There are various subscription plans suitable for different development needs. Whether you’re a beginner, you could use our START FREE plan, or you’re an Enterprise owner – we have an ENTERPRISE plan for you, offering 100 MILLION requests/month

    Keep in mind that with the START plan, you can choose up to 5 blockchain networks and work with the Axelar node endpoint. If you need the Axelar blockchain, scroll down and click on the button next to the “AXL” ticker.

    If you wish to work with the Tendermint node interface, it is only available in the PRO plan and higher.

    As soon as you’re in a dashboard, you can create your Personal API Key. All you have to do is click the “GET FREE API KEY” button to access the Axelar mainnet full nodes.

    Step 3.1: Connect to Axelar LCD Node API via Preferred API Environment

    When the registration process is completed and the API environment is ready to be used, it’s time to utilize the Axelar Node API. 

    • Use the general endpoint axelar.nownodes.io to connect to the Axelar RPC Full Node; 
    • We support all methods that are located in our Official Documentation.

    Here’s a simple example of how to make a call to get account details based on address:

    curl --location 'https://axelar.nownodes.io/cosmos/auth/v1beta1/accounts/<address>' \
    --header 'Accept: */*'

    Step 3.2: Connect to Axelar Tendermint Nodes via Preferred API Environment

    Besides Axelar’s Mainnet LCD Full Node NOWNodes also provides access to the Tendermint instance available on Axelar network. 

    What is an Axelar Tendermint?

    Tendermint is the consensus engine of the Axelar blockchain, offering an RPC interface through its endpoint for direct interaction with the blockchain’s consensus layer, including block and transaction data, consensus state, etc. NOWNodes’ Axelar Tendermint endpoint (axelar-tendermint.nownodes.io) provides in-depth insights into the blockchain’s consensus mechanism and validator information.

    Similarly, you can connect to Axelar’s Tendermint nodes to utilize Tendermint-specific functionalities, such as subscribing to real-time events.

    In order to access the Axelar Tenderming instance via NOWNodes, you will need to use another endpoint. Make sure you have a PRO pricing plan or higher.  

    Additionally, the locations of the methods are the same as in step 3.1.

    • Import axelar-tendermint.nownodes.io endpoint to connect to this instance. 
    • We support all methods which are located in our Official Documentation.
    • Try them out by adding the provided endpoint and your API key.

    Once you’ve connected to the Axelar’s Tendermint it’s time to make some requests to start. Here’s a sample one, that you can copy & paste to try:

    curl --location 
    'https://axelar-tendermint.nownodes.io/block?height='

    Axelar API AllBalances Method

    The AllBalances method in Axelar’s API allows you to retrieve all token balances for a specific address. This is incredibly useful for getting a comprehensive view of an address’s assets. Here’s an example of how to use the AllBalances method:

    curl --location 'https://axelar.nownodes.io/cosmos/bank/v1beta1/balances/<your_address>' \
    --header 'Accept: */*' \
    --header 'api-key: <your_api-key> '

    Below, you can see a sample response: 

    {
        "balances": [
            {
                "denom": "uaxl",
                "amount": "89990930"
            }
        ],
        "pagination": {
            "next_key": null,
            "total": "1"
        }

    By making this request you can get the total balances of all tokens held by an account at the specified address. The “total balances” include all tokens, regardless of their status, meaning it sums up both locked (e.g., in staking, governance, or vesting) and spendable tokens.

    Axelar API SpendableBalances Method

    SpendableBalances is another useful method that specifically fetches the balances of tokens that are available to spend. This can be particularly useful for applications that need to verify user funds before initiating transactions. Here’s a sample request: 

    curl --location 'https://axelar.nownodes.io/cosmos/bank/v1beta1/spendable_balances/<your_address>' \
    --header 'Accept: */*' \
    --header 'api-key: <your_api-key> '

    Here’s a sample response: 

    {
    	"balances": [
    		{
    			"denom": "uaxl",
    			"amount": "4997499"
    		}
    	],
    	"pagination": {
    		"next_key": null,
    		"total": "1"
    	}
    }

    In contrast, this API method specifically fetches the spendable balances of an account. “Spendable balances” refer to the portion of tokens that are freely available for the account holder to transfer or spend in other transactions, excluding tokens that are currently locked or reserved for specific purposes. This method is particularly useful for applications or services that need to determine an account’s liquid assets, such as wallets or DeFi platforms where users might need to know how much they can transact at any given time.

    There are numbers of other API commands available to interact with the Axelar network. You can explore all of them in NOWNodes Documentation. Here are a few other methods that you might need in order to communicate with the Axelar network for checking token balances. 

    • https://axelar.nownodes.io/cosmos/bank/v1beta1/balances/<address>/<by_denom> 
      • Balance queries the balance of a single coin for a single account. You would replace <address> with the actual Axelar address and <by_denom> with the specific token denomination you want to query. This allows you to get a detailed view of how much of a particular token an account holds, which is useful for wallet services, user balance displays, and other applications needing.
    • https://axelar.nownodes.io/cosmos/bank/v1beta1/supply
      • TotalSupply queries the total supply of all coins. This endpoint provides the total supply of all tokens available on the Axelar network. When you query this endpoint, you get information about the quantity of each token that exists within the network
    • https://axelar.nownodes.io/cosmos/bank/v1beta1/params:
      • This endpoint retrieves the parameters of the bank module of the Axelar network. The bank module’s parameters can include settings like default send enabled status (which indicates if token transfers are enabled by default) and any other parameters that govern how tokens are managed and transferred within the network.
    • https://axelar.nownodes.io/cosmos/bank/v1beta1/denoms_metadata:
      • This endpoint provides metadata for all token denominations available on the Axelar network. The metadata can include information like the token’s name, symbol, decimal places, and other relevant details that describe the token’s properties. This is particularly useful for developers building applications that need to display detailed token information to users.

    Each of these endpoints serves a specific purpose in querying token information on the Axelar network, from individual account balances to overall token supply and detailed token descriptions, supporting a wide range of applications and analyses within the ecosystem.

    Conclusion

    With the constant enhancement of blockchain technologies, cross-chain interoperability networks such as Axelar play an important role in the Web3 world. Axelar works on the back end, connecting various networks into one-click experiences for all users.

    The Axelar Network offers powerful tools and methods for seamlessly checking token balances across multiple blockchains, making it an invaluable resource for developers in the Web3 space. By following the steps outlined above, you can easily integrate Axelar’s functionalities into your applications, enhancing your blockchain interactions and capabilities. Whether you’re building a wallet, a DeFi platform, or any other dApp, understanding and utilizing Axelar’s balance-checking methods will significantly contribute to your project’s success.

    Please let us know if this guide was helpful by leaving your feedback in the comments in our Telegram Builders Community or just by hitting our DMs at X/Twitter.

    Explore Axelar’s Internet-Scale Interoperability #NOW