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. Solana

Swap

PreviousTransferNextTron

Last updated 1 year ago

Was this helpful?

Swap makes the same way as a transfer, but you have to specify tokens from the one chain

// initiate transfer using Messenger.WORMHOLE
const amount = "10";
const transaction = (await sdk.bridge.rawTxBuilder.send({
  amount: amount,
  fromAccountAddress: accountAddress,
  toAccountAddress: accountAddress,
  sourceToken: sourceTokenInfo,
  destinationToken: destinationTokenInfo,
  minimumReceiveAmount: await sdk.getAmountToBeReceived(amount, sourceTokenInfo, destinationTokenInfo),
})) as RawSolanaTransaction;

const keypair = solanaWeb3.Keypair.fromSecretKey(bs58.decode(privateKey));
transaction.sign([keypair]);

const connection = new solanaWeb3.Connection(nodeUrlsDefault.solanaRpcUrl, "confirmed");
const txId = await connection.sendTransaction(transaction);
console.log(`https://explorer.solana.com/tx/${txId}`);

⚪
Full example