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

# TON Wallet

## Overview

The TON wallet provider supports TON Connect compatible wallets including Tonkeeper, MyTonWallet, and more.

## Installation

<CodeGroup>
  ```typescript yarn theme={"system"} theme={null}
  yarn add @layerswap/wallet-ton
  ```

  ```typescript pnpm theme={"system"} theme={null}
  pnpm add @layerswap/wallet-ton
  ```

  ```typescript npm theme={"system"} theme={null}
  npm install @layerswap/wallet-ton
  ```
</CodeGroup>

## Basic Usage

```typescript theme={null}
import { LayerswapProvider, Swap } from "@layerswap/widget"
import { createTONProvider } from "@layerswap/wallet-ton"
import "@layerswap/widget/index.css"

export const App = () => {
  const tonProvider = createTONProvider({
    tonConfigs: {
      tonApiKey: "YOUR_TON_API_KEY",
      manifestUrl: "https://yourapp.com/tonconnect-manifest.json"
    }
  })

  return (
    <LayerswapProvider
      walletProviders={[tonProvider]}
    >
      <Swap />
    </LayerswapProvider>
  )
}
```

***

## Configuration

### TON Configuration

The TON provider requires specific configuration:

```typescript theme={null}
import { createTONProvider } from "@layerswap/wallet-ton"
import type { TonClientConfig } from "@layerswap/wallet-ton"

const tonConfigs: TonClientConfig = {
  tonApiKey: string,    // Required: Your TON API key
  manifestUrl: string   // Required: URL to your TON Connect manifest
}

const tonProvider = createTONProvider({ tonConfigs })
```

### TON API Key

The `tonApiKey` is required to interact with the TON blockchain network. It's used for:

* Fetching wallet balances
* Initiating transactions
* Accessing TON Center's HTTP API

#### Getting Your API Key

To obtain a TON API key:

1. Open Telegram and navigate to the [@tonapibot](https://t.me/tonapibot) bot
2. Follow the bot's instructions to register and generate your API key
3. Copy the API key provided by the bot

<Note>
  Without an API key, usage is limited to 1 request per second. Registering for an API key provides access to higher rate limits necessary for production applications. Visit [TON Center](https://toncenter.com/) for more information.
</Note>

### Manifest URL Configuration

The `manifestUrl` is required by TON Connect and points to a `tonconnect-manifest.json` file that contains essential metadata about your application.

#### Creating the Manifest File

Create a `tonconnect-manifest.json` file in your project's public directory with the following structure:

```json theme={null}
{
  "url": "https://your-app-domain.com",
  "name": "Your App Name",
  "iconUrl": "https://your-app-domain.com/icon.png",
  "termsOfUseUrl": "https://your-app-domain.com/terms",
  "privacyPolicyUrl": "https://your-app-domain.com/privacy"
}
```

<ResponseField name="url" type="string" required>
  Your application's URL. This should match the domain where your app is hosted.
</ResponseField>

<ResponseField name="name" type="string" required>
  The name of your application as it will appear to users in TON wallets.
</ResponseField>

<ResponseField name="iconUrl" type="string" required>
  URL to your application's icon/logo. Should be a publicly accessible image file.
</ResponseField>

<ResponseField name="termsOfUseUrl" type="string">
  Optional URL to your terms of use page.
</ResponseField>

<ResponseField name="privacyPolicyUrl" type="string">
  Optional URL to your privacy policy page.
</ResponseField>

<Note>
  The manifest file must be publicly accessible. For local development, you may need to host it on a development server or use a public URL. Learn more in the [TON Connect documentation](https://docs.ton.org/v3/guidelines/ton-connect/frameworks/react#set-up-ton-connect).
</Note>
