For the complete documentation index, see llms.txt. This page is also available as Markdown.

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);

Full example

Last updated