# Reference

## createIkaAccounts

```ts
createIkaAccounts(options: CreateIkaAccountsOptions): IkaAccounts
```

| Option | Type | |
|---|---|---|
| `apiKey` | `string` | Your platform key, from the dashboard. |
| `apiUrl` | `string` | `https://ika-accounts.mpckit.xyz` |
| `keysOrigin` | `string` | `https://ika-accounts.mpckit.xyz`. Required in browsers. |
| `network` | `'mainnet' \| 'testnet'` | Default `'mainnet'`. |
| `session` | `SessionConfig` | Optional. See [sessions](https://docs-ika-accounts.mpckit.xyz/transactions/#sessions). |
| `suiUrl` | `string` | Optional Sui gRPC endpoint for reads. |
| `keyHost` | `KeyHost` | Node and tests: `createLocalKeyHost(...)` instead of the iframe. |

## Methods

**Sign-in**

| | |
|---|---|
| `openConnect(options?)` | Sign-in modal. Resolves addresses or `null`. |
| `reconnect()` | Restores the last wallet silently, or resolves `null`. |
| `signInWallets()` | Installed wallets: `{ id, name, icon, chain }[]`. |
| `connectWallet(id)` | Signs in with one of them. |
| `connect(provider)` | Signs in with an EIP-1193 provider or a Solana wallet. |
| `disconnect()` | Signs out and ends the session on-chain. |
| `forgetDevice()` | Also erases this browser's cached key. |
| `preload()` | Fetches Ika parameters early. |
| `whenReady()` | Resolves when the account's keys are ready. |
| `subscribe(listener)` | Called on sign-in and sign-out. Returns an unsubscribe function. |

**State**: `isConnected`, `address`, `addresses`, `owner`, `wallet`, `fundingWallets`.

**Transactions**

| | |
|---|---|
| `execute(input)` | Gasless Sui transaction. `{ digest }` |
| `perform(options)` | Fund if needed, then execute. `{ digest, deposits }` |
| `swap({ from, to, amountIn \| amountOut })` | Swap on Sui through Aftermath. |
| `balance(coinType?)` | Balance on Sui, default USDC. `bigint` |
| `signMessage(bytes)` | Raw Ed25519 signature. |
| `near.signIntents(intents)`, `near.publish(signed)` | NEAR Intents. |
| `solana.signTransaction(message)` | Solana. |

**Funds**

| | |
|---|---|
| `openFunds({ tab, receive })` | Deposit and withdraw panel. |
| `estimateDeposit(params)`, `estimateWithdraw(params)` | Quote without an order. |
| `deposit(params)` | Creates an order: `{ order, send(), wait() }`. |
| `withdraw(params)` | Sends from Sui: `{ order, digest, wait() }`. |
| `waitForOrder(id)` | Follows an order to `SUCCESS`, or throws. |
| `tokens()`, `chains()` | Everything that can be bridged, with logos. |
| `fundingOptions()` | The user's bridgeable balances, largest first. |
| `availableWallets()`, `addFundingWallet(id)` | Extra wallets to deposit from. |

## React

```tsx
import { IkaAccountsProvider, useIkaAccount, useBalance, usePerform } from '@ika-accounts/react';

<IkaAccountsProvider options={{ apiKey, apiUrl, keysOrigin, network: 'mainnet' }}>
  <App />
</IkaAccountsProvider>

const { connect, addresses, isReady } = useIkaAccount();
const { balance } = useBalance(USDC);
const { perform, status, error } = usePerform();
```

`useIkaAccounts()` returns the client, and `useFundingOptions()` the user's balances on other chains.

## Errors

The SDK throws `IkaAccountsError` with a stable `code`. API errors surface with the API's code.

| Code | Meaning |
|---|---|
| `not_connected` | Call a sign-in method first. |
| `transaction_failed` | The transaction executed and failed on-chain. |
| `insufficient_funds` | No balance on any connected chain covers the amount. |
| `bridge_refunded`, `bridge_failed` | The bridge order was refunded or failed. |
| `bridge_timeout`, `balance_timeout` | Funds didn't arrive in time. |
| `approval_required`, `invalid_approval`, `approval_expired` | The wallet approval is missing, wrong or too old. |
| `wallet_key_mismatch` | The wallet produced a different key than the account's (not deterministic). |
| `rate_limited` | A limit was hit. See [limits](https://docs-ika-accounts.mpckit.xyz/platform/#limits). |
| `insufficient_platform_balance` | Your platform balance is too low. Top up. |
| `presign_pool_empty`, `service_underfunded`, `service_paused` | Temporary. Retry shortly. |

## Deployments

Sui mainnet:

| | |
|---|---|
| Accounts package | `0xc60bb39a956847eeb02651435809241e8a6aa83780e157f5523ddbdfa533cae0` |
| Registry | `0xb83e52ab869e84bc435f8042403b6de28b3796b6e640feac6867759d20e53b76` |
| Upgrade timelock (7 days) | `0xac3bdc737adf7b9e829759237f1bf9993b935012afbd4e0cd656693f1796cda2` |

## Endpoints

| | |
|---|---|
| API | `https://ika-accounts.mpckit.xyz/v1` |
| Key origin | `https://ika-accounts.mpckit.xyz` |
| Dashboard | `https://dashboard-ika-accounts.mpckit.xyz` |
| Health | `https://ika-accounts.mpckit.xyz/health` |
