This how-to guide focuses on deploying Teleporter-enabled Subnets to a local Avalanche network.
After this tutorial, you would have created and deployed two Subnets 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 a Subnet 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 Subnet 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 Subnet, use the flag --teleporter=false when creating the Subnet.
To disable Relayer in your Subnet, use the flag --relayer=false when creating the Subnet.
Now let's create a second Subnet 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 Subnet: 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 Subnet and sends them to the destination Subnet.)
CLI configures the Relayer to enable every Subnet to send messages to all other Subnets. If you add more Subnets, the Relayer will be automatically reconfigured.
When deploying Subnet <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 Subnet.
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 Subnet creation time, the Relayer can be stopped and restarted on used request.
To stop the Relayer:
avalanche teleporter relayer stop --local✓ Local AWM Relayer successfully stopped
To start it again:
avalanche teleporter 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