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:
Instantiate the AxelarQueryAPI
module:
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 gas limit is equal to the execution gas cost on the destination chain. You can test out GMP calls to find the correct value. - The
minGasPrice
andgasMultipler
parameters can be adjusted to enhance execution certainty of cross-chain transactions. - L2 chains. For execution of GMP calls where the destination chain is an EVM L2 chain, it is important to note that all L2 chains have an extra cost of posting the executed transaction back to the L1 chain. This
estimateGasFee
SDK method will aggregate that estimated cost for you. The parameters to call out specifically for L2s are:- the
gasLimit
parameter, which are the actual gas units required to execute the tx on the L2 chain. You can check this empirically by looking at the gas used to execute theAxelarExecutable
on the destination chain. - the
executeData
parameter, which is the GMP data to be executed on the L2 destination chain. This is important for OP-stack chains, where the SDK queries a gas oracle contract with this executeData to retrieve the L1 fee, and if the parameter forexecuteData
is not provided, a stub piece ofexecuteData
is used.
- the
- 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 specifyingtrue
forshowDetailedFees
. 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,(baseFee + executionFeeWithMultiplier + l1ExecutionFeeWithMultiplier)
for regular way GMP calls to any L2 chains,(baseFee + executionFeeWithMultiplier + expressFee)
for GMP Express calls
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.
getFeeForChainAndAsset
Given a chain and asset, retrieves the base fee that the network would assess.
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.
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:
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).
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: