IntroductionCosmos GMPSolidity UtilitiesSandbox
InterchainTokenServiceInterchainTokenFactoryTokenManagerAxelarGateway AxelarGasServiceAxelarExecutableAxelarJS SDK
Crosschain Message FlowaxlUSDCSecurity OverviewInterchain Transaction DurationEVM Contract Governance

Axelar query API

This module is a nice-to-have of common queries made into the Axelar network and its services that are abstracted into easy-to-use JavaScript one-liners.

Install the AxelarJS SDK module (AxelarQueryAPI)

Install the AxelarJS SDK:

npm i @axelar-network/axelarjs-sdk

Instantiate the AxelarQueryAPI module:

const sdk = new AxelarQueryAPI({
  environment: "testnet",
});

Possible queries

estimateGasFee

This is a useful query for GMP transactions, when invoking callContract or callContractWithToken to get an estimate of the appropriate gas payment to be made to the gas receiver on the source chain.

IMPORTANT NOTES:

  • You must ensure the correct gasLimit is used for your gas estimation. The gasLimit parameter can be used here to override the default 700K gas limit that is used.
  • The minGasPrice and gasMultipler parameters can be adjusted to enhance execution certainty of cross-chain transactions.
  • The response to the method gives a single value (in wei) of the total estimated gas required for the cross-chain call. In the GMPParams parameter, there is an option to show a full breakdown of fees instead by specifying true for showDetailedFees. If you do this, you will have to add the individual components of the fees yourself, e.g. (baseFee + executionFeeWithMultiplier) for regular way GMP calls, or (baseFee + executionFeeWithMultiplier + expressFee) for GMP Express calls

  interface GMPParams {
    showDetailedFees: boolean;
    transferAmount: number; // In terms of symbol, not unit denom, e.g. use 1 for 1 axlUSDC, not 1000000
    destinationContractAddress: string;
    sourceContractAddress: string;
    tokenSymbol: string;
  }
  export interface AxelarQueryAPIFeeResponse {
    expressFee: string;
    baseFee: string;
    executionFee: string;
    executionFeeWithMultiplier: string;
    gasMultiplier: number;
    gasLimit: number;
    srcGasPrice: string;
    minGasPrice: string;
    apiResponse: any;
    isExpressSupported: boolean;
  }

  /**
   * Calculate estimated gas amount to pay for the gas receiver contract.
   * @param sourceChainId
   * @param destinationChainId
   * @param sourceChainTokenSymbol
   * @param gasLimit An estimated gas amount required to execute `executeWithToken` function. The default value is 700000 which should be sufficient for most transactions.
   * @param gasMultiplier (Optional) A multiplier used to create a buffer above the calculated gas fee, to account for potential slippage throughout tx execution, e.g. 1.1 = 10% buffer. supports up to 3 decimal places
   * The default value is "auto", which uses the `execute_gas_multiplier` from the fee response.
   * @param minGasPrice (Optional) A minimum value, in wei, for the gas price on the destination chain that is used to override the estimated gas price if it falls below this specified value.
   * @param gmpParams (Optional) Additional parameters for GMP transactions, including the ability to see a detailed view of the fee response
   * @returns
   */
  public async estimateGasFee(
    sourceChainId: EvmChain | string,
    destinationChainId: EvmChain | string,
    sourceChainTokenSymbol: GasToken | string,
    gasLimit: number,
    gasMultiplier = 'auto',
    minGasPrice = "0",
    gmpParams?: GMPParams
  ): Promise<string | AxelarQueryAPIFeeResponse>

getTransferFee

Given a source chain, destination chain and amount of an asset, this query retrieves the base fee that the network would assess for that transaction.

/**
 * Gets the transfer fee for a given transaction
 * @param sourceChainName
 * @param destinationChainName
 * @param assetDenom
 * @param amountInDenom
 * @returns
 */
public async getTransferFee(
  sourceChainName: string,
  destinationChainName: string,
  assetDenom: string,
  amountInDenom: number
): Promise<TransferFeeResponse>

getFeeForChainAndAsset

Given a chain and asset, retrieves the base fee that the network would assess.

/**
 * Gets the fee for a chain and asset
 * @param chainName
 * @param assetDenom
 * @returns
 */
public async getFeeForChainAndAsset(
  chainName: string,
  assetDenom: string
): Promise<FeeInfoResponse>

getDenomFromSymbol

Get the denom for an asset given its symbol on a chain. For all the assets that Axelar supports natively, the network identifies the asset by a denom, while most EVM chains have a symbol for the asset.

The method below allows you to translate the asset symbol (as identified on an EVM chain) to the underlying denom.

/**
 * @param symbol
 * @param chainName
 * @returns
 */
public async getDenomFromSymbol(symbol: string, chainName: string)

For example, let’s say you have Axelar’s canonical testnet aUSDC. The symbol for this asset on EVM chains is aUSDC, and the denom is uausdc. Sample usage to get denom from symbol:

  const queryConfig: AxelarQueryAPIConfig = {
    environment: Environment.TESTNET
  }
  const api = new AxelarQueryAPI(queryConfig);

  async function main() {
    const denom = await api.getDenomFromSymbol("aUSDC", "moonbeam");
    console.log("denom: ",denom);
    return denom;
  }

  //expected returned result: uausdc

getSymbolFromDenom

Get the symbol for an asset on a given chain given its denom. For all the assets that Axelar supports natively, the network identifies the asset by a denom, while most EVM chains have a symbol for the asset.

The method below allows you to translate the asset denom to the asset symbol (as identified on an EVM chain).

/**
 * @param denom
 * @param chainName
 * @returns
 */
public async getSymbolFromDenom(denom: string, chainName: string)

For example, let’s say you have Axelar’s canonical testnet aUSDC. The symbol for this asset on EVM chains is aUSDC, and the denom is uausdc. Sample usage to get symbol from denom:

  const queryConfig: AxelarQueryAPIConfig = {
    environment: Environment.TESTNET
  }
  const api = new AxelarQueryAPI(queryConfig);

  async function main() {
    const symbol = await api.getSymbolFromDenom("uausdc", "moonbeam");
    console.log("symbol: ",symbol);
    return symbol;
  }

  //expected returned result: aUSDC
Edit this page
On this page