Message Passing
How to relay message in a cross-chain swap?
When transferring tokens using Rango cross-chain API, you could pass a random message from the source chain to the destination and call your contract on the destination. In order to do so, you need to pass your contracts on source & destination chains plus an arbitrary hex message. Here is a brief guide on what you need to do in terms of SDK usage and the smart contract side.
SDK Usage
You should specify sourceContract
, destinationContract
and imMessage
arguments in both quote
and swap
methods if you want to pass a message from the source contract to the destination.
const quoteResponse = await rango.quote({
from: {
"blockchain": "OPTIMISM",
"symbol": "ETH",
"address": null
},
to: {
"blockchain": "ARBITRUM",
"symbol": "ETH",
"address": null
},
amount: "100000000000000000000",
messagingProtocols: ['LAYER_ZERO'],
sourceContract: "<source contract address>",
destinationContract: "<destination contract address>",
imMessage: "0x00000000000000000000000000000000000000000000000000000000000000010000000000000000000000007E8A8b130272430008eCa062419ACD8B423d339D"
})
Make sure to check out Message Passing in order to implement proper interface in your smart contracts to receive messages from Rango contracts.
Last updated
Was this helpful?