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 approvedawaitsdk.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 addressconstrawTransactionApprove=awaitsdk.bridge.rawTxBuilder.approve({ token: sourceTokenInfo, owner: fromAddress, });constapproveTxReceipt=awaitsendRawTransaction(rawTransactionApprove asasRawEvmTransaction);console.log("approve tx id:",approveTxReceipt.transactionHash);