This example demonstrates how to mint tokens on a source chain and transfer them to a destination chain.
The cross-chain token transfer method described below provides a basic example for reference but is not recommended for production use cases. For token bridges or transfers in testnet or mainnet, we recommend using the Axelar Interchain Token Service (ITS).
The Axelar Interchain Token Service provides a robust, managed service for creating cross-chain tokens and bridges. Key benefits include:
- Create new ERC-20 tokens available on multiple chains
- Bridge existing ERC-20 tokens across chains
- Flexibility for standardized tokens or custom logic
- Built-in security, monitoring, and reliability features
- Easy integration into dApps with SDKs
See the ITS docs for usage, APIs, and more details.
The example below provides a basic local implementation for reference.
Make sure you've already followed the following steps:
To deploy the contract, use the following command:
npm run deploy evm/cross-chain-token [local|testnet]
The command above pertains to specifying a project's intended environment to execute. It provides the option to choose between local and testnet environments by appending either local
or testnet
after the command.
An example of its usage is npm run deploy evm/cross-chain-token local
or npm run deploy evm/cross-chain-token testnet
.
To execute the example, use the following command:
npm run execute evm/cross-chain-token [local|testnet] ${srcChain} ${destChain} ${amount}
Default Values:
srcChain
isAvalanche
. Valid values are Moonbeam, Avalanche, Fantom, Ethereum, and PolygondestChain
isFantom
. Valid values are Moonbeam, Avalanche, Fantom, Ethereum, and Polygonamount
is10
This example deploys the contract on a local network, mints one token on the Ethereum chain, and transfers it to the Fantom chain.
npm run deploy evm/cross-chain-token local
npm run execute evm/cross-chain-token local "Avalanche" "Fantom" 1
The output will be:
--- Initially ---
Balance at Ethereum is 0
Balance at Fantom is 0
--- After getting some token on the source chain ---
Balance at Ethereum is 1
Balance at Fantom is 0
--- After ---
Balance at Ethereum is 0
Balance at Fantom is 1