This is a demonstration of sending arbitrary data across chains using the Telepathy Protocol. Try out the demo here!
The source chain contract CrossChainMailer concatenates together a string message that includes:
- arbitrary text
- the sender's balance
- the sender's ENS name (if applicable)
It then sends this data to the Telepathy Router, which means it will be relayed to the destination chain contract specified in:
telepathyRouter.send(_destinationChainId, _destinationMailbox, bytes(data));
Once finalization occurs, it can be relayed to the destination chain contract CrossChainMailbox, which handles the message in:
function handleTelepathyImpl(uint32 _sourceChainId, address _sourceAddress, bytes memory _message)
internal
override
{
messages.push(string(_message));
emit MessageReceived(_sourceChainId, _sourceAddress, string(_message));
}
It store the message and emit an event.