Smart Contracts
An overview of all the smart contracts used in Telepathy.
For more details about any of these contracts, please refer to the source code for the contracts and circuits respectively.
Light Client
The Light Client contract 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 step function:
where an update
contains all the necessary information for validation:
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
The Router contract 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.
Sending
When the Router is used on the source chain to send messages, the entry point is the Router's send
function:
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
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 executeMessageFromLog
function is called:
An off-chain actor, known as a Relayer, 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 handleTelepathy
function:
A destination contract must implement this function to receive the message.
Last updated