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

# SDK Getting Started

> Install leokit-sdk and execute your first cross-chain swap

## Install

```bash theme={null}
npm install leokit-sdk ethers
```

`ethers@^6` is a peer dependency. Optional dependencies (per-chain xchain libraries, ZCash, Solana, etc.) are loaded lazily — only what you actually use is bundled.

The package exposes five entry points:

| Import path            | Use                                                     |
| ---------------------- | ------------------------------------------------------- |
| `leokit-sdk`           | `LeoKitClient`, factory, top-level types                |
| `leokit-sdk/wallets`   | `WalletManager` and adapter classes (lazy-loaded)       |
| `leokit-sdk/protocols` | Protocol handlers (`EvmProtocol`, `NearProtocol`, etc.) |
| `leokit-sdk/utils`     | Amount/chain/asset/error helpers, `EventEmitter`        |
| `leokit-sdk/cdn`       | Icon-URL builders                                       |

## Create a Client

```typescript theme={null}
import { createLeoKit } from "leokit-sdk";

const sdk = createLeoKit({
  apiKey: "your-leokit-api-key",
  network: "mainnet",
});
```

### `LeoKitConfig`

| Field     | Type                       | Required | Description                                             |
| --------- | -------------------------- | -------- | ------------------------------------------------------- |
| `apiKey`  | string                     | Yes      | API key from [dash.leokit.dev](https://dash.leokit.dev) |
| `network` | `"mainnet"` \| `"testnet"` | No       | Default: `"mainnet"`                                    |
| `apiUrl`  | string                     | No       | Default: `https://api.leokit.dev`                       |
| `cdnUrl`  | string                     | No       | CDN base for icons. Default: LeoKit CDN                 |

`sdk.getConfig()` returns the resolved `ResolvedConfig` (defaults filled in). `sdk.getNetwork()` returns the active `Network`.

## End-to-End Swap

```typescript theme={null}
import { createLeoKit } from "leokit-sdk";

const sdk = createLeoKit({ apiKey: process.env.LEOKIT_API_KEY!, network: "mainnet" });

// 1. Connect a wallet (e.g. MetaMask in a browser)
await sdk.connectWallet("metamask");

// 2. Get a quote
const quote = await sdk.getQuote({
  fromAsset: "ETH.ETH",
  toAsset: "BTC.BTC",
  amount: "1000000000000000000",      // 1 ETH in wei
  destination: "bc1q...",             // recipient address
});

// 3. Execute
const result = await sdk.executeSwap(quote);
console.log("Tx hash:", result.txHash);

// 4. Track to completion
const stop = sdk.watchTransaction(quote.quoteId, (status) => {
  console.log(status.state); // "pending" | "success" | "failed" | "refunded"
  if (status.state !== "pending") stop();
});
```

## Where to Go Next

<CardGroup cols={2}>
  <Card title="Wallets" icon="wallet" href="/sdk/wallets">
    19 adapters: MetaMask, Phantom, Ledger, Keplr, Trust, WalletConnect…
  </Card>

  <Card title="Quotes & Swaps" icon="arrows-rotate" href="/sdk/quotes-and-swaps">
    `getQuote`, `streamQuote`, `executeSwap`, `transfer`, transaction tracking
  </Card>

  <Card title="Limit Orders" icon="line-chart" href="/sdk/limit-orders">
    THORChain / MAYAChain native limit orders
  </Card>

  <Card title="Shielded ZCash" icon="shield" href="/sdk/zcash-shielded">
    `WebZjs`-backed shielded balance scan and transfer
  </Card>

  <Card title="Utilities" icon="screwdriver-wrench" href="/sdk/utilities">
    Amount math, chain helpers, asset parsing, error handling, events, icons
  </Card>
</CardGroup>

## Source

* npm: [`leokit-sdk`](https://www.npmjs.com/package/leokit-sdk)
* GitHub: [`LeoFinance/leokit-sdk`](https://github.com/LeoFinance/leokit-sdk)

The SDK ships its own `README.md` with a long-form integration walkthrough and a React example.
