' // Tonkeeper
}
];
connector.connect(sources);
```
--------------------------------
### Install 'encoding' package to resolve Next.js warning
Source: https://github.com/ton-connect/sdk/blob/main/docs/modules/_tonconnect_ui_react.html
Provides an optional command to install the `encoding` package using npm. This can suppress a 'Module not found' warning related to `node-fetch` in Next.js applications, though it's recommended to wait for a future SDK update.
```Shell
npm install encoding
```
--------------------------------
### Use useTonAddress Hook to Get User Wallet Address
Source: https://github.com/ton-connect/sdk/blob/main/docs/modules/_tonconnect_ui_react.html
Retrieve the user's current TON wallet address using the useTonAddress hook. You can specify whether to get the address in a user-friendly or raw format. Returns an empty string if no wallet is connected.
```TypeScript
import { useTonAddress } from '@tonconnect/ui-react';
export const Address = () => { const userFriendlyAddress = useTonAddress(); const rawAddress = useTonAddress(false); return ( address && (
User-friendly address: {userFriendlyAddress}
Raw address: {rawAddress}
)
);};
```
--------------------------------
### Install 'encoding' Package to Resolve Next.js Warning
Source: https://github.com/ton-connect/sdk/blob/main/packages/sdk/README.md
This command provides an optional solution to suppress the 'encoding' module warning encountered in Next.js applications using `node-fetch`. While the warning typically doesn't affect functionality, installing the `encoding` package can resolve it immediately. The recommended approach is to wait for future SDK updates.
```shell
npm install encoding
```
--------------------------------
### TonConnect: Initiate Connection with Backend Auth Payload
Source: https://github.com/ton-connect/sdk/blob/main/packages/sdk/README.md
This snippet demonstrates how to initiate a wallet connection using `connector.connect()` by passing a `tonProof` payload. This payload is fetched from the backend and is crucial for verifying the connection later.
```ts
connector.connect(
walletConnectionSource,
{ tonProof: "" }
);
```
--------------------------------
### Get Available Wallets
Source: https://github.com/ton-connect/sdk/blob/main/docs/classes/_tonconnect_ui.TonConnectUI.html
Retrieves a list of available wallets.
```APIDOC
getWallets(): Promise
Returns: Promise
Defined in: packages/ui/src/ton-connect-ui.ts:317
```
--------------------------------
### Get Wallets Required Features
Source: https://github.com/ton-connect/sdk/blob/main/docs/classes/_tonconnect_ui.TonConnectUI.html
Returns the required features of the wallets.
```APIDOC
get walletsRequiredFeatures(): undefined | RequiredFeatures
Returns: undefined | RequiredFeatures
Defined in: packages/ui/src/ton-connect-ui.ts:78
```
--------------------------------
### Get Wallets Preferred Features
Source: https://github.com/ton-connect/sdk/blob/main/docs/classes/_tonconnect_ui.TonConnectUI.html
Returns the preferred features of the wallets.
```APIDOC
get walletsPreferredFeatures(): undefined | RequiredFeatures
Returns: undefined | RequiredFeatures
Defined in: packages/ui/src/ton-connect-ui.ts:84
```
--------------------------------
### createConnectionRestoringStartedEvent
Source: https://github.com/ton-connect/sdk/blob/main/docs/types/_tonconnect_sdk.SdkActionEvent.html
A function to create an event indicating that the connection restoration process has started.
```APIDOC
createConnectionRestoringStartedEvent
```
--------------------------------
### WalletInfoCurrentlyInjected Property: platforms
Source: https://github.com/ton-connect/sdk/blob/main/docs/interfaces/_tonconnect_sdk.WalletInfoCurrentlyEmbedded.html
Defines the operating systems and browsers where the wallet can be installed. This property is inherited from WalletInfoCurrentlyInjected.
```APIDOC
platforms: ("ios" | "android" | "macos" | "windows" | "linux" | "chrome" | "firefox" | "safari")[]
```
--------------------------------
### Solid App Basic CSS Styling
Source: https://github.com/ton-connect/sdk/blob/main/packages/ui/index.html
Provides basic CSS styling for a Solid application, setting full height for html and body elements and positioning a button root element.
```css
html, body { height: 100%; } #button-root { float: right; margin: 20px; }
```
--------------------------------
### Get Modal State
Source: https://github.com/ton-connect/sdk/blob/main/docs/classes/_tonconnect_ui.TonConnectUI.html
Returns the current state of the modal window used for wallet selection.
```APIDOC
get modalState(): WalletsModalState
Returns: WalletsModalState
Defined in: packages/ui/src/ton-connect-ui.ts:367
```
--------------------------------
### Get Connected Wallet
Source: https://github.com/ton-connect/sdk/blob/main/docs/classes/_tonconnect_ui.TonConnectUI.html
Returns the currently connected wallet application and its information, or null if no wallet is connected.
```APIDOC
get wallet(): null | Wallet | Object
Returns: null | Wallet | Object
Defined in: packages/ui/src/ton-connect-ui.ts:138
```
--------------------------------
### TON Connect SDK Modules Overview
Source: https://github.com/ton-connect/sdk/blob/main/docs/classes/_tonconnect_sdk.FetchWalletsError.html
This section lists the main modules within the TON Connect SDK, providing an overview of the project's structure and its sub-packages like protocol, SDK, and UI components.
```APIDOC
Modules:
- tonconnect
- @tonconnect/protocol
- @tonconnect/sdk
- @tonconnect/ui
- @tonconnect/ui-react
```
--------------------------------
### API Function: createConnectionStartedEvent
Source: https://github.com/ton-connect/sdk/blob/main/docs/functions/_tonconnect_sdk.createDataSignedEvent.html
Creates an event indicating that a new connection process has started within the TonConnect SDK.
```APIDOC
createConnectionStartedEvent
```
--------------------------------
### TonConnect SDK Modules Overview
Source: https://github.com/ton-connect/sdk/blob/main/docs/interfaces/_tonconnect_sdk.TonConnectOptions.html
Lists the core modules available within the TonConnect SDK, including protocol, SDK, UI, and UI-React components. This provides a high-level structural overview of the library's organization and its sub-packages.
```APIDOC
Modules:
- tonconnect
- @tonconnect/protocol
- @tonconnect/sdk
- @tonconnect/ui
- @tonconnect/ui-react
```
--------------------------------
### API Function: createConnectionRestoringStartedEvent
Source: https://github.com/ton-connect/sdk/blob/main/docs/functions/_tonconnect_sdk.createDataSignedEvent.html
Creates an event indicating that the connection restoring process has started within the TonConnect SDK.
```APIDOC
createConnectionRestoringStartedEvent
```
--------------------------------
### API Type: ConnectionStartedEvent
Source: https://github.com/ton-connect/sdk/blob/main/docs/functions/_tonconnect_sdk.createDataSignedEvent.html
Represents an event indicating that a new connection process has started within the TonConnect SDK.
```APIDOC
ConnectionStartedEvent
```
--------------------------------
### TON Connect SDK API Elements Overview
Source: https://github.com/ton-connect/sdk/blob/main/docs/functions/_tonconnect_sdk.createVersionInfo.html
This section lists all public types, interfaces, and functions exposed by the TON Connect SDK, categorized for easier navigation and understanding of the library's capabilities.
```APIDOC
TON Connect SDK API Reference:
Types & Interfaces:
- ConnectionRestoringStartedEvent
- ConnectionStartedEvent
- DataSentForSignatureEvent
- DataSignedEvent
- DataSigningEvent
- DataSigningFailedEvent
- DisconnectionEvent
- Feature
- FeatureName
- RemoveTonConnectPrefix
- RequestVersionEvent
- RequiredFeatures
- RequiredSendTransactionFeature
- RequiredSignDataFeature
- ResponseVersionEvent
- SdkActionEvent
- SendTransactionFeature
- SendTransactionFeatureDeprecated
- SignDataFeature
- SignDataPayload
- SignDataPayloadBinary
- SignDataPayloadCell
- SignDataPayloadText
- SignDataResponse
- SignDataType
- TonProofItemReply
- TonProofItemReplyError
- TransactionInfo
- TransactionMessage
- TransactionSentForSignatureEvent
- TransactionSignedEvent
- TransactionSigningEvent
- TransactionSigningFailedEvent
- Version
- VersionEvent
- WalletConnectionSource
- WalletInfo
- WithoutVersion
Functions:
- checkRequiredWalletFeatures
- createConnectionCompletedEvent
- createConnectionErrorEvent
- createConnectionRestoringCompletedEvent
- createConnectionRestoringErrorEvent
- createConnectionRestoringStartedEvent
- createConnectionStartedEvent
- createDataSentForSignatureEvent
- createDataSignedEvent
- createDataSigningFailedEvent
- createDisconnectionEvent
- createRequestVersionEvent
- createResponseVersionEvent
- createTransactionSentForSignatureEvent
- createTransactionSignedEvent
- createTransactionSigningFailedEvent
- createVersionInfo
- encodeTelegramUrlParameters
- isTelegramUrl
- isWalletInfoCurrentlyEmbedded
- isWalletInfoCurrentlyInjected
- isWalletInfoInjectable
- isWalletInfoInjected
- isWalletInfoRemote
```
--------------------------------
### API Type: ConnectionRestoringStartedEvent
Source: https://github.com/ton-connect/sdk/blob/main/docs/functions/_tonconnect_sdk.createDataSignedEvent.html
Represents an event indicating that the connection restoring process has started within the TonConnect SDK.
```APIDOC
ConnectionRestoringStartedEvent
```
--------------------------------
### TonConnect UI SDK API References and Modules
Source: https://github.com/ton-connect/sdk/blob/main/docs/modules/_tonconnect_ui.html
Provides an overview of key API references, including the default export, and a comprehensive list of modules, classes, interfaces, and enums available in the TonConnect UI SDK.
```APIDOC
References:
default: Renames and re-exports TonConnectUI
Modules:
tonconnect:
- @tonconnect/protocol
- @tonconnect/sdk
- @tonconnect/ui
- @tonconnect/ui-react
API Elements:
- default (Reference)
- THEME (Enum)
- TonConnectUI (Class)
- TonConnectUIError (Class)
- ActionConfiguration (Interface)
- TonConnectUiCreateOptionsBase (Interface)
- TonConnectUiOptions (Interface)
- TonConnectUiOptionsWithConnector (Interface)
- TonConnectUiOptionsWithManifest (Interface)
- UIPreferences (Interface)
- WalletsModal (Interface)
- BorderRadius (Type)
- Color (Type)
- ColorsSet (Type)
- ConnectedWallet (Type)
- Loadable (Type)
- LoadableLoading (Type)
- LoadableReady (Type)
- Locales (Type)
- PartialColorsSet (Type)
- ReturnStrategy (Type)
- Theme (Type)
- TonConnectUiCreateOptions (Type)
- UIWallet (Type)
- UserActionEvent (Type)
- WalletInfoRemoteWithOpenMethod (Type)
- WalletInfoWithOpenMethod (Type)
- WalletModalClosed (Type)
- WalletModalOpened (Type)
- WalletOpenMethod (Type)
- WalletsListConfiguration (Type)
- WalletsModalCloseReason (Type)
- WalletsModalState (Type)
```
--------------------------------
### TON Connect SDK Core API Elements
Source: https://github.com/ton-connect/sdk/blob/main/docs/variables/_tonconnect_protocol.Base64.html
An index of key types and functions provided by the TON Connect SDK, useful for understanding the available API surface. Each entry links to its respective detailed documentation.
```APIDOC
Types:
- WalletResponseError
- WalletResponseSuccess
- Base64
Functions:
- concatUint8Arrays
- hexToByteArray
- isNode
- splitToUint8Arrays
- toHexString
```
--------------------------------
### API Function: createConnectionStartedEvent
Source: https://github.com/ton-connect/sdk/blob/main/docs/functions/_tonconnect_sdk.createTransactionSignedEvent.html
Represents the createConnectionStartedEvent function within the TON Connect SDK API. This function creates a connection started event.
```APIDOC
createConnectionStartedEvent()
```
--------------------------------
### Create TonConnectUI Instance (ESM/TypeScript)
Source: https://github.com/ton-connect/sdk/blob/main/docs/modules/_tonconnect_ui.html
This TypeScript snippet illustrates how to create an instance of `TonConnectUI` using ES module imports. It configures the UI kit with a `manifestUrl` for application metadata and a `buttonRootId` to specify the DOM element where the connect button will be rendered, facilitating wallet integration.
```TypeScript
import { TonConnectUI } from '@tonconnect/ui'
const tonConnectUI = new TonConnectUI({
manifestUrl: 'https:///tonconnect-manifest.json',
buttonRootId: ''
});
```
--------------------------------
### Get Single Wallet Modal State (Experimental)
Source: https://github.com/ton-connect/sdk/blob/main/docs/classes/_tonconnect_ui.TonConnectUI.html
Returns the current state of the single wallet modal window. This is an experimental feature.
```APIDOC
get singleWalletModalState(): SingleWalletModalState
Returns: SingleWalletModalState
Defined in: packages/ui/src/ton-connect-ui.ts:401
```
--------------------------------
### TON Connect SDK Types and Functions API
Source: https://github.com/ton-connect/sdk/blob/main/docs/functions/_tonconnect_sdk.createConnectionStartedEvent.html
Comprehensive API documentation for the TON Connect SDK, listing all available types, interfaces, and utility functions for interacting with the TON blockchain.
```APIDOC
TON Connect SDK API Reference
Types and Interfaces:
ConnectionRestoringStartedEvent
ConnectionStartedEvent
DataSentForSignatureEvent
DataSignedEvent
DataSigningEvent
DataSigningFailedEvent
DisconnectionEvent
Feature
FeatureName
RemoveTonConnectPrefix
RequestVersionEvent
RequiredFeatures
RequiredSendTransactionFeature
RequiredSignDataFeature
ResponseVersionEvent
SdkActionEvent
SendTransactionFeature
SendTransactionFeatureDeprecated
SignDataFeature
SignDataPayload
SignDataPayloadBinary
SignDataPayloadCell
SignDataPayloadText
SignDataResponse
SignDataType
TonProofItemReply
TonProofItemReplyError
TransactionInfo
TransactionMessage
TransactionSentForSignatureEvent
TransactionSignedEvent
TransactionSigningEvent
TransactionSigningFailedEvent
Version
VersionEvent
WalletConnectionSource
WalletInfo
WithoutVersion
Functions:
checkRequiredWalletFeatures()
createConnectionCompletedEvent()
createConnectionErrorEvent()
createConnectionRestoringCompletedEvent()
createConnectionRestoringErrorEvent()
createConnectionRestoringStartedEvent()
createConnectionStartedEvent()
createDataSentForSignatureEvent()
createDataSignedEvent()
createDataSigningFailedEvent()
createDisconnectionEvent()
createRequestVersionEvent()
createResponseVersionEvent()
createTransactionSentForSignatureEvent()
createTransactionSignedEvent()
createTransactionSigningFailedEvent()
createVersionInfo()
encodeTelegramUrlParameters()
isTelegramUrl()
isWalletInfoCurrentlyEmbedded()
isWalletInfoCurrentlyInjected()
isWalletInfoInjectable()
isWalletInfoInjected()
isWalletInfoRemote()
```
--------------------------------
### API Property: Supported Platforms
Source: https://github.com/ton-connect/sdk/blob/main/docs/interfaces/_tonconnect_sdk.WalletInfoCurrentlyInjected.html
Specifies the operating systems and browsers where the wallet could be installed. This property is inherited from WalletInfoInjectable and is defined in packages/sdk/src/models/wallet/wallet-info.ts.
```APIDOC
platforms: (\"ios\" | \"android\" | \"macos\" | \"windows\" | \"linux\" | \"chrome\" | \"firefox\" | \"safari\")[]
```
--------------------------------
### API Function: createConnectionRestoringStartedEvent
Source: https://github.com/ton-connect/sdk/blob/main/docs/functions/_tonconnect_sdk.createTransactionSignedEvent.html
Represents the createConnectionRestoringStartedEvent function within the TON Connect SDK API. This function creates a connection restoring started event.
```APIDOC
createConnectionRestoringStartedEvent()
```
--------------------------------
### TonConnect SDK API Reference Overview
Source: https://github.com/ton-connect/sdk/blob/main/docs/functions/_tonconnect_sdk.createResponseVersionEvent.html
Lists the main modules, enums, classes, interfaces, and types available within the TonConnect SDK, providing a high-level overview of its public API surface.
```APIDOC
Modules:
- tonconnect
- @tonconnect/protocol
- @tonconnect/sdk
- @tonconnect/ui
- @tonconnect/ui-react
- default
Enums:
- CHAIN
- CONNECT_EVENT_ERROR_CODES
- CONNECT_ITEM_ERROR_CODES
- SEND_TRANSACTION_ERROR_CODES
- SIGN_DATA_ERROR_CODES
Classes:
- BadRequestError
- BrowserEventDispatcher
- FetchWalletsError
- LocalstorageNotFoundError
- ParseHexError
- TonConnect
- TonConnectError
- UnknownAppError
- UnknownError
- UserRejectsError
- WalletAlreadyConnectedError
- WalletMissingRequiredFeaturesError
- WalletNotConnectedError
- WalletNotInjectedError
- WalletNotSupportFeatureError
- WalletsListManager
- WrongAddressError
Interfaces:
- Account
- ConnectAdditionalRequest
- ConnectEventSuccess
- DappMetadata
- DeviceInfo
- EventDispatcher
- IStorage
- ITonConnect
- SendTransactionRequest
- SendTransactionResponse
- TonAddressItem
- TonAddressItemReply
- TonConnectOptions
- TonProofItem
- TonProofItemReplySuccess
- Wallet
- WalletConnectionSourceHTTP
- WalletConnectionSourceJS
- WalletInfoBase
- WalletInfoCurrentlyEmbedded
- WalletInfoCurrentlyInjected
- WalletInfoInjectable
- WalletInfoInjected
- WalletInfoRemote
Types:
- AddTonConnectPrefix
- AuthType
- ConnectItem
- ConnectItemReply
- ConnectItemReplyError
- ConnectionCompletedEvent
- ConnectionErrorEvent
- ConnectionEvent
- ConnectionInfo
- ConnectionRestoringCompletedEvent
- ConnectionRestoringErrorEvent
- ConnectionRestoringEvent
```
--------------------------------
### TonConnect Class API Reference
Source: https://github.com/ton-connect/sdk/blob/main/docs/classes/_tonconnect_sdk.TonConnect.html
Comprehensive API documentation for the `TonConnect` class, detailing its structure, implemented interfaces, constructor, accessors (account, connected, wallet), and a list of its methods for interacting with TON wallets.
```APIDOC
Class TonConnect
Hierarchy: TonConnect
Implements: ITonConnect
Defined in: packages/sdk/src/ton-connect.ts:64
Constructors:
new TonConnect(options?: TonConnectOptions): TonConnect
Parameters:
options: TonConnectOptions (Optional)
Returns: TonConnect
Defined in: packages/sdk/src/ton-connect.ts:138
Accessors:
account:
get account(): null | Account
Description: Current connected account or null if no account is connected.
Returns: null | Account
Implements: ITonConnect.account
Defined in: packages/sdk/src/ton-connect.ts:122
connected:
get connected(): boolean
Description: Shows if the wallet is connected right now.
Returns: boolean
Implements: ITonConnect.connected
Defined in: packages/sdk/src/ton-connect.ts:115
wallet:
get wallet(): null | Wallet
Description: Current connected wallet or null if no account is connected.
Returns: null | Wallet
Implements: ITonConnect.wallet
Defined in: packages/sdk/src/ton-connect.ts:129
set wallet(value: null | Wallet): void
Description: Current connected wallet or null if no account is connected.
Parameters:
value: null | Wallet
Returns: void
Implements: ITonConnect.wallet
Defined in: packages/sdk/src/ton-connect.ts:133
Methods:
connect()
disconnect()
getWallets()
onStatusChange()
pauseConnection()
restoreConnection()
sendTransaction()
signData()
unPauseConnection()
isInsideWalletBrowser()
isWalletInjected()
```
--------------------------------
### Static captureStackTrace Method API
Source: https://github.com/ton-connect/sdk/blob/main/docs/classes/_tonconnect_sdk.WalletNotConnectedError.html
Documents the static `captureStackTrace` method, which is used to create a `.stack` property on a target object. This method can be inherited, for example, from `TonConnectError`.
```APIDOC
captureStackTrace(targetObject: object, constructorOpt?: Function): void
Description: Create .stack property on a target object
Parameters:
targetObject: object
constructorOpt: Function (Optional)
Returns: void
Inherited from: TonConnectError.captureStackTrace
Defined in: node_modules/@types/node/ts4.8/globals.d.ts:4
```
--------------------------------
### TonConnectOptions Interface API Reference
Source: https://github.com/ton-connect/sdk/blob/main/docs/interfaces/_tonconnect_sdk.TonConnectOptions.html
Defines the configuration options for the TonConnect constructor, allowing customization of connection behavior, storage, event dispatching, and wallet list sources.
```APIDOC
Interface TonConnectOptions
Description: TonConnect constructor options
Hierarchy:
- TonConnectOptions
Properties:
- disableAutoPauseConnection?: boolean
Description: Allows to disable auto pause/unpause SSE connection on 'document.visibilitychange' event. It is not recommended to change default behaviour.
- eventDispatcher?: EventDispatcher
Description: Event dispatcher to track user actions. By default, it uses `window.dispatchEvent` for browser environment.
- manifestUrl?: string
Description: Url to the manifest with the Dapp metadata that will be displayed in the user's wallet. If not passed, manifest from ${window.location.origin}/tonconnect-manifest.json will be taken.
- storage?: IStorage
Description: Storage to save protocol data. For browser default is `localStorage`. If you use SDK with nodeJS, you have to specify this field.
- walletsListCacheTTLMs?: number
Description: Wallets list cache time to live. Default: Infinity
- walletsListSource?: string
Description: Redefine wallets list source URL. Must be a link to a json file with following structure. Default: https://raw.githubusercontent.com/ton-connect/wallets-list/main/wallets.json
- walletsRequiredFeatures?: RequiredFeatures
Description: Required features for wallets. If wallet doesn't support required features, it will be disabled.
```
--------------------------------
### API Reference: createConnectionStartedEvent()
Source: https://github.com/ton-connect/sdk/blob/main/docs/types/_tonconnect_sdk.TonProofItemReply.html
Documents the createConnectionStartedEvent function within the TON Connect SDK, used to generate an event for the start of a new connection.
```APIDOC
Function: createConnectionStartedEvent()
```
--------------------------------
### API Reference: createConnectionRestoringStartedEvent()
Source: https://github.com/ton-connect/sdk/blob/main/docs/types/_tonconnect_sdk.TonProofItemReply.html
Documents the createConnectionRestoringStartedEvent function within the TON Connect SDK, used to generate an event for the start of connection restoration.
```APIDOC
Function: createConnectionRestoringStartedEvent()
```
--------------------------------
### createConnectionRestoringStartedEvent Function Reference
Source: https://github.com/ton-connect/sdk/blob/main/docs/modules/_tonconnect_sdk.html
API reference for the createConnectionRestoringStartedEvent function in the TonConnect SDK, used to create an event object for the start of connection restoration.
```APIDOC
Function: createConnectionRestoringStartedEvent
```
--------------------------------
### TonConnectUI SDK API References
Source: https://github.com/ton-connect/sdk/blob/main/docs/modules/_tonconnect_ui.html
This section provides a structured overview of the key API elements within the TonConnectUI SDK, including enumerations, classes, and interfaces. It serves as a quick reference for developers to understand the available components and their relationships.
```APIDOC
References:
default: _tonconnect_ui.html#default
Enumerations:
THEME: ../enums/_tonconnect_ui.THEME.html
Classes:
TonConnectUI: ../classes/_tonconnect_ui.TonConnectUI.html
TonConnectUIError: ../classes/_tonconnect_ui.TonConnectUIError.html
Interfaces:
ActionConfiguration: ../interfaces/_tonconnect_ui.ActionConfiguration.html
TonConnectUiCreateOptionsBase: ../interfaces/_tonconnect_ui.TonConnectUiCreateOptionsBase.html
TonConnectUiOptions: ../interfaces/_tonconnect_ui.TonConnectUiOptions.html
TonConnectUiOptionsWithConnector: ../interfaces/_tonconnect_ui.TonConnectUiOptionsWithConnector.html
TonConnectUiOptionsWithManifest: ../interfaces/_tonconnect_ui.TonConnectUiOptionsWithManifest.html
UIPreferences: ../interfaces/_tonconnect_ui.UIPreferences.html
WalletsModal: ../interfaces/_tonconnect_ui.WalletsModal.html
```