Skip to main content

Overview

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

Installation

yarn add @layerswap/wallet-ton

Basic Usage

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:
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 bot
  2. Follow the bot’s instructions to register and generate your API key
  3. Copy the API key provided by the bot
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 for more information.

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:
{
  "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"
}
url
string
required
Your application’s URL. This should match the domain where your app is hosted.
name
string
required
The name of your application as it will appear to users in TON wallets.
iconUrl
string
required
URL to your application’s icon/logo. Should be a publicly accessible image file.
termsOfUseUrl
string
Optional URL to your terms of use page.
privacyPolicyUrl
string
Optional URL to your privacy policy page.
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.