You can listen to specific events such as onTransactionSuccess, onTransactionError, onWidgetClose and onWidgetOpen

FKEvents

The FKEvents defines callback functions for various events that can occur during the operation of the widget. Here’s a breakdown of each event:

EventTypeDescription
onTransactionSuccess(data: TransactionSuccessData) => void | undefinedCalled when a transaction is successful.
onTransactionError(data: TransactionErrorData) => void | undefinedCalled when a transaction encounters an error.
onWidgetClose(error?: Error) => void | undefinedCalled when the widget is closed.
onWidgetOpen() => void | undefinedCalled when the widget is opened.

Event Data Types

TransactionSuccessData

PropertyTypeDescription
statusstringThe status of the transaction.
messagestringA message describing the transaction result.
dataobjectAdditional data about the transaction.
data.txHashstring | undefinedThe transaction hash, if available.
data[key: string]string | number | undefinedAny additional key-value pairs.

TransactionErrorData

PropertyTypeDescription
statusstringThe status of the transaction (presumably an error status).
messagestringA message describing the error.
datastringAdditional data about the error.

Example

  const config: FKConfig = {
    appName: "Aarc",
    // remaining config...
    events: {
      onTransactionSuccess: (data: TransactionSuccessData) => {
        console.log("onTransactionSuccess", data);
      },
      onTransactionError: (data: TransactionErrorData) => {
        console.log("onTransactionError", data);
      },
      onWidgetClose: () => {
        console.log("onWidgetClose");
      },
      onWidgetOpen: () => {
        console.log("onWidgetOpen");
      },
    },
  };