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.
constswapResponse=awaitrango.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) {constevmTx=swapResponse.tx asEvmTransactionconst {value,txData} = evmTxconsole.log({value, txData})// pass value and txData to your own contract}
You could also limit messagingProtocols used to a custom list like ['LAYER_ZERO']. (Please note that as the message is relayed alongside with token in a single transaction if you limit messaging protocols toLAYER_ZERO, we use the same bridge for transferring tokens.
Make sure to check out Message Passing in order to implement proper interface in your smart contracts to receive messages from Rango contracts.