Documentation
Wallet Client
createWalletClient

createWalletClient

WalletClient provides a set of methods for interacting with TON wallets: connect to them, send transactions, and more. This client is available in both Node and browser environments.

Import

import { createWalletClient } from '@fotonjs/core';

Usage

Initialize the client on the mainnet (by default) with the link to manifest:

import { createWalletClient } from '@fotonjs/core';
 
const walletClient = createWalletClient({
  chain: 'mainnet',
  manifestUrl: 'https://example.com/tonconnect-manifest.json',
});

Then you can get the list of all supported wallets:

const wallets = await walletClient.getWallets();

When user selects one of the wallets, connect to it:

const walletConnection = await walletClient.connect(wallets[0]);

Parameters

manifestUrl

  • Type: string
  • Required if connection is not provided

The URL of a published manifest file (opens in a new tab). A Manifest is a JSON file with the following fields:

{
    "url": "<app-url>",                        // required
    "name": "<app-name>",                      // required
    "iconUrl": "<app-icon-url>",               // required
    "termsOfUseUrl": "<terms-of-use-url>",     // optional
    "privacyPolicyUrl": "<privacy-policy-url>" // optional
}
const walletClient = createWalletClient({
  manifestUrl: 'https://example.com/tonconnect-manifest.json',
});

connection

  • Type: TonConnect
  • Required if manifestUrl is not provided

An instance of the @tonconnect/sdk (opens in a new tab). Needed for integration between Foton and Ton Connect.

import { TonConnect } from '@tonconnect/sdk';
 
const tonConnect = new TonConnect({
  manifestUrl: 'https://example.com/tonconnect-manifest.json',
});
 
const walletClient = createWalletClient({
  connection: tonConnect,
});

chain (optional)

  • Type: 'mainnet' | 'testnet'
  • Default: 'mainnet'

TON blockchain network to use for sending the transactions.

const walletClient = createWalletClient({
  chain: 'mainnet',
  manifestUrl: 'https://example.com/tonconnect-manifest.json',
});

storage (optional)

In interface to store the user's wallet connection data. By default, the client uses the browser's localStorage.

For backend, this field should be configured with a custom storage implementation.

walletsListCacheTTLMs (optional)

  • Type: number
  • Default: Infinity

Time in milliseconds to cache the list of wallets.

walletsListSource (optional)

  • Type: string
  • Default: 'https://raw.githubusercontent.com/ton-connect/wallets-list/main/wallets.json'

Redefine the source of wallets list. Must be a link to a json file with following structure (opens in a new tab).