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

Allowance and approve

This is an example demonstrating how to use the Allbridge Core SDK to check the allowance and create an approval.

if (
  // check if tokens already approved
  await sdk.bridge.checkAllowance({
    token: sourceTokenInfo,
    owner: fromAddress,
    gasFeePaymentMethod: gasFeePaymentMethod,
    amount: totalAmountFloat,
  })
) {
  console.log("The granted allowance is enough for the transaction");
} else {
  console.log("The granted allowance is NOT enough for the transaction");
}

To make approve transaction

  // authorize the bridge to transfer tokens from the sender's address
  const rawTransactionApprove = await sdk.bridge.rawTxBuilder.approve({
    token: sourceTokenInfo,
    owner: fromAddress,
  });
  const approveTxReceipt = await sendRawTransaction(rawTransactionApprove as  as RawEvmTransaction);
  console.log("approve tx id:", approveTxReceipt.transactionHash);
PreviousTransferNextSolana

Last updated 8 months ago

Was this helpful?

⚪
Full example