This how-to guide focuses on deploying Teleporter-enabled Avalanche L1s to a local Avalanche network.
After this tutorial, you would have created and deployed two Avalanche L1s to the local network and have enabled them to cross-communicate with each other and with the local C-Chain (through Teleporter and the underlying Warp technology.)
For more information on cross chain messaging through Teleporter and Warp, check:
Let's create an Avalanche L1 called <chain1> with the latest Subnet-EVM version, a chain ID of 1, TOKEN1 as the token name, and with default Subnet-EVM parameters (more information regarding Avalanche L1 creation can be found here):
avalanche blockchain create <chain1> --evm --latest\ --evm-chain-id 1 --evm-token TOKEN1 --evm-defaultscreating genesis for <blockchain chain1>configuring airdrop to stored key "subnet_<chain1>_airdrop" with address 0x0EF8151A3e6ad1d4e17C8ED4128b20EB5edc58B1loading stored key "cli-teleporter-deployer" for teleporter deploys (evm address, genesis balance) = (0xE932784f56774879e03F3624fbeC6261154ec711, 600000000000000000000)using latest teleporter version (v1.0.0)✓ Successfully created subnet configuration
Notice that by default, Teleporter is enabled and a stored key is created to fund Teleporter related operations (that is deploy Teleporter smart contracts, fund Teleporter Relayer).
To disable Teleporter in your Avalanche L1, use the flag --teleporter=false when creating the Avalanche L1.
To disable Relayer in your Avalanche L1, use the flag --relayer=false when creating the Avalanche L1.
Now let's create a second Avalanche L1 called <chain2>, with similar settings:
avalanche blockchain create <chain2> --evm --latest\ --evm-chain-id 2 --evm-token TOKEN2 --evm-defaultscreating genesis for <blockchain chain2>configuring airdrop to stored key "subnet_<chain2>_airdrop" with address 0x0EF815FFFF6ad1d4e17C8ED4128b20EB5edAABBBloading stored key "cli-teleporter-deployer" for teleporter deploys (evm address, genesis balance) = (0xE932784f56774879e03F3624fbeC6261154ec711, 600000000000000000000)using latest teleporter version (v1.0.0)✓ Successfully created subnet configuration
avalanche blockchain deploy <chain1> --localDeploying [<chain1>] to Local NetworkBackend controller started, pid: 149427, output at: ~/.avalanche-cli/runs/server_20240229_165923/avalanche-cli-backend.logBooting Network. Wait until healthy...Node logs directory: ~/.avalanche-cli/runs/network_20240229_165923/node<i>/logsNetwork ready to use.Deploying Blockchain. Wait until network acknowledges...Teleporter Messenger successfully deployed to c-chain (0x253b2784c75e510dD0fF1da844684a1aC0aa5fcf)Teleporter Registry successfully deployed to c-chain (0x17aB05351fC94a1a67Bf3f56DdbB941aE6c63E25)Teleporter Messenger successfully deployed to <chain1> (0x253b2784c75e510dD0fF1da844684a1aC0aa5fcf)Teleporter Registry successfully deployed to <chain1> (0x9EDc4cB4E781413b1b82CC3A92a60131FC111F58)Using latest awm-relayer version (v1.1.0)Executing AWM-Relayer...Blockchain ready to use. Local network node endpoints:+-------+-----------+------------------------------------------------------------------------------------+--------------------------------------------+| NODE | VM | URL | ALIAS URL |+-------+-----------+------------------------------------------------------------------------------------+--------------------------------------------+| node1 | <chain1> | http://127.0.0.1:9650/ext/bc/MzN4AbtFzQ3eKqPhFaDpwCMJmagciWSCgghkZx6YeC6jRdvb6/rpc | http://127.0.0.1:9650/ext/bc/<chain1>/rpc |+-------+-----------+------------------------------------------------------------------------------------+--------------------------------------------+| node2 | <chain1> | http://127.0.0.1:9652/ext/bc/MzN4AbtFzQ3eKqPhFaDpwCMJmagciWSCgghkZx6YeC6jRdvb6/rpc | http://127.0.0.1:9652/ext/bc/<chain1>/rpc |+-------+-----------+------------------------------------------------------------------------------------+--------------------------------------------+| node3 | <chain1> | http://127.0.0.1:9654/ext/bc/MzN4AbtFzQ3eKqPhFaDpwCMJmagciWSCgghkZx6YeC6jRdvb6/rpc | http://127.0.0.1:9654/ext/bc/<chain1>/rpc |+-------+-----------+------------------------------------------------------------------------------------+--------------------------------------------+| node4 | <chain1> | http://127.0.0.1:9656/ext/bc/MzN4AbtFzQ3eKqPhFaDpwCMJmagciWSCgghkZx6YeC6jRdvb6/rpc | http://127.0.0.1:9656/ext/bc/<chain1>/rpc |+-------+-----------+------------------------------------------------------------------------------------+--------------------------------------------+| node5 | <chain1> | http://127.0.0.1:9658/ext/bc/MzN4AbtFzQ3eKqPhFaDpwCMJmagciWSCgghkZx6YeC6jRdvb6/rpc | http://127.0.0.1:9658/ext/bc/<chain1>/rpc |+-------+-----------+------------------------------------------------------------------------------------+--------------------------------------------+Browser Extension connection details (any node URL from above works):RPC URL: http://127.0.0.1:9650/ext/bc/MzN4AbtFzQ3eKqPhFaDpwCMJmagciWSCgghkZx6YeC6jRdvb6/rpcFunded address: 0x0EF8151A3e6ad1d4e17C8ED4128b20EB5edc58B1 with 1000000 (10^18) - private key: 16289399c9466912ffffffdc093c9b51124f0dc54ac7a766b2bc5ccf558d8eeeNetwork name: <chain1>Chain ID: 1Currency Symbol: TOKEN1
Notice some details here:
Two smart contracts are deployed to each Avalanche L1: Teleporter Messenger and Teleporter Registry
Both Teleporter smart contracts are also deployed to C-Chain in the Local Network
AWM Teleporter Relayer is installed, configured and executed in background (A Relayer listens for new messages being generated on a source Avalanche L1 and sends them to the destination Avalanche L1.)
CLI configures the Relayer to enable every Avalanche L1 to send messages to all other Avalanche L1s. If you add more Avalanche L1s, the Relayer will be automatically reconfigured.
When deploying Avalanche L1 <chain2>, the two Teleporter contracts will not be deployed to C-Chain in Local Network as they have already been deployed when we deployed the first Avalanche L1.
To verify that Teleporter is successfully, let's send a couple of cross messages:
avalanche teleporter msg C-Chain chain1 "Hello World" --localDelivering message "this is a message" to source subnet "C-Chain"Waiting for message to be received at destination subnet subnet "chain1"Message successfully Teleported!
avalanche teleporter msg chain2 chain1 "Hello World" --localDelivering message "this is a message" to source subnet "chain2"Waiting for message to be received at destination subnet subnet "chain1"Message successfully Teleported!
You have Teleport-ed your first message in the Local Network!
Relayer related logs can be found at ~/.avalanche-cli/runs/awm-relayer.log, and Relayer configuration can be found at ~/.avalanche-cli/runs/awm-relayer-config.json
Besides having the option to not use a Relayer at Avalanche L1 creation time, the Relayer can be stopped and restarted on used request.
To stop the Relayer:
avalanche interchain relayer stop --local✓ Local AWM Relayer successfully stopped
To start it again:
avalanche interchain relayer start --localusing latest awm-relayer version (v1.1.0)Executing AWM-Relayer...✓ Local AWM Relayer successfully startedLogs can be found at ~/.avalanche-cli/runs/awm-relayer.log