Send tokens cross-chain
There are three ways to transfer tokens cross-chain with Axelar:
sendTokenon an Axelar gateway EVM contract.
- Get a deposit address using the AxelarJS SDK.
- For tokens not natively supported, build your own Interchain Token.
- Your dApp transfers EVM-to-X where X is one of EVM, Cosmos.
- Your dApp uses smart contracts.
- 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
function sendToken( string memory destinationChain, string memory destinationAddress, string memory symbol, uint256 amount ) external;
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:
function approve(address spender, uint256 amount) external returns (bool);
spender is the Gateway address on the source chain.
Find a list of assets, their names and their addresses: Mainnet | Testnet.
3. Execute sendToken on the Gateway
sendToken on the Gateway contract of the source chain. Example:
sendToken( "avalanche", // destination chain name "0xF16DfB26e1FEc993E085092563ECFAEaDa7eD7fD", // some destination wallet address (should be your own) "USDC", // asset symbol 100000000 // amount (in atomic units) )
Watch for the tokens to appear at the destination address on the destination 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.