Allbridge Core
LAUNCH APP
  • What is Allbridge Core?
  • ⚪Product
    • How does Allbridge Core work?
      • Fees
      • Messaging protocols
      • Allbridge Core contracts
      • Token value
      • Liquidity provision
    • FAQ
      • How to bridge with Allbridge Core via mobile TronLink
      • Allbridge Core guide
      • How to provide liquidity?
      • What is an Approve Transaction?
    • Security audits
    • Ecosystem reports
    • Leaderboard
  • ⚪Allbridge Core SDK
    • Get started
    • Guides
      • General
        • Token info
        • Send
        • Swap
        • Paying fees with stables
      • EVM
        • Transfer
        • Allowance and approve
      • Solana
        • Transfer
        • Swap
      • Tron
      • Stellar
        • Transfer
      • Utilities
        • Amount and fee calculations
        • Transfer time
        • Extra gas limits
    • Technical reference
    • Referral program
    • Allbridge Core REST API
  • ⚪official support
    • Telegram
    • Discord
  • ⚪Social links
    • Twitter
    • Discord
    • Telegram announcements
    • Telegram group
    • Medium
    • Reddit
  • ⚪Allbridge ecosystem
    • Allbridge Classic
    • Allbridge BaaS
Powered by GitBook
On this page

Was this helpful?

  1. Allbridge Core SDK
  2. Guides
  3. General

Swap

If you want to swap tokens on the same chain

PreviousSendNextPaying fees with stables

Last updated 11 months ago

Was this helpful?

// initiate transfer
const swapParams: SwapParams = {
  amount: amount,
  fromAccountAddress: fromAddress,
  toAccountAddress: toAddress,
  sourceToken: sourceTokenInfo,
  destinationToken: destinationTokenInfo,
  minimumReceiveAmount: await sdk.getAmountToBeReceived(amount, sourceTokenInfo, destinationTokenInfo),
};
const rawTransactionTransfer = await sdk.bridge.rawTxBuilder.send(swapParams) as RawEvmTransaction;

console.log(`Swaping ${amount} ${sourceTokenInfo.symbol}`);
const txReceipt = await sendRawTransaction(rawTransactionTransfer);
console.log("tx id:", txReceipt.transactionHash);

⚪
Full example