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

# Migrate to 0.2.0

> One constructor, required public clients, wallet-client signing, and opt-in indexing.

These changes apply to core, React, and widgets.

```bash theme={null}
npm install @inco/ctoken@^0.2.0
```

## Configuration changes

| Previous API                                    | 0.2.0                                                               |
| ----------------------------------------------- | ------------------------------------------------------------------- |
| `CTokenClient.browser(options)`                 | `new CTokenClient(options)`                                         |
| `CTokenClient.node(options)`                    | `new CTokenClient(options)`                                         |
| Optional `publicClient` / SDK `rpcUrl`          | Required caller-owned `publicClient`                                |
| Raw `privateKey` or standalone `account` option | Supply an application-owned `walletClient` with its account set     |
| `indexerUrl`, `indexerTimeoutMs`                | Opt in with `indexer: { url, timeoutMs }`                           |
| Automatic indexer use                           | Off by default; `indexer: true` selects the matching hosted service |
| Numeric token `priority`                        | Put tokens in their intended array order                            |
| Numeric balance used for Max                    | Use `ExactBalance.raw` or `.formatted`                              |
| `onMax(number)`                                 | `onMax(exactDecimalString)`                                         |

Removed constructor options reject with `INVALID_CONFIG` in JavaScript and type errors in TypeScript object literals.

## Unified client

```ts theme={null}
const ctoken = new CTokenClient({
  network: "baseSepolia",
  publicClient,
  walletClient,
  indexer: true, // optional; omit to keep indexing off
});
```

Keep clients stable; rebuild when account, chain, or configuration changes.

Node and browsers share [scoped sessions](/ctoken/sessions). Include cToken addresses when decrypting handles.

## React setup

```tsx theme={null}
<CTokenProvider
  network="baseSepolia"
  publicClient={publicClient}
  walletClient={walletClient}
  tokens={TOKENS}
  indexer={true}
>
  {children}
</CTokenProvider>
```

Keep `QueryClientProvider`. Omit `walletClient` for wagmi; pass a client for another wallet, or null/undefined to disconnect. See [React setup](/ctoken/react).

With indexing off, widgets hide history/discovery. Indexer methods and manual refetches raise `INDEXER_NOT_CONFIGURED`.

## Balance and error behavior

Failed/pending balances throw instead of returning zero. Use `balanceExact()` for writes and `balancesSettled()` for per-token pending/error states.

```ts theme={null}
const balance = await ctoken.balanceExact({ token });
await ctoken.withdraw({ token, amount: balance.raw });
```

`onMax` now receives an exact decimal string. Indexer `block_time: null` becomes `undefined`.

Receipts return the final mined hash after repricing. Cancellation and different-operation replacement raise distinct errors. Use [error helpers](/ctoken/errors) for display; retain original causes.
