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

# Wallets and balances

> Connected wallets, the OmniWallet API, connect and disconnect events, and how balances are read.

## Connected wallets

```ts theme={null}
kit.wallets; // OmniWallet[]: every connected wallet
kit.priorityWallet; // the wallet that signs intents by default (the HOT balance owner)
kit.evm; kit.near; kit.solana; kit.ton; kit.stellar; kit.tron; kit.cosmos; // EvmWallet | null, ...
kit.wallet(WalletType.EVM); // by type
```

All of them are observable (MobX). Type guards narrow a wallet: `kit.isEvmWallet(w)`, `kit.isNearWallet(w)`,
`kit.isSolanaWallet(w)`, `kit.isTonWallet(w)`, `kit.isStellarWallet(w)`, `kit.isCosmosWallet(w)`.

Every wallet extends `OmniWallet`:

| Member | Purpose |
| - | - |
| `type`, `address`, `publicKey`, `icon` | Identity of the wallet on its chain |
| `omniAddress` | Its account on NEAR Intents (the HOT balance); `""` when the chain has none |
| `fetchBalance(chain, address)` | One token balance (base units, `bigint`) |
| `fetchBalances(chain, whitelist?)` | Balances of the listed tokens (and native) on a chain, read from the chain's RPC |
| `transfer({ token, receiver, amount, comment? })` | On-chain transfer; resolves with the tx hash |
| `transferFee(token, receiver, amount)` | Network fee of that transfer |
| `signIntents(intents, options?)` | Signs raw intents into a commitment |
| `auth(intents, { customAuth, ... })` | Signs an auth commitment in the auth popup and hands it to `customAuth` (your verifier); resolves with its answer |
| `intents(kit?)` | An [`Intents`](https://docs.hex-api.app/kit/intents) builder signed by this wallet |

## Connect and disconnect

```ts theme={null}
await kit.connect(); // wallet picker for every connector
await kit.connect(WalletType.EVM); // only EVM wallets
await kit.disconnect(WalletType.EVM); // or pass the wallet
```

Events, each returns an unsubscribe function:

```ts theme={null}
kit.onConnect(({ wallet, connector }) => {}); // new connection or a restored session
kit.onNewConnect(({ wallet }) => {}); // the user just connected
kit.onRestoreConnect(({ wallet }) => {}); // restored from storage after a reload
kit.onDisconnect(({ wallet }) => {});
```

## Balances

```ts theme={null}
import { OmniToken, Network } from "@hot-labs/kit";

kit.tokens; // all known tokens (Token[]), with prices
kit.walletsTokens; // { token, wallet, balance } for every connected wallet
kit.balance(wallet, token); // bigint, base units
kit.availableBalance(OmniToken.USDC); // HOT balance of a token across wallets
kit.getChainBalances(Network.Solana); // balances on one chain

await kit.fetchTokens(wallet); // refresh a wallet's balances
```

Balances come straight from each chain: for every token of the kit's list on that chain (the whitelist) and the
native coin, the wallet asks the chain's RPC (see [Endpoints](https://docs.hex-api.app/kit/configuration.md#endpoints)). Solana, TON, Stellar, XRP
and Sui read all their tokens in one or two calls (Solana and TON then keep the listed ones). No balance API is
involved, unless you opt into the hex-api indexer (`indexer: { baseUrl: "https://hex-api.app/wallet", balances: "proxy" }`)
or pass your own `BalanceIndexer`. HEX (NEAR Intents) balances are read from the `intents.near` contract.

`Token` carries the metadata: `symbol`, `decimals`, `chain`, `address`, `usd`, `icon`, and helpers like
`token.int(1.5)` (to base units) and `token.float(raw)`. Look tokens up with `tokens.get(id, chain)` and
`await tokens.getToken(chain, address)` from `@hot-labs/kit/core`.

## Deposit and withdraw (UI)

```ts theme={null}
await kit.deposit(OmniToken.USDC, 10); // move 10 USDC from a connected wallet into the HOT balance
await kit.withdraw(OmniToken.USDC, 10); // back to its original chain
```

Both open the Bridge popup preset for that operation. For a headless flow use `kit.exchange.reviewSwap(request)` and
`kit.exchange.makeSwap(review)`.

## Server-side wallets

`NearWallet.fromPrivateKey(privateKey, accountId)` from `@hot-labs/kit/near` creates a NEAR signer from a raw ed25519
key, without a browser. It signs intents and NEAR transactions.


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