Executing the trade
Implementation Example (TypeScript)
const {
routerAddress,
calldata,
gasLimit,
} = swapResponse;
// Approve the router contract to spend your sell tokens
await approveAsync(sellToken, wallet, routerAddress);
// Build the transaction
const unsignedTx = await wallet.populateTransaction({
to: routerAddress,
data: calldata,
gasLimit: gasLimit,
// Configure gas pricing for EIP-1559 transactions
type: 2,
maxFeePerGas,
maxPriorityFeePerGas,
});
// Sign and send the transaction
const tx = await wallet.sendTransaction(unsignedTx);Prerequisites
Last updated