TON DocsTON Docs
TON ConnectAPI reference

@tonconnect/sdk reference

@tonconnect/sdk is the JavaScript client library for the TON Connect protocol. It exposes the TonConnect connector for wallet connection, transaction signing, and message signing; the WalletsListManager for browsing supported wallets; and the models, errors, and utilities the protocol uses on the wire.

This page is reference-level. For an integration walkthrough, see Get started. For protocol semantics behind the API, see the TON Connect spec.

Installation

Install from npm:

npm i @tonconnect/sdk

Or include the bundle via CDN. The package is exposed on window.TonConnectSDK:

<script src="https://unpkg.com/@tonconnect/sdk@latest/dist/tonconnect-sdk.min.js"></script>

For a pinned version, replace @latest with the desired version.

Generated from @tonconnect/sdk v4.0.0-beta.2.

TonConnect

Headless TON Connect connector — implements the ITonConnect contract. Wraps the protocol handshake and the HTTP / JS bridge / WalletConnect transports.

Constructor

Create a new connector. See TonConnectOptions for every option; the most common shape is { manifestUrl } in the browser, and { manifestUrl, storage } in Node.js / non-browser hosts.

new TonConnect(options?: TonConnectOptions)
ParameterTypeDescription
optionsTonConnectOptionsOptional.

Throws: DappMetadataError when manifestUrl is omitted and window.location.origin is not available.

Instance properties

PropertyTypeDescription
connectedbooleanShows if the wallet is connected right now.
accountAccount | nullCurrent connected account or null if no account is connected.
walletWallet | nullCurrent connected wallet or null if no account is connected.

getWallets()

Returns available wallets list.

getWallets(): Promise<WalletInfo[]>;

Returns Promise<WalletInfo[]>.

onStatusChange()

Allows to subscribe to connection status changes and handle connection errors.

onStatusChange(
    callback: (wallet: Wallet | null) => void,
    errorsHandler?: (err: TonConnectError) => void
): () => void;
ParameterTypeDescription
callback(wallet: Wallet | null) => voidWill be called after connections status changes with actual wallet or null.
errorsHandler(err: TonConnectError) => voidOptional. Will be called with some instance of TonConnectError when connect error is received.

Returns () => void. Unsubscribe callback.

connect()

Generates universal link for an external wallet and subscribes to the wallet's bridge, or sends connect request to the injected wallet.

connect<T extends WalletConnectionSource | Pick<WalletConnectionSourceHTTP, 'bridgeUrl'>[]>(
    wallet: T,
    options?: OptionalTraceable<{
        request?: ConnectAdditionalRequest;
        openingDeadlineMS?: number;
        signal?: AbortSignal;
        embeddedRequest?: ConsumableLike<EmbeddedRequest>;
    }>
): T extends WalletConnectionSourceJS ? void : T extends WalletConnectionSourceWalletConnect ? void : string;
ParameterTypeDescription
walletTWallet's bridge url and universal link for an external wallet or jsBridge key for the injected wallet.
optionsOptionalTraceable<{ request?: ConnectAdditionalRequest; openingDeadlineMS?: number; signal?: AbortSignal; embeddedRequest?: ConsumableLike<EmbeddedRequest> }>Optional. openingDeadlineMS sets the connection opening deadline, and signal controls connection cancellation.

Returns T extends WalletConnectionSourceJS ? void : T extends WalletConnectionSourceWalletConnect ? void : string. Universal link if external wallet was passed or void for the injected wallet.

Possible errors:

A legacy overload is preserved for backwards compatibility and marked @deprecated — use connect(wallet, options) instead.

connect<T extends WalletConnectionSource | Pick<WalletConnectionSourceHTTP, 'bridgeUrl'>[]>(
    wallet: T,
    request?: ConnectAdditionalRequest,
    options?: OptionalTraceable<{
        openingDeadlineMS?: number;
        signal?: AbortSignal;
        embeddedRequest?: ConsumableLike<EmbeddedRequest>;
    }>
): T extends WalletConnectionSourceJS ? void : T extends WalletConnectionSourceWalletConnect ? void : string;

restoreConnection()

Try to restore existing session and reconnect to the corresponding wallet. Call it immediately when your app is loaded.

restoreConnection(
    options?: OptionalTraceable<{ openingDeadlineMS?: number; signal?: AbortSignal }>
): Promise<void>;
ParameterTypeDescription
optionsOptionalTraceable<{ openingDeadlineMS?: number; signal?: AbortSignal }>Optional.

Returns Promise<void>.

sendTransaction()

Asks connected wallet to sign and send the transaction.

sendTransaction(
    transaction: SendTransactionRequest,
    options?: OptionalTraceable<{ onRequestSent?: () => void; signal?: AbortSignal }>
): Promise<Traceable<SendTransactionResponse>>;
ParameterTypeDescription
transactionSendTransactionRequestTransaction to send.
optionsOptionalTraceable<{ onRequestSent?: () => void; signal?: AbortSignal }>Optional. onRequestSent will be called after the request was sent to the wallet and signal for the transaction abort.

Returns Promise<Traceable<SendTransactionResponse>>. The signed transaction BoC identifies the transaction on the blockchain.

Possible errors:

A legacy overload is preserved for backwards compatibility and marked @deprecated — use sendTransaction(transaction, options) instead.

sendTransaction(
    transaction: SendTransactionRequest,
    onRequestSent?: () => void
): Promise<Traceable<SendTransactionResponse>>;

signData()

Ask the connected wallet to sign opaque data (SignDataPayload). The signature is bound to the user's wallet address, the dApp's domain, a timestamp, and the payload — verify on the backend or on-chain.

signData(
    data: SignDataPayload,
    options?: OptionalTraceable<{ onRequestSent?: () => void; signal?: AbortSignal }>
): Promise<Traceable<SignDataResponse>>;
ParameterTypeDescription
dataSignDataPayload
optionsOptionalTraceable<{ onRequestSent?: () => void; signal?: AbortSignal }>Optional.

Returns Promise<Traceable<SignDataResponse>>. The SignDataResponse plus, when available, the traceId the SDK propagated through the bridge.

Possible errors:

signMessage()

Ask the connected wallet to sign an internal message without broadcasting it.

Same payload shape as sendTransaction; supported by wallets that advertise the SignMessage feature (typically Wallet V5).

signMessage(
    message: SignMessageRequest,
    options?: OptionalTraceable<{ onRequestSent?: () => void; signal?: AbortSignal }>
): Promise<Traceable<SignMessageResponse>>;
ParameterTypeDescription
messageSignMessageRequest
optionsOptionalTraceable<{ onRequestSent?: () => void; signal?: AbortSignal }>Optional.

Returns Promise<Traceable<SignMessageResponse>>. A signed BoC the dApp can wrap in an external message and submit through a relayer (e.g. for a gasless jetton transfer).

Possible errors:

setConnectionNetwork()

Set desired network for the connection. Can only be set before connecting. If wallet connects with a different chain, the SDK will throw an error and abort connection.

setConnectionNetwork(network?: ChainId): void;
ParameterTypeDescription
networkChainIdOptional. Desired network ID (e.g., -239, -3, or a custom ID). Pass undefined to allow any network.

Possible errors:

disconnect()

Disconnect from the connected wallet and drop current session.

