DEX Swap

DEX Swap

Swap tokens through any Uniswap V2-compatible DEX on Flare, without holding FLR. Encode your own calldata for full control over routing, slippage, and deadlines.

typescript
import { Zedkr } from "zedkr";
const client   = await Zedkr.create({ provider });
const callData = iface.encodeFunctionData("swapExactTokensForTokens", [amountIn, 0n, [FXRP, USDT], to, deadline]);
const result   = await client.swap(signer, BLAZESWAP_ROUTER, callData);
console.log(result.txHash);

Full example - FXRP to USDT

typescript
import { ethers } from "ethers";

const BLAZESWAP = "0x2b8f51c1Ffadb778D48A5bd6d0169Cf648568243"; // Coston2
const iface     = new ethers.Interface(["function swapExactTokensForTokens(uint256,uint256,address[],address,uint256) returns (uint256[])"]);
const amountIn  = ethers.parseUnits("10", 6);
const deadline  = Math.floor(Date.now() / 1000) + 300;
const callData  = iface.encodeFunctionData("swapExactTokensForTokens", [amountIn, 0n, [FXRP, USDT], await signer.getAddress(), deadline]);

const result = await client.swap(signer, BLAZESWAP, callData);
Warning
Approve the Zedkr router (not the DEX itself) for the input token before swapping.
Tip
BlazeSwap on Coston2: 0x2b8f51c1Ffadb778D48A5bd6d0169Cf648568243