Telepathy
  • Introduction
  • Why Telepathy?
  • Getting Started
  • Build with Telepathy
    • Cross-Chain Messaging
      • Example: Cross-Chain Counter
      • Example: Cross-Chain Messaging Demo
      • Unit Testing
    • Ethereum Data Oracle
      • Example: Cross-Chain Airdrop
      • Example: Cross-Chain ENS Resolution
    • Ethereum Consensus Oracle
      • Example: Validator Balance Data
  • Telepathy Protocol
    • Overview
    • Sync Committee Protocol
    • Proof of Consensus
    • Smart Contracts
    • Off-chain Actors
    • Circuits
    • Guardrails
  • Resources
    • Telepathy Explorer
    • Contract Addresses
    • Brand Assets
  • Demo
  • Explorer
  • Github
  • Website
  • Discord
Powered by GitBook
On this page
  • Light Client
  • Router
  1. Telepathy Protocol

Smart Contracts

An overview of all the smart contracts used in Telepathy.

PreviousProof of ConsensusNextOff-chain Actors

Last updated 2 years ago

For more details about any of these contracts, please refer to the source code for the and respectively.

Light Client

The is responsible for keeping up-to-date with the state of Ethereum. In particular, it keeps track of an append-only list of Ethereum block headers based on the verification that >2/3rds of the sync committee has provided signatures.

To add a new block header to a Light Client, one must generate a zkSNARK proof that validates the latter claim and pass the proof as an argument to the function:

step(LightClientStep memory update)

where an contains all the necessary information for validation:

struct LightClientStep {
    uint256 attestedSlot;
    uint256 finalizedSlot;
    uint256 participation;
    bytes32 finalizedHeaderRoot;
    bytes32 executionStateRoot;
    Groth16Proof proof;
}

This allows the Light Client to check the following conditions:

  • >2/3rds participation signatures from the current sync committee

  • A valid finality proof for the finalizedHeaderRoot

  • A valid execution state root proof against the finalizedHeaderRoot

If those conditions all pass, the current head of the Light Client is set to the finalizedSlot with the finalizedHeaderRoot stored on-chain.

Router

Sending

send(uint32 destinationChainId, bytes32 destinationAddress, bytes calldata data)

The destinationChainId and destinationAddress parameters are used to specify the chain and the address of the destination contract. The data parameter is used to specify the message that the destination contract receives. The send function emits a SentMessage event, which is used for validation on the destination chain.

Receiving

executeMessageFromLog(
    bytes calldata srcSlotTxSlotPack,
    bytes calldata messageBytes,
    bytes32[] calldata receiptsRootProof,
    bytes32 receiptsRoot,
    bytes[] calldata receiptProof,
    bytes memory txIndexRLPEncoded,
    uint256 logIndex
)
handleTelepathy(uint32 sourceChainId, address sourceAddress, bytes memory data)

A destination contract must implement this function to receive the message.

The is how developers use Telepathy Protocol to achieve cross-chain communication between their contracts. It is responsible for handling both the sending and receiving of messages.

When the Router is used on the source chain to send messages, the entry point is the Router's function:

When on the destination chain, the Router contract is responsible for relaying the message by using the light client to verify the message was actually sent on the source chain, and then calling handleTelepathy with the correct arguments. This happens when function is called:

An off-chain actor, known as a , will call this function with the required information and Merkle proofs that are used to validate the message against the stored header root in the LightClient. Once validated, the message is relayed to the specifieddestinationAddress via the function:

contracts
circuits
Light Client contract
step
update
Router contract
send
executeMessageFromLog
handleTelepathy
Relayer