Message Passing
How to relay message in a cross-chain swap?
SDK Usage
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"
})const swapResponse = await rango.swap({
from: {
"blockchain": "OPTIMISM",
"symbol": "ETH",
"address": null
},
to: {
"blockchain": "ARBITRUM",
"symbol": "ETH",
"address": null
},
amount: "100000000000000000000",
fromAddress: fromAddress,
toAddress: fromAddress,
disableEstimate: false,
referrerAddress: null,
referrerFee: null,
slippage: '1.0',
messagingProtocols: ['LAYER_ZERO'],
sourceContract: "<source contract address>",
destinationContract: "<destination contract address>",
imMessage: "0x00000000000000000000000000000000000000000000000000000000000000010000000000000000000000007E8A8b130272430008eCa062419ACD8B423d339D"
})
if (!!swapResponse && !swapResponse.error && swapResponse.resultType === "OK" && swapResponse.tx?.type === TransactionType.EVM) {
const evmTx = swapResponse.tx as EvmTransaction
const {value, txData} = evmTx
console.log({value, txData})
// pass value and txData to your own contract
}Last updated