disconnect(options?: OptionalTraceable<{ signal?: AbortSignal }>): Promise<void>;
ParameterTypeDescription
optionsOptionalTraceable<{ signal?: AbortSignal }>Optional.

Returns Promise<void>.

Possible errors:

getSessionId()

Gets the current session ID if available.

getSessionId(): Promise<string | null>;

Returns Promise<string | null>. Session ID string or null if not available.

pauseConnection()

Pause bridge HTTP connection. Might be helpful, if you want to pause connections while browser tab is unfocused, or if you use SDK with NodeJS and want to save server resources.

pauseConnection(): void;

unPauseConnection()

Unpause bridge HTTP connection if it is paused.

unPauseConnection(): Promise<void>;

Returns Promise<void>.

Static methods

MethodDescription
TonConnect.isWalletInjected(walletJSKey)true when a wallet identified by walletJSKey exposes a JS bridge on the current page. The fastest way to detect a browser extension before deciding which connect source to build.
TonConnect.isInsideWalletBrowser(walletJSKey)true when the dApp is running inside the named wallet's in-app browser. Use it to pick the JS-bridge transport automatically and skip the QR-code modal.
TonConnect.getWallets()Fetch the wallets-list registry without instantiating a connector. Equivalent to ITonConnect.getWallets but usable before constructing a TonConnect.

ITonConnect

Public contract of the TON Connect connector.

interface ITonConnect {
    connected: boolean;
    account: Account | null;
    wallet: Wallet | null;
    /* see TonConnect.getWallets */
    getWallets(...): Promise<WalletInfo[]>;
    /* see TonConnect.onStatusChange */
    onStatusChange(...): () => void;
    /* see TonConnect.connect */
    connect(...): T extends WalletConnectionSourceJS ? void : T extends WalletConnectionSourceWalletConnect ? void : string;
    /* see TonConnect.restoreConnection */
    restoreConnection(...): Promise<void>;
    /* see TonConnect.pauseConnection */
    pauseConnection(...): void;
    /* see TonConnect.unPauseConnection */
    unPauseConnection(...): Promise<void>;
    /* see TonConnect.setConnectionNetwork */
    setConnectionNetwork(...): void;
    /* see TonConnect.disconnect */
    disconnect(...): Promise<void>;
    /* see TonConnect.sendTransaction */
    sendTransaction(...): Promise<OptionalTraceable<SendTransactionResponse>>;
    /* see TonConnect.signData */
    signData(...): Promise<OptionalTraceable<SignDataResponse>>;
    /* see TonConnect.signMessage */
    signMessage(...): Promise<OptionalTraceable<SignMessageResponse>>;
    /* see TonConnect.getSessionId */
    getSessionId(...): Promise<string | null>;
}

WalletsListManager

Fetches and caches the wallets-list registry (wallets-v2.json) and merges it with any JS-injectable wallets the SDK detects on the page.

Constructor

new WalletsListManager(
    options?: {
        walletsListSource?: string;
        cacheTTLMs?: number;
        onDownloadDurationMeasured?: (duration: number | undefined) => void;
    }
)
ParameterTypeDescription
options{ walletsListSource?: string; cacheTTLMs?: number; onDownloadDurationMeasured?: (duration: number | undefined) => void }Optional.

getWallets()

getWallets(): Promise<WalletInfo[]>;

Returns Promise<WalletInfo[]>.

getEmbeddedWallet()

getEmbeddedWallet(): Promise<WalletInfoCurrentlyEmbedded | null>;

Returns Promise<WalletInfoCurrentlyEmbedded | null>.

getRemoteWallet()

getRemoteWallet(appName: string): Promise<WalletInfoRemote>;
ParameterTypeDescription
appNamestring

Returns Promise<WalletInfoRemote>.

BrowserEventDispatcher

A concrete implementation of EventDispatcher that dispatches events to the browser window.

Constructor

new BrowserEventDispatcher()

dispatchEvent()

Dispatches an event with the given name and details to the browser window.

dispatchEvent<P extends `ton-connect-${string}` | `ton-connect-ui-${string}`>(
    eventName: P,
    eventDetails: T & { type: RemoveTonConnectPrefix<P> }
): Promise<void>;
ParameterTypeDescription
eventNamePThe name of the event to dispatch.
eventDetailsT & { type: RemoveTonConnectPrefix<P> }The details of the event to dispatch.

Returns Promise<void>. A promise that resolves when the event has been dispatched.

addEventListener()

Adds an event listener to the browser window.

addEventListener<P extends `ton-connect-${string}` | `ton-connect-ui-${string}`>(
    eventName: P,
    listener: (event: CustomEvent<T & { type: RemoveTonConnectPrefix<P> }>) => void,
    options?: AddEventListenerOptions
): Promise<() => void>;
ParameterTypeDescription
eventNamePThe name of the event to listen for.
listener(event: CustomEvent<T & { type: RemoveTonConnectPrefix<P> }>) => voidThe listener to add.
optionsAddEventListenerOptionsOptional. The options for the listener.

Returns Promise<() => void>. A function that removes the listener.

Consumable

Single-shot value envelope. Holds a value until exactly one consumer calls Consumable.consume; subsequent reads return undefined.

Constructor

Wrap value. If value is already a Consumable, returns it unchanged so the type stays flat.

new Consumable(value: ConsumableLike<T>)
ParameterTypeDescription
valueConsumableLike<T>

Instance properties

PropertyTypeDescription
consumedbooleantrue once Consumable.consume has been called.

peek()

Read the wrapped value without consuming it. undefined once consumed.

peek(): T | undefined;

Returns T | undefined.

consume()

Take ownership of the wrapped value. The next call returns undefined. Use this when the value is about to be acted on exactly once.

consume(): T | undefined;

Returns T | undefined.

Types

IEnvironment

Represents the client environment in which the application is running.

interface IEnvironment {
    getLocale(): string;
    getBrowser(): string;
    getPlatform(): string;
    getTelegramUser(): TelegramUser | undefined;
    getClientEnvironment(): 'web' | 'miniapp' | (string & {});
}

DappMetadata

interface DappMetadata {
    name: string;
    icon: string;
    url: string;
}
FieldTypeDescription
namestringdApp name. It is not used as an identifier. Defaults to document.title when available, or Unknown dApp otherwise.
iconstringURL to the dApp icon. Must be PNG, ICO, ... . SVG icons are not supported. Defaults to best quality favicon declared via <link> in the document or '' if there are no any icons in the document.
urlstringdApp URL. Will be used as the dApp identifier. Will be used to open the dApp after click to its icon in the wallet. Pass url without closing slash, e.g. 'https://mydapp.com' instead of 'https://mydapp.com/'. Defaults to window.location.origin if exists, otherwise (if not explicitly specified) an error will be thrown.

ConnectAdditionalRequest

Extra items to attach to the ConnectRequest the SDK sends to the wallet.

interface ConnectAdditionalRequest {
    tonProof?: string;
}
FieldTypeDescription
tonProofstringOptional. Application payload for future verification to bind into the ton_proof signature.

SendTransactionRequestBase

Fields shared by both payload shapes of sendTransaction / signMessage.

interface SendTransactionRequestBase {
    validUntil: number;
    network?: ChainId;
    from?: string;
}
FieldTypeDescription
validUntilnumberDeadline in unix epoch seconds. The wallet refuses the request after this moment.
networkChainIdOptional. Target TON network identifier.
fromstringOptional. Sender address in raw <workchain>:<hex> format. Defaults to Account.address.

