Send tokens cross-chain
There are three ways to transfer tokens cross-chain with Axelar:
- Call
sendToken
from any source chain. - Get a deposit address using the AxelarJS SDK.
- For tokens not natively supported, build your own Interchain Token.
Call sendToken
sendToken
is an API method that allows you to send any token supported directly on the Axelar network to any recipient on a destination chain.
The underlying mechanics work slightly differently, depending on whether the origin chain is an EVM chain or a Cosmos-based chain:
sendToken
from an EVM Source Chain
- Locate the Axelar Gateway contract on the source chain.
- Execute approve on the source chain (ERC-20).
- Execute sendToken on the Gateway.
1. Locate the Axelar Gateway contract on the source chain
Axelar Gateways are application-layer smart contracts established on source and destination chains. They send and receive payloads, and monitor state. Find a list of Gateway addresses for the chains we support: Mainnet | Testnet.
An Axelar Gateway implements the IAxelarGateway
interface, which has a public method called sendToken
:
2. Execute approve on the source chain (ERC-20)
Transferring tokens through a Gateway is similar to an ERC-20 token transfer. You first need to approve the Gateway to transfer a specific token in a specific amount. This approval is done via the approve
method of the ERC-20 interface:
Here, spender
is the Gateway address on the source chain.
Find a list of assets, their names and their addresses: Mainnet | Testnet. Note that for the same asset denom, the ERC20 symbol could be different on different chains (e.g. USDC
on Ethereum is linked to axlUSDC
on Avalanche).
3. Execute sendToken on the Gateway
Call sendToken
on the Gateway contract of the source chain. Example:
Watch for the tokens to appear at the destination address on the destination chain.
sendToken
from a Cosmos-based Source Chain
From any Cosmos-based source chain, sendToken
is a simple IBC transfer of any asset supported on the Axelar network where the message:
- is sent to the designated admin address on Axelar for receiving GMP (General-Message-Passing) messages -
axelar1dv4u5k73pzqrxlzujxg3qp8kvc3pje7jtdvu72npnt5zhq05ejcsn5qme5
- includes a
memo
field with the following payload:
Using AxelarJS SDK for sendToken
In v0.13.0
+ Axelar’s JS SDK abstracts the invocations above in a one-line JS code that can be called directly from any frontend dApp. Example implementations below:
Example: Invoking sendToken
using the JS SDK from an EVM chain
Example: Invoking sendToken
using the JS SDK from a Cosmos-based chain
Get a deposit address
Use a deposit address if:
- You need functionality not offered by
sendToken
. Example: Cosmos-to-X. - You want to allow token transfers from wallets that don’t know anything about Axelar. Example: Withdrawal from a centralized exchange.
You’ll find the SDK method to getDepositAddress
as a part of the AxelarJS SDK.