Crosschain SWAP
How to SWAP from one chain to another chain
1. Connect to the network
2. Creating the RubicService instance
After connecting the wallet you need to create a Rubic Service instanceSupportedChains.POLYGON.
Need to use that chain from which you want to swap tokens.
In this case used Polygon, because we wanted to swap from the Polygon chain to Ethereum.
Here are the supported chains.
3. Creating the payload to get trade data
Provided payload for swapping 10 USDT from the Polygon chain to the Ethereum chain4. Get trade data
After creating the payload, need to call thegetTrade method
5. Execute trade method
After successfully getting the trade data, we already can do a swap by calling theexecuteTrade method
executeTrade method will be the receipt of that swap transaction
e.g.