SendTransactionRequestWithMessages

Send a transaction using the raw messages[] payload.

interface SendTransactionRequestWithMessages {
    validUntil: number;
    network?: ChainId;
    from?: string;
    messages: { address: string; amount: string; stateInit?: string; payload?: string; extraCurrency?: { [k: number]: string } }[];
    items?: undefined;
}
FieldTypeDescription
validUntilnumberDeadline in unix epoch seconds. The wallet refuses the request after this moment.
networkChainIdOptional. Target TON network identifier.
fromstringOptional. Sender address in raw <workchain>:<hex> format. Defaults to Account.address.
messages{ address: string; amount: string; stateInit?: string; payload?: string; extraCurrency?: { [k: number]: string } }[]Outgoing messages — at least one, no more than the wallet's SendTransactionFeature.maxMessages (declared in Wallet.device.features). Submission is grouped (one signed external) but execution is not atomic: each recipient contract is processed independently, so some messages can fail or bounce while others succeed.
itemsundefinedOptional.

SendTransactionRequestWithItems

Send a transaction using structured items. Use only when you know the wallet advertises the needed SendTransactionFeature.itemTypes.

interface SendTransactionRequestWithItems {
    validUntil: number;
    network?: ChainId;
    from?: string;
    items: StructuredItem[];
    messages?: undefined;
}
FieldTypeDescription
validUntilnumberDeadline in unix epoch seconds. The wallet refuses the request after this moment.
networkChainIdOptional. Target TON network identifier.
fromstringOptional. Sender address in raw <workchain>:<hex> format. Defaults to Account.address.
itemsStructuredItem[]Structured items. The wallet builds the BoC for each.
messagesundefinedOptional.

SendTransactionResponse

Result of sendTransaction method.

interface SendTransactionResponse {
    boc: string;
}
FieldTypeDescription
bocstringBase64-encoded BoC of the broadcasted external message.

TonItem

Native GRAM transfer.

interface TonItem {
    type: 'gram';
    address: string;
    amount: string;
    payload?: string;
    stateInit?: string;
    extraCurrency?: { [k: number]: string };
}
FieldTypeDescription
type'gram'
addressstringDestination address in TEP-2 user-friendly base64url form. The bounceable flag is taken from the address itself.
amountstringNanograms to send, as a decimal string (e.g. "5000000" for 0.005 Gram).
payloadstringOptional. Optional one-cell BoC body, base64-encoded. Omit for a plain transfer.
stateInitstringOptional. Optional one-cell BoC StateInit, base64-encoded. Use it to deploy a contract together with the value transfer.
extraCurrency{ [k: number]: string }Optional. Extra currencies to attach: map of TEP-92 currency ID (decimal integer key) to amount in elementary units (decimal string value).

JettonItem

TEP-74 jetton transfer. The wallet resolves the user's jetton-wallet address from master, builds the transfer body and attaches enough Gram to pay for the jetton-wallet execution.

interface JettonItem {
    type: 'jetton';
    master: string;
    destination: string;
    amount: string;
    attachAmount?: string;
    responseDestination?: string;
    customPayload?: string;
    forwardAmount?: string;
    forwardPayload?: string;
    queryId?: string;
}
FieldTypeDescription
type'jetton'
masterstringJetton master contract address (friendly format).
destinationstringRecipient address (friendly format).
amountstringJetton amount in elementary units.
attachAmountstringOptional. Nanograms to attach to the jetton-wallet call.
responseDestinationstringOptional. Where to refund excess Gram. Defaults to the sender.
customPayloadstringOptional. Raw one-cell BoC custom_payload, base64-encoded.
forwardAmountstringOptional. Nanograms forwarded to the destination wallet — drives the transfer_notification to the recipient. Defaults to "1" nanogram.
forwardPayloadstringOptional. Raw one-cell BoC forward_payload, base64-encoded.
queryIdstringOptional. Application-defined query_id for the transfer body.

NftItem

TEP-62 NFT transfer. The wallet builds the transfer#5fcc3d14 body addressed to the NFT item contract.

interface NftItem {
    type: 'nft';
    nftAddress: string;
    newOwner: string;
    attachAmount?: string;
    responseDestination?: string;
    customPayload?: string;
    forwardAmount?: string;
    forwardPayload?: string;
    queryId?: string;
}
FieldTypeDescription
type'nft'
nftAddressstringNFT item contract address (friendly format).
newOwnerstringNew owner address (friendly format).
attachAmountstringOptional. Nanograms to attach.
responseDestinationstringOptional. Where to refund excess Gram.
customPayloadstringOptional. Raw one-cell BoC custom_payload, base64-encoded.
forwardAmountstringOptional. Nanograms forwarded to the new owner.
forwardPayloadstringOptional. Raw one-cell BoC forward_payload, base64-encoded.
queryIdstringOptional. Application-defined query_id for the transfer body.

SignMessageResponse

Result of signMessage method.

interface SignMessageResponse {
    internalBoc: string;
}
FieldTypeDescription
internalBocstringBase64-encoded BoC of the signed internal message. The wallet does not broadcast. Submit it through a relayer.

AnalyticsSettings

Analytics configuration forwarded to the SDK's internal tracker.

Analytics is opt-out. The default mode is 'telemetry' — minimal, anonymous signals used for technical research and issue debugging. Set mode: 'off' to disable, or mode: 'full' to opt into the full event stream.

interface AnalyticsSettings {
    mode?: AnalyticsMode;
}
FieldTypeDescription
modeAnalyticsModeOptional. - 'off' — no events are collected or sent. - 'telemetry' — technical analytics only (default). - 'full' — full user-action event stream. Defaults to 'telemetry'.

TonConnectOptions

Constructor options for the TonConnect connector.

For most browser dApps { manifestUrl } is enough; the SDK fills in localStorage, fetches the canonical wallets list, and runs analytics in the default 'telemetry' mode.

interface TonConnectOptions {
    manifestUrl?: string;
    storage?: IStorage;
    eventDispatcher?: EventDispatcher<SdkActionEvent>;
    walletsListSource?: string;
    walletsListCacheTTLMs?: number;
    walletsRequiredFeatures?: RequiredFeatures;
    disableAutoPauseConnection?: boolean;
    environment?: IEnvironment;
    analytics?: AnalyticsSettings;
}
FieldTypeDescription
manifestUrlstringOptional. HTTPS URL of the dApp's tonconnect-manifest.json. The wallet fetches this file before showing the connect prompt to extract the dApp's name, icon and policy URLs. If omitted, the SDK falls back to ${window.location.origin}/tonconnect-manifest.json.
storageIStorageOptional. Storage backend for protocol state (session keys, last connected wallet). Defaults to window.localStorage in the browser. Required when running the SDK in Node.js.
eventDispatcherEventDispatcher<SdkActionEvent>Optional. Custom event dispatcher for user-action events. Defaults to window.dispatchEvent in the browser, emitting CustomEvents prefixed with ton-connect-.
walletsListSourcestringOptional. Override the wallets-list JSON source. Must point to a file matching the wallets-v2 schema. Defaults to 'https://config.ton.org/wallets-v2.json'.
walletsListCacheTTLMsnumberOptional. In-memory cache TTL for the fetched wallets list, in milliseconds. Infinity (default) caches forever for the lifetime of the page. Defaults to Infinity.
walletsRequiredFeaturesRequiredFeaturesOptional. Required wallet capabilities. Wallets that do not advertise every requested feature are hidden from the picker (and rejected at connect time if the user selects one through a custom flow).
disableAutoPauseConnectionbooleanOptional. Disable the automatic pause / unpause of the SSE bridge connection driven by document.visibilitychange.
environmentIEnvironmentOptional. Override the runtime environment (platform, user-agent, Telegram user context). The SDK auto-detects in browsers; pass an IEnvironment implementation when embedding the SDK in a non-standard host.
analyticsAnalyticsSettingsOptional. Analytics configuration.

