logoAcademy

Deploy Native Token Home

Deploy the NativeTokenHome contract on the Avalanche L1 blockchain.

You may already have TELEPORTER_REGISTRY_L1 and SOURCE_BLOCKCHAIN_ID_HEX set from previous sections. If you do, you can skip to step 5.

Get the Teleporter Registry Address of myblockchain

avalanche blockchain describe myblockchain
+-------------------------------------------------------------------------------------------+
|                                         TELEPORTER                                        |
+---------------+------------------------------+--------------------------------------------+
| Local Network | Teleporter Messenger Address | 0x253b2784c75e510dD0fF1da844684a1aC0aa5fcf |
|               +------------------------------+--------------------------------------------+
|               | Teleporter Registry Address  | 0xB4DC3d786D658d118631F5C6B75CB5935be8407C |
+---------------+------------------------------+--------------------------------------------+

Save the Teleporter Registry Address

Most other environment variables we will need are already set in the devcontainer or from the previous section.

export TELEPORTER_REGISTRY_L1=0xa3493940a13b426BD2f7dA6E55A39c060C0e6020

Get the Blockchain ID (hex) of myblockchain

+---------------------------------------------------------------------------------------------------------------+
|                                                 MYBLOCKCHAIN                                                  |
+---------------+-----------------------------------------------------------------------------------------------+
| Name          | myblockchain                                                                                  |
+---------------+-----------------------------------------------------------------------------------------------+
| VM ID         | qDNV9vtxZYYNqm7TSa9KnDTRabGxtBLv6vd888791J9a89kTF                                             |
+---------------+-----------------------------------------------------------------------------------------------+
| VM Version    | v0.6.9                                                                                        |
+---------------+--------------------------+--------------------------------------------------------------------+
| Local Network | ChainID                  | 1                                                                  |
|               +--------------------------+--------------------------------------------------------------------+
|               | SubnetID                 | 2KhsQJhH3VqS7WWMreodAAHpGfGCUNuGQDSaP2vUT29p1HELBV                 |
|               +--------------------------+--------------------------------------------------------------------+
|               | Owners (Threhold=1)      | P-custom18jma8ppw3nhx5r4ap8clazz0dps7rv5u9xde7p                    |
|               +--------------------------+--------------------------------------------------------------------+
|               | BlockchainID (CB58)      | 2ZempAyezixFRdJhJribDdj2wiK6YFF63CkXKaimfPb3hWeWVH                 |
|               +--------------------------+--------------------------------------------------------------------+
|               | BlockchainID (HEX)       | 0xcdd5b2b99ae462c32a8e4ea47e94f2c7804519353558fd4127cf7ae11d8a6e52 |
+---------------+--------------------------+--------------------------------------------------------------------+

Save the Blockchain ID (hex)

export SOURCE_BLOCKCHAIN_ID_HEX=0xcdd5b2b99ae462c32a8e4ea47e94f2c7804519353558fd4127cf7ae11d8a6e52

Deploy NativeTokenHome on myblockchain

Using the forge create command, we will deploy the NativeTokenHome.sol contract, passing in the following constructor arguments:

  • Interchain Messaging Registry (for our Avalanche L1)
  • Interchain Messaging Manager (our funded address)
  • Wrapped Token Address (deployed in the last step)
forge create --rpc-url myblockchain --private-key $PK lib/avalanche-interchain-token-transfer/contracts/src/TokenHome/NativeTokenHome.sol:NativeTokenHome --constructor-args $TELEPORTER_REGISTRY_L1 $FUNDED_ADDRESS $WRAPPED_ERC20_L1
[⠊] Compiling...
[⠊] Compiling 22 files with Solc 0.8.18
[⠒] Solc 0.8.18 finished in 1.95s
Compiler run successful!
Deployer: 0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC
Deployed to: 0x17aB05351fC94a1a67Bf3f56DdbB941aE6c63E25
Transaction hash: 0x91c60be19a69aadb1415112dd42302764b30bc48f09957c3a191021d70ccc9d4

Save the Native Token Home Address

export ERC20_HOME_BRIDGE_L1=0x17aB05351fC94a1a67Bf3f56DdbB941aE6c63E25

On this page