PixelBridge Core
  • What is PixelBridge Core?
  • ⚪PRODUCT
    • How does PixelBridge Core work?
      • Fees
      • Messaging protocols
      • PixelBridge Core contracts
      • Token value
      • Liquidity provision
    • PixelBridge Core guide
    • How to provide liquidity?
    • How to bridge with PixelBridge Core via mobile TronLink
    • Security audit
  • ⚪PixelBridge CORE SDK
    • Get started
    • Guides
      • General
        • Token info
        • Send
        • Swap
        • Paying fees with stables
      • EVM
        • Transfer
        • Allowance and approve
      • Solana
        • Transfer
        • Swap
      • Stellar
        • Transfer
      • Utilities
        • Amount and fee calculations
        • Transfer time
        • Extra gas limits
  • ⚪SOCIAL LINKS
    • Twtter
    • Telegram
    • Medium
  • ⚪PixelBridge ECOSYSTEM
    • PixelBridge Classic
    • PixelBridge BaaS
Powered by GitBook
On this page
  1. ⚪PixelBridge CORE SDK
  2. Guides
  3. EVM

Allowance and approve

This is an example demonstrating how to use the PixelBridge 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 12 months ago