Account

The TON account that the wallet exposed to the dApp during the connect handshake.

One Wallet maps to exactly one Account for the lifetime of the session. To switch accounts the user has to disconnect and reconnect from the dApp UI.

interface Account {
    address: string;
    chain: ChainId;
    walletStateInit: string;
    publicKey?: string;
}
FieldTypeDescription
addressstringUser's address in raw hex form <workchain>:<hex>. Use toUserFriendlyAddress to render the non-bounceable base64url form (UQ… on mainnet, 0Q… on testnet) used in user-facing UI.
chainChainIdTON network identifier. See ChainId.
walletStateInitstringBase64-encoded (not URL-safe) BoC of the wallet contract StateInit cell.
publicKeystringOptional. Ed25519 public key advertised by the wallet during connect, hex-encoded without the 0x prefix. The value is not authoritative — do not trust it directly when verifying signatures. Re-derive it from Account.walletStateInit or call get_public_key on the wallet contract instead.

WalletConnectionSourceHTTP

Connect via the wallet's HTTP (SSE) bridge plus a universal link.

Both fields are sourced from the wallets list entry — see wallets-list.md.

interface WalletConnectionSourceHTTP {
    universalLink: string;
    bridgeUrl: string;
}
FieldTypeDescription
universalLinkstringHTTPS base of the wallet's universal link, e.g. 'https://connect.gramwallet.io'. The SDK appends the connect parameters (v, id, r, optional ret, trace_id, e).
bridgeUrlstringURL of the wallet's HTTP (SSE) bridge, e.g. 'https://connect.ton.org/bridge'.

WalletConnectionSourceJS

Connect via an injected JS bridge — the wallet is a browser extension or the dApp is running inside the wallet's webview.

interface WalletConnectionSourceJS {
    jsBridgeKey: string;
}
FieldTypeDescription
jsBridgeKeystringName of the window property where the wallet exposes its TonConnectBridge object. For example, jsBridgeKey: 'mytonwallet' resolves to window.mytonwallet.tonconnect.

WalletConnectionSourceWalletConnect

Connect via the WalletConnect transport. Requires initializeWalletConnect to have been called once at app startup.

interface WalletConnectionSourceWalletConnect {
    type: 'wallet-connect';
}
FieldTypeDescription
type'wallet-connect'

WalletInfoBase

Common fields shared by every wallet returned from the wallets list.

interface WalletInfoBase {
    name: string;
    appName: string;
    imageUrl: string;
    tondns?: string;
    aboutUrl: string;
    features?: Feature[];
    platforms: ('ios' | 'android' | 'macos' | 'windows' | 'linux' | 'chrome' | 'firefox' | 'safari')[];
}
FieldTypeDescription
namestringHuman-readable display name shown in the wallet picker.
appNamestringWallet identifier — equals the DeviceInfo.appName reported by the connected Wallet at runtime.
imageUrlstringHTTPS URL of the wallet icon. 288×288 PNG on a non-transparent background, no rounded corners.
tondnsstringOptional.
aboutUrlstringInfo or landing page for the wallet — shown to new users.
featuresFeature[]Optional. Wallet capabilities advertised in the registry.
platforms('ios' | 'android' | 'macos' | 'windows' | 'linux' | 'chrome' | 'firefox' | 'safari')[]Operating systems / browsers the wallet supports.

WalletInfoRemote

Wallet reached over the HTTP (SSE) bridge.

