Request Data

Get transaction swap data

Requesting swap data

Using the swap method, you can get a transaction data for swap, obtained on previous step. You can check available request params here.

Here is an example of requesting data 1.05 ETH in Ethereum Blockchain for Matic in Polygon Blockchain

const quoteParams = {
    "dstTokenAddress": "0x0000000000000000000000000000000000000000",
    "dstTokenBlockchain": "POLYGON",
    "referrer": "rubic.exchange",
    "srcTokenAddress": "0x0000000000000000000000000000000000000000",
    "srcTokenAmount": "1.05",
    "srcTokenBlockchain": "ETH"
};
const bestTrade = await axios.post('https://api-v2.rubic.exchange/api/routes/quoteBest', {
  params: quoteParams
});
const swapParams = {
    ...quoteParams,
    id: bestTrade.id,
    fromAddress: "Your wallet address"
};
const tradeWithData = await axios.post('https://api-v2.rubic.exchange/api/routes/swap', {
  params: swapParams
});

console.log(tradeWithData.transaction);
/**
{
  data: 0x.....;
  to: 0x....;
  value: 0
}
*/

Swap request params

Required params

Optional params

Swap Response params

Last updated