> ## Documentation Index
> Fetch the complete documentation index at: https://aarc.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Event handling

You can listen to specific events such as `onTransactionSuccess`, `onTransactionError`, `onWidgetClose` and `onWidgetOpen`&#x20;

## 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:

<table><thead><tr><th width="212">Event</th><th width="320">Type</th><th>Description</th></tr></thead><tbody><tr><td>onTransactionSuccess</td><td><code>(data: TransactionSuccessData) => void</code> | undefined</td><td>Called when a transaction is successful.</td></tr><tr><td>onTransactionError</td><td><code>(data: TransactionErrorData) => void</code> | undefined</td><td>Called when a transaction encounters an error.</td></tr><tr><td>onWidgetClose</td><td><code>(error?: Error) => void</code> | undefined</td><td>Called when the widget is closed.</td></tr><tr><td>onWidgetOpen</td><td><code>() => void</code> | undefined</td><td>Called when the widget is opened.</td></tr></tbody></table>

### Event Data Types

#### TransactionSuccessData

<table><thead><tr><th width="195">Property</th><th width="234">Type</th><th>Description</th></tr></thead><tbody><tr><td>status</td><td>string</td><td>The status of the transaction.</td></tr><tr><td>message</td><td>string</td><td>A message describing the transaction result.</td></tr><tr><td>data</td><td>object</td><td>Additional data about the transaction.</td></tr><tr><td>data.txHash</td><td>string | undefined</td><td>The transaction hash, if available.</td></tr><tr><td>data\[key: string]</td><td>string | number | undefined</td><td>Any additional key-value pairs.</td></tr></tbody></table>

#### TransactionErrorData

<table><thead><tr><th width="189">Property</th><th width="167">Type</th><th>Description</th></tr></thead><tbody><tr><td>status</td><td>string</td><td>The status of the transaction (presumably an error status).</td></tr><tr><td>message</td><td>string</td><td>A message describing the error.</td></tr><tr><td>data</td><td>string</td><td>Additional data about the error.</td></tr></tbody></table>

### Example

```typescript theme={null}
  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");
      },
    },
  };
```
