Deep Dive into Teleporter
Teleporter is an EVM compatible cross-blockchain communication protocol built on top of Avalanche Warp Messaging (AWM), and implemented as a Solidity smart contract.
To get started with building applications on top of Teleporter, refer to the avalanche-starter-kit repository. This README is focused on the development of the Teleporter protocol itself.
Teleporter is an EVM compatible cross-blockchain communication protocol built on top of Avalanche Warp Messaging (AWM), and implemented as a Solidity smart contract. It provides a mechanism to asynchronously invoke smart contract functions on other EVM blockchains within Avalanche. Teleporter provides a handful of useful features on top of AWM, such as specifying relayer incentives for message delivery, replay protection, message delivery and execution retries, and a standard interface for sending and receiving messages within a dApp deployed across multiple Layer 1s.
It's important to understand the distinction between Avalanche Warp Messaging and Teleporter. AWM allows blockchains to communicate with each other via authenticated messages by providing signing and verification primitives in Avalanchego. These are used by the blockchain VMs to sign outgoing messages and verify incoming messages.
The Teleporter protocol, on the other hand, is implemented at the smart contract level, and is a user-friendly interface to AWM, aimed at dApp developers. All of the message signing and verification is abstracted away from developers. Instead, developers simply call sendCrossChainMessage
on the TeleporterMessenger
contract to send a message invoking a smart contract on another Avalanche L1, and implement the ITeleporterReceiver
interface to receive messages on the destination Avalanche L1. Teleporter handles all of the Warp message construction and sending, as well as the message delivery and execution.
To get started with using Teleporter, see How to Deploy Teleporter Enabled Blockchains on a Local Network
- Deployed Addresses
- A Note on Versioning
- Setup
- Structure
- E2E tests
- Upgradability
- Deploy Teleporter to an Avalanche L1
- Deploy TeleporterRegistry to an Avalanche L1
- ABI Bindings
- Docs
- Resources
Deployed Addresses
Contract | Address | Chain |
---|---|---|
TeleporterMessenger | 0x253b2784c75e510dD0fF1da844684a1aC0aa5fcf | All chains, all networks |
TeleporterRegistry | 0x7C43605E14F391720e1b37E49C78C4b03A488d98 | Mainnet C-Chain |
TeleporterRegistry | 0xF86Cb19Ad8405AEFa7d09C778215D2Cb6eBfB228 | Fuji C-Chain |
-
Using Nick's method,
TeleporterMessenger
deploys at a universal address across all chains, varying with eachteleporter
Major release. Compatibility exists only between same-versionTeleporterMessenger
instances. See Teleporter Contract Deployment and Deploy Teleporter to an Avalanche L1 for more details. -
TeleporterRegistry
can be deployed to any address. See Deploy TeleporterRegistry to an Avalanche L1 for details. The table above enumerates the canonical registry addresses on the Mainnet and Fuji C-Chains.
A Note on Versioning
Release versions follow the semver convention of incompatible Major releases. A new Major version is released whenever the TeleporterMessenger
bytecode is changed, and a new version of TeleporterMessenger
is meant to be deployed. Due to the use of Nick's method to deploy the contract to the same address on all chains (see Teleporter Contract Deployment for details), this also means that new release versions would result in different Teleporter contract addresses. Minor and Patch versions may pertain to contract changes that do not change the TeleporterMessenger
bytecode, or to changes in the test frameworks, and will only be included in tags.
Setup
Initialize the repository
- Get all submodules:
git submodule update --init --recursive
Dependencies
- Ginkgo for running the end-to-end tests.
- Docker and Docker Compose v2 for running the local test network.
Structure
contracts/
is a Foundry project that includes the implementation of theTeleporterMessenger
contract and example dApps that demonstrate how to write contracts that interact with Teleporter.abi-bindings/
includes Go ABI bindings for the contracts incontracts/
.tests/
includes integration tests for the contracts incontracts/
, written using the Ginkgo testing framework.utils/
includes Go utility functions for interacting with the contracts incontracts/
. Included are Golang scripts to derive the expected EVM contract address deployed from a given EOA at a specific nonce, and also construct a transaction to deploy provided byte code to the same address on any EVM chain using Nick's method.scripts/
includes bash scripts for interacting with Teleporter in various environments, as well as utility scripts.abi_bindings.sh
generates ABI bindings for the contracts incontracts/
and outputs them toabi-bindings/
.lint.sh
performs Solidity and Golang linting.scripts/local/
includes scripts for running Teleporter in Docker.
docker/
includes configurations for a local, containerized setup of Teleporter.
Upgradability
The Teleporter contract is non-upgradeable and can not be changed once it is deployed. This provides immutability to the contracts, and ensures that the contract's behavior at each address is unchanging. However, to allow for new features and potential bug fixes, new versions of the Teleporter contract can be deployed to different addresses. The TeleporterRegistry is used to keep track of the deployed versions of Teleporter, and to provide a standard interface for dApps to interact with the different Teleporter versions.
TeleporterRegistry
is not mandatory for dApps built on top of Teleporter, but dApp's are recommended to leverage the registry to ensure they use the latest Teleporter version available. Another recommendation standard is to have a single canonical TeleporterRegistry
for each Layer 1 chain, and unlike the Teleporter contract, the registry does not need to be deployed to the same address on every chain. This means the registry does not need a Nick's method deployment, and can be at different contract addresses on different chains.
For more information on the registry and how to integrate with Teleporter dApps, see the Upgradability doc.
Deploy Teleporter to an Avalanche L1
From the root of the repo, the TeleporterMessenger contract can be deployed by calling
Required arguments:
--version <version>
Specify the release version to deploy. These will all be of the formv1.X.0
. Each Teleporter version can only send and receive messages from the same Teleporter version on another chain. You can see a list of released versions at https://github.com/ava-labs/teleporter/releases.--rpc-url <url>
Specify the rpc url of the node to use.
Options:
--private-key <private_key>
Funds the deployer address with the account held by<private_key>
To ensure that Teleporter can be deployed to the same address on every EVM based chain, it uses Nick's Method to deploy from a static deployer address. Teleporter costs exactly 10eth
in the Avalanche L1's native gas token to deploy, which must be sent to the deployer address.
deploy_teleporter.sh
will send the necessary native tokens to the deployer address if it is provided with a private key for an account with sufficient funds. Alternatively, the deployer address can be funded externally. The deployer address for each version can be found by looking up the appropriate version at https://github.com/ava-labs/teleporter/releases and downloading TeleporterMessenger_Deployer_Address_<VERSION>.txt
.
Alternatively for new Layer 1s, the TeleporterMessenger
contract can be directly included in the genesis file as documented here.
Deploy TeleporterRegistry to an Avalanche L1
There should only be one canonical TeleporterRegistry
deployed for each chain, but if one does not exist, it is recommended to deploy the registry so Teleporter dApps can always use the most recent Teleporter version available. The registry does not need to be deployed to the same address on every chain, and therefore does not need a Nick's method transaction. To deploy, run the following command from the root of the repository:
Required arguments:
--version <version>
Specify the release version to deploy. These will all be of the formv1.X.0
.--rpc-url <url>
Specify the rpc url of the node to use.--private-key <private_key>
Funds the deployer address with the account held by<private_key>
deploy_registry.sh
will deploy a new TeleporterRegistry
contract for the intended release version, and will also have the corresponding TeleporterMessenger
contract registered as the initial protocol version.
ABI Bindings
To generate Golang ABI bindings for the Solidity smart contracts, run:
The auto-generated bindings should be written under the abi-bindings/
directory.
Docs
Resources
Last updated on