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

# Events

Subscribe to wallet and transaction lifecycle events with `c8.on(event, handler)`.

```js theme={null}
c8.on('connected',      (e) => { /* ... */ });
c8.on('txChanged',      (e) => { /* ... */ });
```

## Event reference

**connected** `event`

Fires when the user approves the connection in the popup. Payload: `{ meta?: Json }`.

**disconnected** `event`

Fires when `disconnect()` is called or the popup is closed. Payload: `{ reason?: string, meta?: Json }`.

**accountChanged** `event`

Fires when balances or holdings change. Payload: `{ accounts: AccountInfoPayload[], meta?: Json }`.

**txInitiated** `event`

Fires when a transaction request is initiated. Payload: `{ txId?: string, meta?: Json }`.

**txChanged** `event`

Fires when a transaction's completion status updates. Payload: `{ txId: string, status: "pending" | "confirmed" | "failed" | string, meta?: Json }`.

**themeChanged** `event`

Fires when the wallet interface changes its UI display theme. Payload: `{ theme: "dark" | "light", meta?: Json }`.

**operationCanceled** `event`

Fires when an action or modal interface is explicitly rejected by the user. Payload: `{ reason: string, meta?: Json }`.

> [!TIP]
>
> Always register listeners **before** calling `connect()` to ensure you don't miss the initial `connected` event.

## Unsubscribing from events

The `on()` method returns an unsubscribe function. Call it to remove the listener.

```js theme={null}
const unsubscribe = c8.on("connected", (event) => {
  console.log("Connected", event);
});

unsubscribe();
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.