Submit a Swap
Build and execute the public swap flow: Build -> Get signing -> Submit signed artifact.
Last updated
import { RoutingEngineSDK } from 'routing-engine-sdk';
const sdk = new RoutingEngineSDK({
api: { apiKey: 'your-api-key' },
});
try {
const quote = await sdk.quote.request({
fromChain: 'arbitrum',
toChain: 'avax',
tokenIn: 'TBTC',
tokenOut: 'WETH',
network: 'mainnet',
amount: '100.00',
slippageBps: 75,
recipient: '0x1234567890123456789012345678901234567890',
});
const build = await sdk.swap.build({
quoteId: quote.data.quoteId,
routeId: quote.data.routes[0].routeId,
recipient: '0x1234567890123456789012345678901234567890',
});
const signing = await sdk.swap.getSigning(build.data.swapId);
if (signing.data.nextAction === 'sign') {
// Sign with wallet/signer, then submit the signed raw transaction.
await sdk.swap.submitSigning(build.data.swapId, { rawTx: '0xsigned_raw_tx' });
}
} catch (error) {
console.error(error);
}