How to resend an ICM message?
It can be useful to resend an ICM message if the icm-relayer failed to processed it on the destination chain. This can happen for a variety of reasons, such as:
- The relayer service was down when the message was sent.
- A change in the source chain validator set caused the message signature to be invalid.
- There was a bug in the relayer service that caused it to fail to process the message
To resend an ICM message, you can use the Teleporter Messenger contract’s retrySendCrossChainMessage function.
Let’s try resending an existing ICM message.
Get transaction logs
For this example, the source chain transaction is on the C-Chain and has the hash 0x7770fd801f2caf39c07f64941946b84e9d2fdbb1148e25e72560dc3cf4210dae
We can get the logs via the cast receipt command:
Out of the multiple logs above, we are interested in the one with the topic SendCrossChainMessage:
Specifically, the SendCrossChainMessage event consists of the following fields:
messageIDbytes32 (topic1)destinationBlockchainIDbytes32 (topic2)TeleporterMessage(uint256,address,bytes32,address,uint256,address[],(uint256,address)[],bytes)TeleporterFeeInfo(address,uint256)
Decode the TeleporterMessage data
The data field of this log contains the encoded TeleporterMessage and TeleporterFeeInfo structs.
We will only need the TeleporterMessage part to resend the ICM message. See the function definition for retrySendCrossChainMessage here
We can decode the SendCrossChainMessage log event data using the cast decode-abi command:
The decoded TeleporterMessage fields are as follows:
Resend the ICM message
Import a wallet for use with the source chain:
Then use the cast send command to call the retrySendCrossChainMessage function on the Teleporter Messenger contract with the decoded TeleporterMessage data:
The transaction is shown on the explorer
icm-relayer response
After a short while, the icm-relayer should pick up the resent ICM message and process it on the destination chain. You can check the relayer logs to confirm that the message was processed successfully.
For this example, since this message was alerady processed on the destination chain, the relayer correctly identifies that and does not attempt to resend it.
If you need more help, explore our other articles or reach out to our support team via chat or email [email protected]. All examples provided are for demonstration purposes only.
Learn More About AvaCloud | Download Case Studies | Schedule an AvaCloud Demo