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

# API reference

## Public API: `C8WalletProvider`

| Method                | Parameters                                 | Return Type                                               |
| --------------------- | ------------------------------------------ | --------------------------------------------------------- |
| `connect()`           | None                                       | `Promise<void>`                                           |
| `disconnect()`        | None                                       | `Promise<void>`                                           |
| `status()`            | None                                       | `Promise<{ connected: boolean; walletVersion?: string }>` |
| `getInstruments()`    | None                                       | `Promise<InstrumentListPayload>`                          |
| `getAccounts()`       | `instrumentId?: string`                    | `Promise<AccountListPayload>`                             |
| `send()`              | `input: SendInput`                         | `Promise<SubmitTransferResultPayload>`                    |
| `signAndExecute()`    | `input: SignAndExecuteInput`               | `Promise<void>`                                           |
| `checkTxStatusById()` | `input: { txId: string }`                  | `Promise<TransferStatusResponsePayload>`                  |
| `on()`                | `event: T, cb: Listener<C8EventByType<T>>` | `() => boolean`                                           |

***

## Constructor

Creates a new wallet provider instance.

```ts theme={null}
new C8WalletProvider(config)
```

<ParamField path="dappUrl" type="string">
  URL of the dApp initiating the connection. Defaults to the current page URL.
</ParamField>

<ParamField path="dappName" type="string" required>
  Name of the dApp. Must match the name registered with the wallet.
</ParamField>

<ParamField path="network" type="string">
  Canton network to connect to. One of `"devnet"` or `"mainnet"`.
</ParamField>

***

## connect

Opens the C8 Wallet popup and establishes the `postMessage` channel. The user sees a connection approval screen in the wallet.

```ts theme={null}
connect(): Promise<void>
```

<ResponseField name="returns" type="Promise<void>">
  Resolves when the user approves the connection.
</ResponseField>

<Note>
  Must be called from a user gesture (e.g. button click) to avoid `POPUP_BLOCKED` errors.
</Note>

***

## disconnect

Closes the wallet popup and tears down the `postMessage` channel. Emits the `disconnected` event.

```ts theme={null}
disconnect(): Promise<void>
```

***

## status

Returns the current connection state.

```ts theme={null}
status(): Promise<{ connected: boolean, walletVersion?: string }>
```

<ResponseField name="connected" type="boolean">
  Whether the wallet is currently connected.
</ResponseField>

<ResponseField name="walletVersion" type="string">
  Version of the connected wallet (only present when connected).
</ResponseField>

***

## getInstruments

Returns the list of Canton instruments available in the connected wallet.

```ts theme={null}
getInstruments(): Promise<InstrumentListPayload>

type InstrumentListPayload = {
  instruments: Array<{
    instrumentId: string
    name: string
    symbol: string
  }>
}
```

***

## getAccounts

Returns accounts and their holdings. If `instrumentId` is provided, filters to accounts holding that instrument.

```ts theme={null}
getAccounts(instrumentId?: string): Promise<AccountListPayload>

type AccountListPayload = {
  accounts: Array<{
    partyId: string
    holdings: Array<{
      instrumentId: string
      balance: number
      balanceUsd: number
    }>
  }>
}
```

<ParamField path="instrumentId" type="string">
  Optional. Filters accounts to those holding this instrument.
</ParamField>

***

## send

Submits a transfer on the Canton ledger. Opens an approval screen in the wallet popup.

```ts theme={null}
send(input): Promise<SubmitTransferResultPayload>
```

<ParamField path="senderPartyId" type="string" required>
  Canton `partyId` of the sender.
</ParamField>

<ParamField path="instrumentId" type="string" required>
  Asset to transfer.
</ParamField>

<ParamField path="amount" type="number" required>
  Transfer amount.
</ParamField>

<ParamField path="receiverPartyId" type="string" required>
  Canton `partyId` of the recipient.
</ParamField>

<ParamField path="memo" type="string">
  Optional text memo attached to the transfer.
</ParamField>

<ParamField path="metadata" type="Record<string, string>">
  Optional arbitrary key-value metadata.
</ParamField>

<ResponseField name="txId" type="string">
  Transaction ID assigned by the Canton ledger. Use it with `checkTxStatusById`.
</ResponseField>

***

## signAndExecute

Signs and executes an arbitrary DAML command via the connected wallet. Use this for custom templates and choices beyond standard transfers. See [Transfer types](/wallet-sdk/transfer-types) for the full example.

```ts theme={null}
signAndExecute(input): Promise<void>
```

<ParamField path="note" type="string" required>
  Human-readable note shown to the user in the wallet UI.
</ParamField>

<ParamField path="partyId" type="string" required>
  The party submitting the command.
</ParamField>

<ParamField path="commandId" type="string" required>
  Unique idempotency key for this submission (e.g. a UUID).
</ParamField>

<ParamField path="commandsJson" type="string" required>
  JSON-serialized array of DAML commands (`CreateCommand`, `ExerciseCommand`, etc.).
</ParamField>

<ParamField path="disclosedContracts" type="string" required>
  JSON-serialized array of contracts disclosed to the participant to authorize the command.
</ParamField>

***

## on

Subscribes to a wallet event. Returns an unsubscribe function. See [Events](/wallet-sdk/events) for the full event reference.

```ts theme={null}
on<T extends C8EventType>(event: T, cb: Listener<C8EventByType<T>>): () => boolean
```

<ParamField path="event" type="string" required>
  Event type to subscribe to (e.g. `"connected"`, `"txChanged"`).
</ParamField>

<ParamField path="cb" type="Listener" required>
  Callback invoked with the typed event payload.
</ParamField>

<ResponseField name="returns" type="() => boolean">
  Unsubscribe function. Call it to remove the listener.
</ResponseField>

***

## checkTxStatusById

Polls the Canton ledger for the current status of a previously submitted transaction.

```ts theme={null}
checkTxStatusById(input): Promise<TransferStatusResponsePayload>
```

<ParamField path="txId" type="string" required>
  Transaction ID returned by `send()`.
</ParamField>

<ResponseField name="returns" type="Promise<TransferStatusResponsePayload>">
  Current ledger status for the given transaction.
</ResponseField>
