Documentation Index
Fetch the complete documentation index at: https://companyname-a7d5b98e-feature-fumodocs.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
@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:window.TonConnectSDK:
@latest with the desired version, e.g. @3.5.0.
Generated from @tonconnect/sdk v3.5.0-alpha.0.
TonConnect
Constructor
| Parameter | Type | Description |
|---|---|---|
options | TonConnectOptions | Optional. |
Instance properties
| Property | Type | Description |
|---|---|---|
connected | boolean | Shows if the wallet is connected right now. |
account | Account | null | Current connected account or null if no account is connected. |
wallet | Wallet | null | Current connected wallet or null if no account is connected. |
getWallets()
Returns the available wallets list. The internal wallets-list manager
falls back to a bundled list if the configured walletsListSource is
unreachable, so this method does not throw FetchWalletsError.
Promise<WalletInfo[]>.
onStatusChange()
Allows to subscribe to connection status changes and handle connection errors.
| Parameter | Type | Description |
|---|---|---|
callback | (wallet: Wallet | null) => void | Fires after the connection status changes, receiving the active wallet or null. |
errorsHandler | (err: TonConnectError) => void | Optional. Fires with a TonConnectError instance when a connect error is received. |
() => 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.
| Parameter | Type | Description |
|---|---|---|
wallet | T | Wallet’s bridge url and universal link for an external wallet or jsBridge key for the injected wallet. |
options | OptionalTraceable<{ request?: ConnectAdditionalRequest; openingDeadlineMS?: number; signal?: AbortSignal; embeddedRequest?: ConsumableLike<EmbeddedRequest> }> | Optional. openingDeadlineMS sets the connection opening deadline; signal aborts the connection. Pass ton_proof and other connect-additional-request fields via options.request. |
T extends WalletConnectionSourceJS ? void : T extends WalletConnectionSourceWalletConnect ? void : string. Universal link if external wallet was passed or void for the injected wallet.
Throws:
WalletAlreadyConnectedError— a wallet is already connected — disconnect first.TonConnectError— the connect-additional-request or embedded request failed validation, or the connection was aborted viaoptions.signal.
@deprecated — use connect(wallet, options) instead.
restoreConnection()
Try to restore existing session and reconnect to the corresponding wallet. Call it immediately when your app is loaded.
| Parameter | Type | Description |
|---|---|---|
options | OptionalTraceable<{ openingDeadlineMS?: number; signal?: AbortSignal }> | Optional. |
Promise<void>.
sendTransaction()
Asks connected wallet to sign and send the transaction.
| Parameter | Type | Description |
|---|---|---|
transaction | SendTransactionRequest | Transaction to send. |
options | OptionalTraceable<{ onRequestSent?: () => void; signal?: AbortSignal }> | Optional. onRequestSent fires after the request is sent to the wallet; signal aborts the transaction. |
Promise<Traceable<SendTransactionResponse>>. Signed transaction boc that allows you to find the transaction in the blockchain.
Throws:
WalletNotConnectedError— no wallet is currently connected.WalletNotSupportFeatureError— the connected wallet does not advertise support for the requested transaction shape (messages, items, or extra currencies).WalletWrongNetworkError— the wallet’saccount.chaindiffers from the network ontransaction.UserRejectsError— the user rejected the transaction in the wallet UI.BadRequestError— the wallet rejected the request as malformed.UnknownAppError— the wallet does not recognise this dApp session.TonConnectError—transactionfailed validation or the request was aborted viaoptions.signal.
@deprecated — use sendTransaction(transaction, options) instead.
signData()
Asks the connected wallet to sign an arbitrary payload (text, binary, or
structured cell) and return the user’s signature. The payload is not
broadcast to the blockchain — only signed.
| Parameter | Type | Description |
|---|---|---|
data | SignDataPayload | Payload to sign. The type discriminator selects the payload form ('text', 'binary', or 'cell'). |
options | OptionalTraceable<{ onRequestSent?: () => void; signal?: AbortSignal }> | Optional. onRequestSent fires once the request has been dispatched to the wallet; signal aborts the in-flight signing request. |
Promise<Traceable<SignDataResponse>>. The signed payload together with the signer address, the domain the dApp was opened under, and the wallet-stamped timestamp.
Throws:
WalletNotConnectedError— no wallet is currently connected.WalletNotSupportFeatureError— the connected wallet does not advertise support for the requested payload type via itssignDatafeature.WalletWrongNetworkError— the wallet’saccount.chaindiffers from the network ondata.UserRejectsError— the user rejected the request in the wallet UI.BadRequestError— the wallet rejected the payload as malformed.UnknownAppError— the wallet does not recognise this dApp session.TonConnectError—datafailed validation or the request was aborted viaoptions.signal.
signMessage()
Asks the connected wallet to sign an internal-message body (BoC) without
sending it to the blockchain. Use this when the dApp needs a signed
message it will relay itself.
| Parameter | Type | Description |
|---|---|---|
message | SignMessageRequest | Message to sign. Carries the same messages / items shape as a transaction request. |
options | OptionalTraceable<{ onRequestSent?: () => void; signal?: AbortSignal }> | Optional. onRequestSent fires once the request has been dispatched to the wallet; signal aborts the in-flight signing request. |
Promise<Traceable<SignMessageResponse>>. The signed internal-message BoC.
Throws:
WalletNotConnectedError— no wallet is currently connected.WalletNotSupportFeatureError— the connected wallet does not advertise support for the requested message shape via itssignMessagefeature.WalletWrongNetworkError— the wallet’saccount.chaindiffers from the network onmessage.UserRejectsError— the user rejected the request in the wallet UI.BadRequestError— the wallet rejected the message as malformed.UnknownAppError— the wallet does not recognise this dApp session.TonConnectError—messagefailed validation or the request was aborted viaoptions.signal.
setConnectionNetwork()
Set desired network for the connection. Can only be set before connecting.
If the wallet connects with a different chain, the SDK throws an error and aborts the connection.
| Parameter | Type | Description |
|---|---|---|
network | ChainId | Optional. Desired network id (e.g., ‘-239’, ‘-3’, or custom). Pass undefined to allow any network. |
TonConnectError — a wallet is already connected — disconnect before changing the desired network.
disconnect()
Disconnect from the connected wallet and drop the current session.
| Parameter | Type | Description |
|---|---|---|
options | OptionalTraceable<{ signal?: AbortSignal }> | Optional. |
Promise<void>.
Throws:
WalletNotConnectedError— no wallet is currently connected.TonConnectError— the request was aborted viaoptions.signal.
getSessionId()
Gets the current session ID if available.
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 Node.js and want to save server resources.
unPauseConnection()
Unpause bridge HTTP connection if it is paused.
Promise<void>.
Static methods
| Method | Description |
|---|---|
TonConnect.isWalletInjected(walletJSKey) | Check if specified wallet is injected and available to use with the app. |
TonConnect.isInsideWalletBrowser(walletJSKey) | Check if the app is opened inside specified wallet’s browser. |
TonConnect.getWallets() | Returns available wallets list. |
ITonConnect
Public interface implemented by TonConnect. Use it to type the connector in code that does not depend on the concrete implementation.
WalletsListManager
Constructor
| Parameter | Type | Description |
|---|---|---|
options | { walletsListSource?: string; cacheTTLMs?: number; onDownloadDurationMeasured?: (duration: number | undefined) => void } | Optional. |
getWallets()
Promise<WalletInfo[]>.
getEmbeddedWallet()
Promise<WalletInfoCurrentlyEmbedded | null>.
getRemoteWallet()
| Parameter | Type | Description |
|---|---|---|
appName | string | — |
Promise<WalletInfoRemote>.
BrowserEventDispatcher
A concrete implementation of EventDispatcher that dispatches events to the browser window.
Constructor
dispatchEvent()
Dispatches an event with the given name and details to the browser window.
| Parameter | Type | Description |
|---|---|---|
eventName | P | The name of the event to dispatch. |
eventDetails | T & { type: RemoveTonConnectPrefix<P> } | The details of the event to dispatch. |
Promise<void>. A promise that resolves when the event has been dispatched.
addEventListener()
Adds an event listener to the browser window.
| Parameter | Type | Description |
|---|---|---|
eventName | P | The name of the event to listen for. |
listener | (event: CustomEvent<T & { type: RemoveTonConnectPrefix<P> }>) => void | The listener to add. |
options | AddEventListenerOptions | Optional. The options for the listener. |
Promise<() => void>. A function that removes the listener.
Consumable
Constructor
| Parameter | Type | Description |
|---|---|---|
value | ConsumableLike<T> | — |
Instance properties
| Property | Type | Description |
|---|---|---|
consumed | boolean | — |
peek()
T | undefined.
consume()
T | undefined.
Types
IEnvironment
Represents the client environment in which the application is running.
DappMetadata
| Field | Type | Description |
|---|---|---|
name | string | dApp name. Might be simple; not used as identifier. Defaults to document.title, or to 'Unknown dApp' when no document title is present. |
icon | string | URL to the dApp icon. Must be PNG, ICO, … . SVG icons are not supported. Defaults to the best-quality favicon declared via a <link> element in the document, or to an empty string when no favicon is declared. |
url | string | — |
ConnectAdditionalRequest
| Field | Type | Description |
|---|---|---|
tonProof | string | Optional. Payload for ton_proof |
SendTransactionRequestBase
| Field | Type | Description |
|---|---|---|
validUntil | number | Sending transaction deadline in unix epoch seconds. |
network | string | Optional. The network (mainnet or testnet) where DApp intends to send the transaction. If not set, the transaction is sent to the network currently set in the wallet, but this is not safe and DApp should always strive to set the network. If the network parameter is set, but the wallet has a different network set, the wallet should show an alert and DO NOT ALLOW TO SEND this transaction. |
from | string | Optional. The sender address in '<wc>:<hex>' format from which DApp intends to send the transaction. Current account.address by default. |
SendTransactionRequestWithMessages
| Field | Type | Description |
|---|---|---|
validUntil | number | Sending transaction deadline in unix epoch seconds. |
network | string | Optional. The network (mainnet or testnet) where DApp intends to send the transaction. If not set, the transaction is sent to the network currently set in the wallet, but this is not safe and DApp should always strive to set the network. If the network parameter is set, but the wallet has a different network set, the wallet should show an alert and DO NOT ALLOW TO SEND this transaction. |
from | string | Optional. The sender address in '<wc>:<hex>' format from which DApp intends to send the transaction. Current account.address by default. |
messages | { address: string; amount: string; stateInit?: string; payload?: string; extraCurrency?: {} }[] | Messages to send: min is 1, max is 255. |
items | undefined | Optional. |
SendTransactionRequestWithItems
| Field | Type | Description |
|---|---|---|
validUntil | number | Sending transaction deadline in unix epoch seconds. |
network | string | Optional. The network (mainnet or testnet) where DApp intends to send the transaction. If not set, the transaction is sent to the network currently set in the wallet, but this is not safe and DApp should always strive to set the network. If the network parameter is set, but the wallet has a different network set, the wallet should show an alert and DO NOT ALLOW TO SEND this transaction. |
from | string | Optional. The sender address in '<wc>:<hex>' format from which DApp intends to send the transaction. Current account.address by default. |
items | StructuredItem[] | Structured transaction items. The wallet constructs the BoC for each item. |
messages | undefined | Optional. |
SendTransactionResponse
| Field | Type | Description |
|---|---|---|
boc | string | Signed boc |
TonItem
| Field | Type | Description |
|---|---|---|
type | 'ton' | — |
address | string | Destination address in friendly format. |
amount | string | Amount in nanocoins as string. |
payload | string | Optional. Raw one-cell BoC encoded in Base64. |
stateInit | string | Optional. Raw one-cell BoC encoded in Base64. |
extraCurrency | {} | Optional. Extra currencies to send. |
JettonItem
| Field | Type | Description |
|---|---|---|
type | 'jetton' | — |
master | string | Jetton master contract address. |
destination | string | Recipient address. |
amount | string | Jetton amount in elementary units. |
attachAmount | string | Optional. TON to attach for fees; wallet calculates if omitted. |
responseDestination | string | Optional. Where to send excess; defaults to sender. |
customPayload | string | Optional. Raw one-cell BoC encoded in Base64. |
forwardAmount | string | Optional. Nanotons to forward to destination. |
forwardPayload | string | Optional. Raw one-cell BoC encoded in Base64. |
queryId | string | Optional. Custom query ID for the transfer. |
NftItem
| Field | Type | Description |
|---|---|---|
type | 'nft' | — |
nftAddress | string | NFT item contract address. |
newOwner | string | Address of the new owner. |
attachAmount | string | Optional. TON to attach for fees; wallet calculates if omitted. |
responseDestination | string | Optional. Where to send excess; defaults to sender. |
customPayload | string | Optional. Raw one-cell BoC encoded in Base64. |
forwardAmount | string | Optional. Nanotons to forward to destination. |
forwardPayload | string | Optional. Raw one-cell BoC encoded in Base64. |
queryId | string | Optional. Custom query ID for the transfer. |
SignMessageResponse
| Field | Type | Description |
|---|---|---|
internalBoc | string | Signed message BoC (base64). |
AnalyticsSettings
| Field | Type | Description |
|---|---|---|
mode | AnalyticsMode | Optional. |
TonConnectOptions
TonConnect constructor options
| Field | Type | Description |
|---|---|---|
manifestUrl | string | Optional. URL to the manifest with the dApp metadata that the wallet displays to the user. If not passed, the SDK loads the manifest from ${window.location.origin}/tonconnect-manifest.json. |
storage | IStorage | Optional. Storage to save protocol data. For browser default is localStorage. If you use SDK with Node.js, you have to specify this field. |
eventDispatcher | EventDispatcher<SdkActionEvent> | Optional. Event dispatcher to track user actions. By default, it uses window.dispatchEvent for browser environment. |
walletsListSource | string | Optional. Redefine wallets list source URL. Must be a link to a json file with following structure |
walletsListCacheTTLMs | number | Optional. Wallets list cache time to live |
walletsRequiredFeatures | RequiredFeatures | Optional. Required features for wallets. If wallet doesn’t support required features, it will be disabled. |
disableAutoPauseConnection | boolean | Optional. Allows to disable auto pause/unpause SSE connection on ‘document.visibilitychange’ event. It is not recommended to change default behaviour. |
environment | IEnvironment | Optional. Represents the client environment in which the application is running. |
analytics | AnalyticsSettings | Optional. Analytics configuration. |
Account
| Field | Type | Description |
|---|---|---|
address | string | User’s address in “hex” format: "<wc>:<hex>". |
chain | string | User’s selected chain. |
walletStateInit | string | Base64 (not url safe) encoded wallet contract stateInit. Can be used to get user’s public key from the stateInit if the wallet contract doesn’t support corresponding get method. |
publicKey | string | Optional. Hex string without 0x prefix. |
WalletConnectionSourceHTTP
| Field | Type | Description |
|---|---|---|
universalLink | string | Base part of the wallet universal url. The link should support Ton Connect parameters. |
bridgeUrl | string | URL of the wallet’s implementation of the HTTP bridge. |
WalletConnectionSourceJS
| Field | Type | Description |
|---|---|---|
jsBridgeKey | string | If the wallet handles JS Bridge connection, specifies the binding for the bridge object accessible through window. Example: the key “tonkeeper” means the bridge can be accessed as window.tonkeeper. |
WalletConnectionSourceWalletConnect
| Field | Type | Description |
|---|---|---|
type | 'wallet-connect' | — |
WalletInfoBase
Common information for injectable and http-compatible wallets.
| Field | Type | Description |
|---|---|---|
name | string | Human-readable name of the wallet. |
appName | string | ID of the wallet, equals to the appName property into Wallet.device. |
imageUrl | string | URL to the icon of the wallet. Resolution 288×288px. On non-transparent background, without rounded corners. PNG format. |
tondns | string | Optional. TON DNS name of the wallet. Reserved for future protocol use. |
aboutUrl | string | Info or landing page of your wallet. May be useful for TON newcomers. |
features | Feature[] | Optional. List of features supported by the wallet. |
platforms | ('ios' | 'android' | 'macos' | 'windows' | 'linux' | 'chrome' | 'firefox' | 'safari')[] | OS and browsers where the wallet could be installed |
WalletInfoRemote
Http-compatible wallet information.
| Field | Type | Description |
|---|---|---|
name | string | Human-readable name of the wallet. |
appName | string | ID of the wallet, equals to the appName property into Wallet.device. |
imageUrl | string | URL to the icon of the wallet. Resolution 288×288px. On non-transparent background, without rounded corners. PNG format. |
tondns | string | Optional. TON DNS name of the wallet. Reserved for future protocol use. |
aboutUrl | string | Info or landing page of your wallet. May be useful for TON newcomers. |
features | Feature[] | Optional. List of features supported by the wallet. |
platforms | ('ios' | 'android' | 'macos' | 'windows' | 'linux' | 'chrome' | 'firefox' | 'safari')[] | OS and browsers where the wallet could be installed |
universalLink | string | Base part of the wallet universal url. The link should support Ton Connect parameters. |
deepLink | string | Optional. Native wallet app deepLink. The link should support Ton Connect parameters. |
bridgeUrl | string | URL of the wallet’s implementation of the HTTP bridge. |
WalletInfoInjectable
JS-injectable wallet information.
| Field | Type | Description |
|---|---|---|
name | string | Human-readable name of the wallet. |
appName | string | ID of the wallet, equals to the appName property into Wallet.device. |
imageUrl | string | URL to the icon of the wallet. Resolution 288×288px. On non-transparent background, without rounded corners. PNG format. |
tondns | string | Optional. TON DNS name of the wallet. Reserved for future protocol use. |
aboutUrl | string | Info or landing page of your wallet. May be useful for TON newcomers. |
features | Feature[] | Optional. List of features supported by the wallet. |
platforms | ('ios' | 'android' | 'macos' | 'windows' | 'linux' | 'chrome' | 'firefox' | 'safari')[] | OS and browsers where the wallet could be installed |
jsBridgeKey | string | If the wallet handles JS Bridge connection, specifies the binding for the bridge object accessible through window. Example: the key “tonkeeper” means the bridge can be accessed as window.tonkeeper. |
injected | boolean | Indicates if the wallet currently is injected to the webpage. |
embedded | boolean | Indicates if the dApp is opened inside this wallet’s browser. |
WalletInfoCurrentlyInjected
Information about the JS-injectable wallet that is injected to the current webpage.
| Field | Type | Description |
|---|---|---|
name | string | Human-readable name of the wallet. |
appName | string | ID of the wallet, equals to the appName property into Wallet.device. |
imageUrl | string | URL to the icon of the wallet. Resolution 288×288px. On non-transparent background, without rounded corners. PNG format. |
tondns | string | Optional. TON DNS name of the wallet. Reserved for future protocol use. |
aboutUrl | string | Info or landing page of your wallet. May be useful for TON newcomers. |
features | Feature[] | Optional. List of features supported by the wallet. |
platforms | ('ios' | 'android' | 'macos' | 'windows' | 'linux' | 'chrome' | 'firefox' | 'safari')[] | OS and browsers where the wallet could be installed |
jsBridgeKey | string | If the wallet handles JS Bridge connection, specifies the binding for the bridge object accessible through window. Example: the key “tonkeeper” means the bridge can be accessed as window.tonkeeper. |
embedded | boolean | Indicates if the dApp is opened inside this wallet’s browser. |
injected | true | Indicates if the wallet currently is injected to the webpage. |
WalletInfoCurrentlyEmbedded
Information about the JS-injectable wallet in the browser of which the dApp is opened.
| Field | Type | Description |
|---|---|---|
name | string | Human-readable name of the wallet. |
appName | string | ID of the wallet, equals to the appName property into Wallet.device. |
imageUrl | string | URL to the icon of the wallet. Resolution 288×288px. On non-transparent background, without rounded corners. PNG format. |
tondns | string | Optional. TON DNS name of the wallet. Reserved for future protocol use. |
aboutUrl | string | Info or landing page of your wallet. May be useful for TON newcomers. |
features | Feature[] | Optional. List of features supported by the wallet. |
platforms | ('ios' | 'android' | 'macos' | 'windows' | 'linux' | 'chrome' | 'firefox' | 'safari')[] | OS and browsers where the wallet could be installed |
jsBridgeKey | string | If the wallet handles JS Bridge connection, specifies the binding for the bridge object accessible through window. Example: the key “tonkeeper” means the bridge can be accessed as window.tonkeeper. |
injected | true | Indicates if the wallet currently is injected to the webpage. |
embedded | true | Indicates if the dApp is opened inside this wallet’s browser. |
WalletInfoInjected
| Field | Type | Description |
|---|---|---|
name | string | Human-readable name of the wallet. |
appName | string | ID of the wallet, equals to the appName property into Wallet.device. |
imageUrl | string | URL to the icon of the wallet. Resolution 288×288px. On non-transparent background, without rounded corners. PNG format. |
tondns | string | Optional. TON DNS name of the wallet. Reserved for future protocol use. |
aboutUrl | string | Info or landing page of your wallet. May be useful for TON newcomers. |
features | Feature[] | Optional. List of features supported by the wallet. |
platforms | ('ios' | 'android' | 'macos' | 'windows' | 'linux' | 'chrome' | 'firefox' | 'safari')[] | OS and browsers where the wallet could be installed |
jsBridgeKey | string | — |
injected | boolean | — |
embedded | boolean | — |
Wallet
| Field | Type | Description |
|---|---|---|
device | DeviceInfo | Information about user’s wallet’s device. |
provider | 'http' | 'injected' | Provider type: http bridge or injected js. |
account | Account | Selected account. |
connectItems | { tonProof?: TonProofItemReply } | Optional. Response for connect items request. |
embeddedResponse | EmbeddedResponse | Optional. Response to the embedded request. Present only if an EmbeddedRequest was embedded in the connect URL and the wallet processed it during connection. |
IStorage
Imitation of the localStorage.
EventDispatcher
Interface for an event dispatcher that sends events.
AnalyticsMode
TelegramUser
Basic Telegram user information.
EmbeddedRequest
SendTransactionRequest
StructuredItem
SignDataResponse
SignMessageRequest
RequiredFeatures
Required features for wallets.
RequiredSendTransactionFeature
Required features for the send transaction feature.
RequiredSignDataFeature
Required features for the sign data feature.
RequiredSignMessageFeature
Required features for the sign message feature.
RequiredEmbeddedRequestFeature
Required features for the embedded request feature.
WalletConnectionSource
WalletInfo
EmbeddedResponse
Parsed response to an embedded request.
Contains either a method-specific success result or an error.
WalletConnectMetadata
Metadata information about your application that is shown to users during WalletConnect pairing.
WalletConnectOptions
Configuration options for initializing WalletConnect integration.
RemoveTonConnectPrefix
Removes the ton-connect- and ton-connect-ui- prefixes from the given string.
AddTonConnectPrefix
RequestVersionEvent
Request TON Connect UI version.
ResponseVersionEvent
Response TON Connect UI version.
VersionEvent
Version events.
Version
Version of the TON Connect SDK and TON Connect UI.
SessionInfo
AuthType
Requested authentication type: ‘ton_addr’ or ‘ton_proof’.
ConnectionInfo
Information about a connected wallet.
ConnectionStartedEvent
Initial connection event when a user initiates a connection.
ConnectionCompletedEvent
Successful connection event when a user successfully connected a wallet.
ConnectionErrorEvent
Connection error event when a user cancels a connection or there is an error during the connection process.
ConnectionEvent
Connection events.
ConnectionRestoringStartedEvent
Connection restoring started event when initiates a connection restoring process.
ConnectionRestoringCompletedEvent
Connection restoring completed event when successfully restored a connection.
ConnectionRestoringErrorEvent
Connection restoring error event when there is an error during the connection restoring process.
ConnectionRestoringEvent
Connection restoring events.
TransactionMessage
Transaction message.
TransactionFullMessage
Transaction message.
TransactionInfo
Transaction information.
TransactionFullInfo
Transaction information.
TransactionSentForSignatureEvent
Initial transaction event when a user initiates a transaction.
TransactionSignedEvent
Transaction signed event when a user successfully signed a transaction.
TransactionSigningFailedEvent
Transaction error event when a user cancels a transaction or there is an error during the transaction process.
TransactionSigningEvent
Transaction events.
DataSentForSignatureEvent
DataSignedEvent
DataSigningFailedEvent
DataSigningEvent
DisconnectionEvent
Disconnect event when a user initiates a disconnection.
WalletModalOpenedEvent
Represents the event triggered when the wallet modal is opened.
SelectedWalletEvent
Represents the event triggered when the wallet is selected.
SdkActionEvent
User action events.
WithoutVersion
Parameters without version field.
ConsumableLike
Traceable
OptionalTraceable
UUIDTypes
Version7Options
Utility functions
initializeWalletConnect()
Initializes the WalletConnect integration. This function must be called once before using WalletConnect features.
A second call throws an error to prevent accidental re-initialization.
| Parameter | Type | Description |
|---|---|---|
UniversalConnectorCls | Function | A UniversalConnector class imported from ‘@reown/appkit-universal-connector’ |
walletConnectOptions | WalletConnectOptions | Configuration options used for initializing WalletConnect. |
isWalletConnectInitialized()
boolean.
toUserFriendlyAddress()
Converts raw TON address to no-bounceable user-friendly format. See details
| Parameter | Type | Description |
|---|---|---|
hexAddress | string | Raw TON address formatted as "0:<hex string without 0x>". |
testOnly | boolean | Optional. Convert address to test-only form. See details Defaults to false. |
string.
Example:
checkRequiredWalletFeatures()
| Parameter | Type | Description |
|---|---|---|
features | Feature[] | — |
walletsRequiredFeatures | RequiredFeatures | Optional. |
boolean.
enableQaMode()
isQaModeEnabled()
boolean.
UUIDv7()
| Parameter | Type | Description |
|---|---|---|
options | Version7Options | Optional. |
buf | undefined | Optional. |
offset | number | Optional. |
string.
Type guards
| Function | Description |
|---|---|
hasItems(req) | — |
hasMessages(req) | — |
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 WalletInfoInjected, but doesn’t check if it is injected to the page or not. |
isWalletInfoRemote(value) | Checks if WalletInfo is WalletInfoRemote. |
isWalletInfoInjected(value) | — |
URL helpers
| Function | Description |
|---|---|
isTelegramUrl(link) | — |
isConnectUrl(link) | — |
encodeTelegramUrlParameters(parameters) | — |
decodeTelegramUrlParameters(parameters) | — |
Tracker events
| Function | Description |
|---|---|
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 extendsTonConnectError. Use err instanceof TonConnectError as a coarse filter; check the concrete class for finer handling.
TonConnectError
Base class for TonConnect errors. You can check if the error was triggered by the @tonconnect/sdk using err instanceof TonConnectError.
super(...args); consumers normally interact with subclass
instances rather than constructing TonConnectError directly.
| Parameter | Type | Description |
|---|---|---|
message | string | Optional. Human-readable message. The resulting error.message is prefixed with [TON_CONNECT_SDK_ERROR] and the subclass name. |
options | { cause?: T } | Optional. Standard ES Error options. cause is typed by the subclass: WalletWrongNetworkError uses { expectedChainId, actualChainId }, WalletNotSupportFeatureError uses { requiredFeature }, and so on. |
Error catalogue
| Class | Thrown when |
|---|---|
WrongAddressError | Thrown when passed address is in incorrect format. |
ParseHexError | Thrown when passed hex is in incorrect format. |
UserRejectsError | Thrown when user rejects the action in the wallet. |
BadRequestError | Thrown when request to the wallet contains errors. |
UnknownAppError | Thrown when app tries to send rpc request to the injected wallet while not connected. |
LocalstorageNotFoundError | Thrown when Storage was not specified in the DappMetadata and default localStorage was not detected in the Node.js environment. |
UnknownError | Unhandled unknown error. |
WalletAlreadyConnectedError | Thrown when wallet connection called but wallet already connected. To avoid the error, disconnect the wallet before doing a new connection. |
WalletMissingRequiredFeaturesError | Thrown when the connected wallet’s device.features do not satisfy the features required by walletsRequiredFeatures (passed to the TonConnect constructor). The check happens after the wallet returns a successful connect response and runs through checkRequiredWalletFeatures. |
WalletNotConnectedError | Thrown when send transaction or other protocol methods called while wallet is not connected. |
WalletNotInjectedError | Thrown when there is an attempt to connect to the injected wallet while it is not exists in the webpage. |
WalletNotSupportFeatureError | Thrown when wallet doesn’t support requested feature method. |
WalletWrongNetworkError | Thrown when the wallet’s account.chain does not match the network the dApp expects — either the chain configured via setConnectionNetwork (on connect) or the network on a transaction or sign request. cause carries the expected and actual chain IDs for inspection. |
FetchWalletsError | Thrown when an error occurred while fetching the wallets list. |
Related pages
- Get started — integration walkthrough.
@tonconnect/ui— framework-agnostic UI on top of the SDK.@tonconnect/ui-react— React bindings.@tonconnect/protocol— wire-format types re-exported by the SDK.- TON Connect spec — normative protocol material.