Cross Chain Messaging Protocol consists of 3 steps:
- Emit event on the SRC chain
- Verify the event and get proof from the Signer
- Receive the event on the DEST chain
Emit event
Cross Chain Messaging Protocol makes it possible to send events between different chains. CCMP relies on the events. To start interacting with it, modify your Src smart contract to emit the event.
You could also add destChainId and destAddress params to the event to make it more specific. However, none of those are required, and you could pass any parameters depending on your internal dApp logic.
Verify event
After the event was emitted, the next step is to receive proof of the event. Signer is responsible to create a signature as proof of the event.
For our example, the request body would be:
As a result of the request, we receive the following object:
The signature is created, therefore we can move to the last step.
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
.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.