logoAcademy

Deploy and Use ICTT with Avalanche CLI

Alternative and simplified way to deploy ICTT to transfer ERC-20 to ERC-20 assets

In the previous sections of this chapter we manually deployed and interacted with the Interchain Token Transfer contracts. In this section we will use the Avalanche CLI to deploy the contracts and transfer the tokens.

What we will do

  1. Create an Avalanche L1 and Deploy on Local Network
  2. Deploy an ERC-20 Contract on C-chain
  3. Deploy the Avalanche Interchain Token Transfer Contracts on C-chain and Avalanche L1
  4. Start Sending Tokens

Deploy Avalanche Interchain Token Transfer Contracts

First retrieve the address of the ERC-20 token on C-Chain.

echo $ERC20_C_CHAIN

Next we will deploy two Interchain Token Transfer contracts using the Avalanche CLI. It will deploy the contracts on the source chain (C-Chain) and on the destination chain (myblockchain) for us.

avalanche interchain tokenTransferrer deploy
 Local Network
 C-Chain
 Deploy a new Home for the token
 An ERC-20 token
Enter the address of the ERC-20 Token: 0x5DB9A7629912EBF95876228C24A848de0bfB43A9
...
Home Deployed to http://127.0.0.1:9650/ext/bc/C/rpc
Home Address: 0x4Ac1d98D9cEF99EC6546dEd4Bd550b0b287aaD6D
 
Remote Deployed to http://127.0.0.1:9650/ext/bc/2u9Hu7Noja3Z1kbZyrztTMZcDeqb6acwyPyqP4BbVDjoT8ZaYc/rpc
Remote Address: 0x0D189a705c1FFe77F1bF3ee834931b6b9B356c05

Save the Remote contract address in the environment variables.

export ERC20_REMOTE_L1=<"Remote address">

Get Balances

Before transfering some funds Cross-Chain, check the current balances of both the ERC20 Home token and the Remote one.

avalanche key list --local --keys ewoq  --blockchains c,myblockchain --tokens $ERC20_C_CHAIN,$ERC20_REMOTE_L1
+--------+------+---------+--------------------------------------------+---------------+------------------+---------------+
|  KIND  | NAME | SUBNET  |                  ADDRESS                   |     TOKEN     |     BALANCE      |    NETWORK    |
+--------+------+---------+--------------------------------------------+---------------+------------------+---------------+
| stored | ewoq | myblockchain |                                        | TOK (0x0D18.)|               0  | Local Network |
+        +      +----------+--------------------------------------------+---------------+-----------------+---------------+
|        |      | C-Chain  | 0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC | TOK (0x5DB9.)| 100000.000000000 | Local Network |
+--------+------+----------+--------------------------------------------+---------------+-----------------+---------------+

Transfer the Token Cross-chain

Now that the Avalanche Interchain Token Transfer contracts have been deployed, transfer some ERC20 tokens TOK from C-Chain to myblockchain

avalanche key transfer
✔ Local Network
✔ C-Chain
✔ Blockchain myblockchain
Enter the address of the Token Transferrer on c-chain: 0x4Ac1d98D9cEF99EC6546dEd4Bd550b0b287aaD6D
Enter the address of the Token Transferrer on myblockchain: 0x0D189a705c1FFe77F1bF3ee834931b6b9B356c05
✔ ewoq
✔ Key
✔ ewoq
Amount to send (TOKEN units): 100

Check Balances

Now we can check the balances of both the ERC-20 Home token and the Remote one.

avalanche key list --local --keys ewoq  --blockchains c,myblockchain --tokens $ERC20_C_CHAIN,$ERC20_REMOTE_L1
+--------+------+----------+--------------------------------------------+---------------+-----------------+---------------+
|  KIND  | NAME |  SUBNET  |                  ADDRESS                   |     TOKEN     |     BALANCE     |    NETWORK    |
+--------+------+----------+--------------------------------------------+---------------+-----------------+---------------+
| stored | ewoq | myblockchain | 0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC | TOK (0x0D18.) |   100.000000000 | Local Network |
+        +      +----------+--------------------------------------------+---------------+-----------------+---------------+
|        |      | C-Chain  | 0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC | TOK (0x5DB9.) | 99900.000000000 | Local Network |
+--------+------+----------+--------------------------------------------+---------------+-----------------+---------------+

Success! We have transferred 100 tokens from C-Chain to myblockchain using the Avalanche CLI.

On this page