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 instance
As you can see here used SupportedChains.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 chain
4. Get trade data
After creating the payload, need to call the getTrade
method
5. Execute trade method
After successfully getting the trade data, we already can do a swap by calling the executeTrade
method
The result of the executeTrade
method will be the receipt of that swap transaction
e.g.
Last updated