interface WalletInfoRemote {
    name: string;
    appName: string;
    imageUrl: string;
    tondns?: string;
    aboutUrl: string;
    features?: Feature[];
    platforms: ('ios' | 'android' | 'macos' | 'windows' | 'linux' | 'chrome' | 'firefox' | 'safari')[];
    universalLink: string;
    deepLink?: string;
    bridgeUrl: string;
}
FieldTypeDescription
namestringHuman-readable display name shown in the wallet picker.
appNamestringWallet identifier — equals the DeviceInfo.appName reported by the connected Wallet at runtime.
imageUrlstringHTTPS URL of the wallet icon. 288×288 PNG on a non-transparent background, no rounded corners.
tondnsstringOptional.
aboutUrlstringInfo or landing page for the wallet — shown to new users.
featuresFeature[]Optional. Wallet capabilities advertised in the registry.
platforms('ios' | 'android' | 'macos' | 'windows' | 'linux' | 'chrome' | 'firefox' | 'safari')[]Operating systems / browsers the wallet supports.
universalLinkstringHTTPS base of the wallet's universal link. The SDK appends the connect parameters (v, id, r, optional ret, trace_id, e).
deepLinkstringOptional. Optional custom-scheme deep link (e.g. mytonwallet-tc://). Same protocol parameters as the universal link.
bridgeUrlstringURL of the wallet's HTTP (SSE) bridge endpoint.

WalletInfoInjectable

Wallet exposed through a JS bridge — typically a browser extension, or the dApp running inside the wallet's webview.

interface WalletInfoInjectable {
    name: string;
    appName: string;
    imageUrl: string;
    tondns?: string;
    aboutUrl: string;
    features?: Feature[];
    platforms: ('ios' | 'android' | 'macos' | 'windows' | 'linux' | 'chrome' | 'firefox' | 'safari')[];
    jsBridgeKey: string;
    injected: boolean;
    embedded: boolean;
}
FieldTypeDescription
namestringHuman-readable display name shown in the wallet picker.
appNamestringWallet identifier — equals the DeviceInfo.appName reported by the connected Wallet at runtime.
imageUrlstringHTTPS URL of the wallet icon. 288×288 PNG on a non-transparent background, no rounded corners.
tondnsstringOptional.
aboutUrlstringInfo or landing page for the wallet — shown to new users.
featuresFeature[]Optional. Wallet capabilities advertised in the registry.
platforms('ios' | 'android' | 'macos' | 'windows' | 'linux' | 'chrome' | 'firefox' | 'safari')[]Operating systems / browsers the wallet supports.
jsBridgeKeystringwindow property name where the wallet exposes its TonConnectBridge object. key: 'mytonwallet'window.mytonwallet.tonconnect.
injectedbooleantrue when the wallet is injected into the current page.
embeddedbooleantrue when the dApp is running inside this wallet's in-app browser.

WalletInfoCurrentlyInjected

WalletInfoInjectable narrowed to wallets actually injected on the current page. Filter the wallets list with isWalletInfoCurrentlyInjected.

interface WalletInfoCurrentlyInjected {
    name: string;
    appName: string;
    imageUrl: string;
    tondns?: string;
    aboutUrl: string;
    features?: Feature[];
    platforms: ('ios' | 'android' | 'macos' | 'windows' | 'linux' | 'chrome' | 'firefox' | 'safari')[];
    jsBridgeKey: string;
    embedded: boolean;
    injected: true;
}
FieldTypeDescription
namestringHuman-readable display name shown in the wallet picker.
appNamestringWallet identifier — equals the DeviceInfo.appName reported by the connected Wallet at runtime.
imageUrlstringHTTPS URL of the wallet icon. 288×288 PNG on a non-transparent background, no rounded corners.
tondnsstringOptional.
aboutUrlstringInfo or landing page for the wallet — shown to new users.
featuresFeature[]Optional. Wallet capabilities advertised in the registry.
platforms('ios' | 'android' | 'macos' | 'windows' | 'linux' | 'chrome' | 'firefox' | 'safari')[]Operating systems / browsers the wallet supports.
jsBridgeKeystringwindow property name where the wallet exposes its TonConnectBridge object. key: 'mytonwallet'window.mytonwallet.tonconnect.
embeddedbooleantrue when the dApp is running inside this wallet's in-app browser.
injectedtruetrue when the wallet is injected into the current page.

WalletInfoCurrentlyEmbedded

WalletInfoCurrentlyInjected narrowed to the case where the dApp is running inside the wallet's webview. Detect with isWalletInfoCurrentlyEmbedded.

When the dApp boots inside a wallet, prefer connecting via this entry rather than showing a QR-code modal.

interface WalletInfoCurrentlyEmbedded {
    name: string;
    appName: string;
    imageUrl: string;
    tondns?: string;
    aboutUrl: string;
    features?: Feature[];
    platforms: ('ios' | 'android' | 'macos' | 'windows' | 'linux' | 'chrome' | 'firefox' | 'safari')[];
    jsBridgeKey: string;
    injected: true;
    embedded: true;
}
FieldTypeDescription
namestringHuman-readable display name shown in the wallet picker.
appNamestringWallet identifier — equals the DeviceInfo.appName reported by the connected Wallet at runtime.
imageUrlstringHTTPS URL of the wallet icon. 288×288 PNG on a non-transparent background, no rounded corners.
tondnsstringOptional.
aboutUrlstringInfo or landing page for the wallet — shown to new users.
featuresFeature[]Optional. Wallet capabilities advertised in the registry.
platforms('ios' | 'android' | 'macos' | 'windows' | 'linux' | 'chrome' | 'firefox' | 'safari')[]Operating systems / browsers the wallet supports.
jsBridgeKeystringwindow property name where the wallet exposes its TonConnectBridge object. key: 'mytonwallet'window.mytonwallet.tonconnect.
injectedtruetrue when the wallet is injected into the current page.
embeddedtruetrue when the dApp is running inside this wallet's in-app browser.

WalletInfoInjected

Deprecated — Use WalletInfoInjectable or WalletInfoCurrentlyInjected instead.

interface WalletInfoInjected {
    name: string;
    appName: string;
    imageUrl: string;
    tondns?: string;
    aboutUrl: string;
    features?: Feature[];
    platforms: ('ios' | 'android' | 'macos' | 'windows' | 'linux' | 'chrome' | 'firefox' | 'safari')[];
    jsBridgeKey: string;
    injected: boolean;
    embedded: boolean;
}
FieldTypeDescription
namestringHuman-readable display name shown in the wallet picker.
appNamestringWallet identifier — equals the DeviceInfo.appName reported by the connected Wallet at runtime.
imageUrlstringHTTPS URL of the wallet icon. 288×288 PNG on a non-transparent background, no rounded corners.
tondnsstringOptional.
aboutUrlstringInfo or landing page for the wallet — shown to new users.
featuresFeature[]Optional. Wallet capabilities advertised in the registry.
platforms('ios' | 'android' | 'macos' | 'windows' | 'linux' | 'chrome' | 'firefox' | 'safari')[]Operating systems / browsers the wallet supports.
jsBridgeKeystring
injectedboolean
embeddedboolean

Wallet

The connected wallet as seen by the dApp. Returned by ITonConnect.wallet and emitted on every onStatusChange callback after a successful connect; null while no wallet is connected.

interface Wallet {
    device: DeviceInfo;
    provider: 'http' | 'injected';
    account: Account;
    connectItems?: { tonProof?: TonProofItemReply };
    embeddedResponse?: EmbeddedResponse;
}
FieldTypeDescription
deviceDeviceInfoMetadata reported by the wallet during the connect handshake — platform, application name and version, max supported protocol version, and the list of advertised features.
provider'http' | 'injected'Transport carrying the session. - 'http' — the wallet is reached through the HTTP (SSE) bridge listed in the wallets registry. dApp and wallet typically run on different devices. - 'injected' — the wallet exposes a JS bridge object on window (a browser extension, or the dApp running inside the wallet's webview).
accountAccountAccount the user picked during connect.
connectItems{ tonProof?: TonProofItemReply }Optional. Replies for the optional ConnectItems the dApp requested in addition to ton_addr.
embeddedResponseEmbeddedResponseOptional. Result of an embedded request, when one was folded into the connect URL. Set only if the SDK encoded an EmbeddedRequest into the connect URL, and the wallet advertises the EmbeddedRequest feature and processed it during connect. Absence means the wallet completed only the connect step.

IStorage

Async key-value store used by the SDK to persist protocol state (session keys, last connected wallet info, restoration markers).

In the browser the SDK uses window.localStorage by default. In Node.js, React Native or any other environment without a localStorage global the dApp MUST pass a custom implementation on TonConnectOptions.storage.

interface IStorage {
    setItem(key: string, value: string): Promise<void>;
    getItem(key: string): Promise<string | null>;
    removeItem(key: string): Promise<void>;
}

EventDispatcher

Interface for an event dispatcher that sends events.

interface EventDispatcher {
    dispatchEvent<P extends `ton-connect-${string}` | `ton-connect-ui-${string}`>(
        eventName: P,
        eventDetails: T & { type: RemoveTonConnectPrefix<P> }
    ): Promise<void>;
    addEventListener<P extends `ton-connect-${string}` | `ton-connect-ui-${string}`>(
        eventName: P,
        listener: (event: CustomEvent<T & { type: RemoveTonConnectPrefix<P> }>) => void,
        options?: AddEventListenerOptions
    ): Promise<() => void>;
}

AnalyticsMode

type AnalyticsMode = 'off' | 'telemetry' | 'full';

TelegramUser

Basic Telegram user information.

type TelegramUser = { id: number; isPremium: boolean };

EmbeddedRequest

Method + payload pair the SDK can fold into the connect URL as an embedded request (e parameter).

type EmbeddedRequest =
    | { method: 'sendTransaction'; request: SendTransactionRequest }
    | { method: 'signData'; request: SignDataPayload }
    | { method: 'signMessage'; request: SignMessageRequest };

SendTransactionRequest

Payload of sendTransaction method.

type SendTransactionRequest = SendTransactionRequestWithMessages | SendTransactionRequestWithItems;

StructuredItem

Structured items describe what the transaction should do (send Gram, transfer a jetton, transfer an NFT) and let the wallet build the BoC.

Wallets advertise structured-item support through the SendTransactionFeature.itemTypes and SignMessageFeature.itemTypes features.

type StructuredItem = TonItem | JettonItem | NftItem;

SignDataResponse

Result of signData method.

type SignDataResponse = { signature: string; address: string; timestamp: number; domain: string; payload: SignDataPayload };

SignMessageRequest

Payload for ITonConnect.signMessage / TonConnectUI.signMessage.

Identical in shape to SendTransactionRequest.

type SignMessageRequest = SendTransactionRequest;

RequiredFeatures

Wallet capabilities the dApp depends on.

Top-level keys combine as a logical AND — declaring sendTransaction and signMessage requires both. A wallet matches when every requirement listed appears in its DeviceInfo.features.

type RequiredFeatures = {
    sendTransaction?: RequiredSendTransactionFeature;
    signData?: RequiredSignDataFeature;
    signMessage?: RequiredSignMessageFeature;
    embeddedRequest?: RequiredEmbeddedRequestFeature;
};

RequiredSendTransactionFeature

Filter for the wallet's SendTransaction capability.

type RequiredSendTransactionFeature = { minMessages?: number; extraCurrencyRequired?: boolean; itemTypes?: StructuredItemType[] };

RequiredSignDataFeature

Filter for the wallet's SignData capability.

type RequiredSignDataFeature = { types: SignDataType[] };

RequiredSignMessageFeature

Filter for the wallet's SignMessage capability. Same shape as RequiredSendTransactionFeature; checked against the wallet's SignMessage feature entry.

type RequiredSignMessageFeature = { minMessages?: number; extraCurrencyRequired?: boolean; itemTypes?: StructuredItemType[] };

RequiredEmbeddedRequestFeature

Marker filter for the wallet's EmbeddedRequest feature. The feature itself has no parameters; pass {} to require it.

type RequiredEmbeddedRequestFeature = {};

WalletConnectionSource

Selector passed to ITonConnect.connect() that tells the SDK how to reach a specific wallet. Discriminated union of the three transports the protocol supports.

type WalletConnectionSource = WalletConnectionSourceHTTP | WalletConnectionSourceJS | WalletConnectionSourceWalletConnect;

WalletInfo

type WalletInfo = WalletInfoRemote | WalletInfoInjectable | (WalletInfoRemote & WalletInfoInjectable);

EmbeddedResponse

Result the wallet attached to the connect event when an embedded request was folded into the connect URL.

Discriminated by ok:

  • ok: true — the wallet processed the request. result carries the regular method response (SendTransactionResponse, SignDataResponse or SignMessageResponse), whichever method was embedded.
  • ok: false — the wallet returned an error in place of a result. error matches the RPC error shape; the per-method error tables live in the RPC specification.
type EmbeddedResponse =
    | { ok: true; result: SendTransactionResponse | SignDataResponse | SignMessageResponse }
    | { ok: false; error: { code: number; message: string; data?: unknown } };

WalletConnectMetadata

Metadata information about your application that will be displayed to users during WalletConnect pairing.

type WalletConnectMetadata = { name: string; description: string; url: string; icons: string[] };

WalletConnectOptions

Configuration options for initializing WalletConnect integration.

type WalletConnectOptions = { projectId: string; metadata: WalletConnectMetadata };

RemoveTonConnectPrefix

Removes the ton-connect- and ton-connect-ui- prefixes from the given string.

type RemoveTonConnectPrefix<T> = T extends `ton-connect-ui-${infer Rest}` ? Rest : T extends `ton-connect-${infer Rest}` ? Rest : T;

AddTonConnectPrefix

type AddTonConnectPrefix<T extends string> = `ton-connect-${T}` | `ton-connect-ui-${T}`;

RequestVersionEvent

Request TON Connect UI version.

type RequestVersionEvent = { type: 'request-version' };

ResponseVersionEvent

Response TON Connect UI version.

type ResponseVersionEvent = { type: 'response-version'; version: string };

VersionEvent

Version events.

type VersionEvent = RequestVersionEvent | ResponseVersionEvent;

Version

Version of the TON Connect SDK and TON Connect UI.

type Version = { ton_connect_sdk_lib: string | null; ton_connect_ui_lib: string | null };

SessionInfo

type SessionInfo = { clientId: string | null; walletId: string | null };

AuthType

Requested authentication type: 'ton_addr' or 'ton_proof'.

type AuthType = ConnectItem['name'];

ConnectionInfo

Information about a connected wallet.

type ConnectionInfo = {
    wallet_address: string | null;
    wallet_state_init: string | null;
    wallet_type: string | null;
    wallet_version: string | null;
    auth_type: AuthType;
    custom_data:
        & {
            chain_id: string | null;
            provider: 'http' | 'injected' | null;
            client_id: string | null;
            wallet_id: string | null;
        }
        & Version;
};

ConnectionStartedEvent

Initial connection event when a user initiates a connection.

type ConnectionStartedEvent = { type: 'connection-started'; custom_data: Version; trace_id?: string | null };

ConnectionCompletedEvent

Successful connection event when a user successfully connected a wallet.

type ConnectionCompletedEvent = { type: 'connection-completed'; is_success: true; trace_id?: string | null } & ConnectionInfo;

ConnectionErrorEvent

Connection error event when a user cancels a connection or there is an error during the connection process.

type ConnectionErrorEvent = {
    type: 'connection-error';
    is_success: false;
    error_message: string;
    error_code: CONNECT_EVENT_ERROR_CODES | null;
    custom_data: { client_id: string | null; wallet_id: string | null } & Version;
    trace_id?: string | null;
};

ConnectionEvent

Connection events.

type ConnectionEvent = ConnectionStartedEvent | ConnectionCompletedEvent | ConnectionErrorEvent;

ConnectionRestoringStartedEvent

Connection restoring started event when initiates a connection restoring process.

type ConnectionRestoringStartedEvent = { type: 'connection-restoring-started'; custom_data: Version; trace_id?: string | null };

ConnectionRestoringCompletedEvent

Connection restoring completed event when successfully restored a connection.

type ConnectionRestoringCompletedEvent =
    & { type: 'connection-restoring-completed'; is_success: true; trace_id?: string | null }
    & ConnectionInfo;

ConnectionRestoringErrorEvent

Connection restoring error event when there is an error during the connection restoring process.

type ConnectionRestoringErrorEvent = {
    type: 'connection-restoring-error';
    is_success: false;
    error_message: string;
    custom_data: Version;
    trace_id?: string | null;
};

ConnectionRestoringEvent

Connection restoring events.

type ConnectionRestoringEvent = ConnectionRestoringStartedEvent | ConnectionRestoringCompletedEvent | ConnectionRestoringErrorEvent;

TransactionMessage

Transaction message.

type TransactionMessage = { address: string | null; amount: string | null };

TransactionFullMessage

Transaction message.

type TransactionFullMessage = { address: string | null; amount: string | null; payload: string | null; state_init: string | null };

TransactionInfo

Transaction information.

type TransactionInfo = { valid_until: string | null; from: string | null; messages: TransactionMessage[] };

TransactionFullInfo

Transaction information.

type TransactionFullInfo = Omit<TransactionInfo, 'messages'> & { messages: TransactionFullMessage[] };

TransactionSentForSignatureEvent

Initial transaction event when a user initiates a transaction.

type TransactionSentForSignatureEvent =
    & { type: 'transaction-sent-for-signature'; trace_id?: string | null }
    & ConnectionInfo
    & TransactionInfo;

TransactionSignedEvent

Transaction signed event when a user successfully signed a transaction.

type TransactionSignedEvent =
    & {
        type: 'transaction-signed';
        is_success: true;
        signed_transaction: string;
        trace_id?: string | null;
    }
    & ConnectionInfo
    & TransactionInfo;

TransactionSigningFailedEvent

Transaction error event when a user cancels a transaction or there is an error during the transaction process.

type TransactionSigningFailedEvent =
    & {
        type: 'transaction-signing-failed';
        is_success: false;
        error_message: string;
        error_code: SEND_TRANSACTION_ERROR_CODES | null;
        trace_id?: string | null;
    }
    & ConnectionInfo
    & TransactionFullInfo;

TransactionSigningEvent

Transaction events.

type TransactionSigningEvent = TransactionSentForSignatureEvent | TransactionSignedEvent | TransactionSigningFailedEvent;

DataSentForSignatureEvent

type DataSentForSignatureEvent =
    & { type: 'sign-data-request-initiated'; data: SignDataPayload; trace_id?: string | null }
    & ConnectionInfo;

DataSignedEvent

type DataSignedEvent =
    & {
        type: 'sign-data-request-completed';
        is_success: true;
        data: SignDataPayload;
        signed_data: SignDataResponse;
        trace_id?: string | null;
    }
    & ConnectionInfo;

DataSigningFailedEvent

type DataSigningFailedEvent =
    & {
        type: 'sign-data-request-failed';
        is_success: false;
        error_message: string;
        error_code: SIGN_DATA_ERROR_CODES | null;
        data: SignDataPayload;
        trace_id?: string | null;
    }
    & ConnectionInfo;

DataSigningEvent

type DataSigningEvent = DataSentForSignatureEvent | DataSignedEvent | DataSigningFailedEvent;

DisconnectionEvent

Disconnect event when a user initiates a disconnection.

type DisconnectionEvent = { type: 'disconnection'; scope: 'dapp' | 'wallet'; trace_id?: string | null } & ConnectionInfo;

WalletModalOpenedEvent

Represents the event triggered when the wallet modal is opened.

type WalletModalOpenedEvent = {
    type: 'wallet-modal-opened';
    client_id: string | null;
    visible_wallets: string[];
    custom_data: Version;
    trace_id: string | null;
};

SelectedWalletEvent

Represents the event triggered when the wallet is selected.

type SelectedWalletEvent = {
    type: 'selected-wallet';
    client_id: string | null;
    visible_wallets: string[];
    wallets_menu: 'explicit_wallet' | 'main_screen' | 'other_wallets';
    wallet_redirect_method?: 'tg_link' | 'external_link';
    wallet_redirect_link?: string;
    wallet_type: string | null;
    custom_data: Version;
    trace_id: string | null;
};

SdkActionEvent

User action events.

type SdkActionEvent =
    | VersionEvent
    | ConnectionEvent
    | ConnectionRestoringEvent
    | DisconnectionEvent
    | TransactionSigningEvent
    | DataSigningEvent
    | WalletModalOpenedEvent
    | SelectedWalletEvent;

WithoutVersion

Parameters without version field.

type WithoutVersion<T> = T extends [Version, ...infer Rest] ? [...Rest] : never;

ConsumableLike

Accept either a bare value or a value already wrapped in a Consumable.

type ConsumableLike<T> = T | Consumable<T>;

Traceable

Wraps a value with a required traceId — a UUID used to correlate logs and analytics across the dApp, bridge and wallet for one user-visible operation.

type Traceable<T extends {} = {}> = { traceId: string } & T;

OptionalTraceable

Wraps a value with an optional traceId.

type OptionalTraceable<T extends {} = {}> = { traceId?: string } & T;

UUIDTypes

type UUIDTypes<TBuf extends Uint8Array = Uint8Array> = string | TBuf;

Version7Options

type Version7Options = { random?: Uint8Array; msecs?: number; seq?: number; rng?: () => Uint8Array };

Utility functions

initializeWalletConnect()

Initializes the WalletConnect integration.

This function must be called once before using WalletConnect features. A second call will throw an error to prevent accidental re-initialization.

function initializeWalletConnect(
    UniversalConnectorCls: Function,
    walletConnectOptions: WalletConnectOptions
): void;
ParameterTypeDescription
UniversalConnectorClsFunctionA UniversalConnector class imported from @reown/appkit-universal-connector
walletConnectOptionsWalletConnectOptionsConfiguration options used for initializing WalletConnect.

Example:

import { UniversalConnector } from '@reown/appkit-universal-connector';

initializeWalletConnect(UniversalConnector, {
    projectId: 'abcd1234abcd1234abcd1234abcd1234',
    metadata: {
        name: 'Demo DApp',
        icons: [
            'https://example.com/my-icon.png'
        ],
        url: window.location.origin,
        description: 'Demo DApp'
    }
});

isWalletConnectInitialized()

function isWalletConnectInitialized(): boolean;

Returns boolean.

toUserFriendlyAddress()

Convert a raw <workchain>:<hex> TON address into the URL-safe, non-bounceable user-friendly form (UQ… on mainnet, 0Q… on testnet).

function toUserFriendlyAddress(hexAddress: string, testOnly: boolean = false): string;
ParameterTypeDescription
hexAddressstring— raw address, e.g. '0:348bcf...0415f'.
testOnlybooleanOptional. — set the test-only flag; Defaults to false.

Returns string. Base64url-encoded user-friendly address.

checkRequiredWalletFeatures()

Test whether a wallet's advertised features satisfy a RequiredFeatures filter.

function checkRequiredWalletFeatures(
    features: Feature[],
    walletsRequiredFeatures?: RequiredFeatures
): boolean;
ParameterTypeDescription
featuresFeature[]
walletsRequiredFeaturesRequiredFeaturesOptional.

Returns boolean. true when every constraint in walletsRequiredFeatures matches, false otherwise.

enableQaMode()

function enableQaMode(): void;

isQaModeEnabled()

function isQaModeEnabled(): boolean;

Returns boolean.

UUIDv7()

function UUIDv7(options?: Version7Options, buf?: undefined, offset?: number): string;
ParameterTypeDescription
optionsVersion7OptionsOptional.
bufundefinedOptional.
offsetnumberOptional.

Returns string.

Type guards

FunctionDescription
hasItems(req)Type guard: narrows to SendTransactionRequestWithItems.
hasMessages(req)Type guard: narrows to SendTransactionRequestWithMessages.
isWalletInfoCurrentlyInjected(value)Checks if WalletInfo is WalletInfoInjectable and WalletInfo is injected to the current webpage (walletInfo.injected === true).
isWalletInfoCurrentlyEmbedded(value)Checks if WalletInfo is WalletInfoInjectable and dApp is opened inside this wallet's browser.
isWalletInfoInjectable(value)Checks if WalletInfo is WalletInfoInjectable, but doesn't check if it is injected to the page or not.
isWalletInfoRemote(value)Checks if WalletInfo is WalletInfoRemote.
isWalletInfoInjected(value)Deprecated — Use isWalletInfoInjectable or isWalletInfoCurrentlyInjected instead.

URL helpers

FunctionDescription
isTelegramUrl(link)Type guard for Telegram links — matches both the tg:// scheme and https://t.me/….
isConnectUrl(link)Type guard that returns true when link looks like a TON Connect connect URL — i.e. it carries the ton_addr request item (raw or Telegram-encoded). Useful for discriminating handler URLs in deep-link routers.
encodeTelegramUrlParameters(parameters)Encode query parameters for transport inside a Telegram universal link. Telegram normalizes ASCII punctuation in URLs, which breaks the encoded connect payload; this helper substitutes the affected characters with pass-through markers that decodeTelegramUrlParameters reverses.
decodeTelegramUrlParameters(parameters)Inverse of encodeTelegramUrlParameters.

Tracker events

FunctionDescription
createRequestVersionEvent()Create a request version event.
createResponseVersionEvent(version)Create a response version event.
createVersionInfo(version)Create a version info.
createConnectionStartedEvent(version, traceId?)Create a connection init event.
createConnectionCompletedEvent(version, wallet, sessionInfo?, traceId?)Create a connection completed event.
createConnectionErrorEvent(version, error_message, errorCode, sessionInfo?, traceId?)Create a connection error event.
createConnectionRestoringStartedEvent(version, traceId?)Create a connection restoring started event.
createConnectionRestoringCompletedEvent(version, wallet, sessionInfo?, traceId?)Create a connection restoring completed event.
createConnectionRestoringErrorEvent(version, errorMessage, traceId?)Create a connection restoring error event.
createTransactionSentForSignatureEvent(version, wallet, transaction, sessionInfo?, traceId?)Create a transaction init event.
createTransactionSignedEvent(version, wallet, transaction, signedTransaction, sessionInfo?, traceId?)Create a transaction signed event.
createTransactionSigningFailedEvent(version, wallet, transaction, errorMessage, errorCode, sessionInfo?, traceId?)Create a transaction error event.
createDataSentForSignatureEvent(version, wallet, data, sessionInfo?, traceId?)
createDataSignedEvent(version, wallet, data, signedData, sessionInfo?, traceId?)
createDataSigningFailedEvent(version, wallet, data, errorMessage, errorCode, sessionInfo?, traceId?)
createDisconnectionEvent(version, wallet, scope, sessionInfo?, traceId?)
createWalletModalOpenedEvent(version, visibleWallets, clientId?, traceId?)
createSelectedWalletEvent(version, visibleWallets, lastSelectedWallet, walletsMenu, redirectLink, redirectLinkType?, clientId?, traceId?)

Errors

Every error from this package extends TonConnectError. Use err instanceof TonConnectError as a coarse filter; check the concrete class for finer handling.

TonConnectError

Base class for every error thrown by @tonconnect/sdk. Catch it to handle TON Connect failures uniformly.

class TonConnectError extends Error {
    constructor(message?: string, options?: { cause?: T });
}

Error catalogue

ClassThrown when
WrongAddressErrorThrown when passed address is in incorrect format.
ParseHexErrorThrown when passed hex is in incorrect format.
UserRejectsErrorThrown when user rejects the action in the wallet.
BadRequestErrorThrown when request to the wallet contains errors.
UnknownAppErrorThrown when the wallet returns UNKNOWN_APP (code 100): the session or app is unknown to the wallet.
LocalstorageNotFoundErrorThrown when no storage was specified in TonConnectOptions and a default localStorage was not detected in the Node.js environment.
UnknownErrorUnhanded unknown error.
WalletAlreadyConnectedErrorThrown when wallet connection called but wallet already connected.
WalletMissingRequiredFeaturesErrorThrown when a wallet completes the connect handshake but its advertised DeviceInfo.features do not satisfy the dApp's walletsRequiredFeatures filter. The SDK aborts the connection and emits this error to onStatusChange's error handler. Use cause.connectEvent to inspect what the wallet returned (its DeviceInfo, the ConnectItemReply array) when surfacing a useful message to the user.
WalletNotConnectedErrorThrown when send transaction or other methods called while wallet is not connected.
WalletNotInjectedErrorThrown when there is an attempt to connect to the injected wallet while it is not exists in the webpage.
WalletNotSupportFeatureErrorThrown when the dApp issues a request the connected wallet does not advertise support for — e.g. signMessage on a wallet missing the SignMessageFeature, or signData({ type: 'cell' }) on a wallet whose SignDataFeature.types lacks 'cell'. cause.requiredFeature reflects what the SDK looked for, so the UI can tell the user which capability is missing and prompt them to switch wallet.
WalletWrongNetworkErrorThrown when the wallet is connected to a network that does not match the one the dApp requested via ITonConnect.setConnectionNetwork or the network field of sendTransaction / signData / signMessage.
FetchWalletsErrorThrown when an error occurred while fetching the wallets list.

On this page

InstallationTonConnectConstructorInstance propertiesgetWallets()onStatusChange()connect()restoreConnection()sendTransaction()signData()signMessage()setConnectionNetwork()disconnect()getSessionId()pauseConnection()unPauseConnection()Static methodsITonConnectWalletsListManagerConstructorgetWallets()getEmbeddedWallet()getRemoteWallet()BrowserEventDispatcherConstructordispatchEvent()addEventListener()ConsumableConstructorInstance propertiespeek()consume()TypesIEnvironmentDappMetadataConnectAdditionalRequestSendTransactionRequestBaseSendTransactionRequestWithMessagesSendTransactionRequestWithItemsSendTransactionResponseTonItemJettonItemNftItemSignMessageResponseAnalyticsSettingsTonConnectOptionsAccountWalletConnectionSourceHTTPWalletConnectionSourceJSWalletConnectionSourceWalletConnectWalletInfoBaseWalletInfoRemoteWalletInfoInjectableWalletInfoCurrentlyInjectedWalletInfoCurrentlyEmbeddedWalletInfoInjectedWalletIStorageEventDispatcherAnalyticsModeTelegramUserEmbeddedRequestSendTransactionRequestStructuredItemSignDataResponseSignMessageRequestRequiredFeaturesRequiredSendTransactionFeatureRequiredSignDataFeatureRequiredSignMessageFeatureRequiredEmbeddedRequestFeatureWalletConnectionSourceWalletInfoEmbeddedResponseWalletConnectMetadataWalletConnectOptionsRemoveTonConnectPrefixAddTonConnectPrefixRequestVersionEventResponseVersionEventVersionEventVersionSessionInfoAuthTypeConnectionInfoConnectionStartedEventConnectionCompletedEventConnectionErrorEventConnectionEventConnectionRestoringStartedEventConnectionRestoringCompletedEventConnectionRestoringErrorEventConnectionRestoringEventTransactionMessageTransactionFullMessageTransactionInfoTransactionFullInfoTransactionSentForSignatureEventTransactionSignedEventTransactionSigningFailedEventTransactionSigningEventDataSentForSignatureEventDataSignedEventDataSigningFailedEventDataSigningEventDisconnectionEventWalletModalOpenedEventSelectedWalletEventSdkActionEventWithoutVersionConsumableLikeTraceableOptionalTraceableUUIDTypesVersion7OptionsUtility functionsinitializeWalletConnect()isWalletConnectInitialized()toUserFriendlyAddress()checkRequiredWalletFeatures()enableQaMode()isQaModeEnabled()UUIDv7()Type guardsURL helpersTracker eventsErrorsTonConnectErrorError catalogueRelated pages