Receive event

After the event was made on the SRC chain and verified by the Signer, the last step of the protocol is receiving that event on the DEST chain.

We can trust that event happened on the SRC chain if proof of this event was made by the correct signer. Signers Registry smart contract is responsible for this validation.

In our example, to receive the event on the DEST chain, we have to call receiveMyMessage method on the MsgReceiver.

pragma solidity ^0.8.0;

contract MsgReceiver {
    event MyMessageReceived(string message);

    ISignersRegistry signersRegistry;

    constructor(address _signersRegistry) {
        signersRegistry = ISignersRegistry(_signersRegistry);

    function receiveMyMessage(
        bytes calldata _signature,
        string memory _message,
        address _msgSender,
        uint256 _chainId,
        bytes calldata _transactionHash
    ) external {
        bytes32 eventHash = keccak256(abi.encodePacked("MyMessage", _chainId, _msgSender, _transactionHash, _message));
        address signer = eventHash.recover(_signature);
        bool isSignerWhitelisted = signersRegistry.isPublicWhitelisted(signer);
        require(isSignerWhitelisted, "Signer is not whitelisted");

        emit MyMessageReceived(_message);

You can check, that eventHash was made the same way as Signer did while making the signature. It's very important to recover the signature with the same eventHash.

After the signature maker was recovered, signersRegistry checked if the signer was whitelisted. That's why all public and private Signers have to be whitelisted before producing any event proofs.

If signersRegistry approved that the signer was whitelisted, it means that we can trust this event. Therefore, do any steps required by your dApp.

In our example, it just emits the MyMessageReceived event.

See the example of the receiveMyMessage transaction on the explorer.

Last updated