### Install Demo App Dependencies Source: https://github.com/ton-connect/sdk/blob/main/DEVELOPERS.md Install all necessary project dependencies for the demo application and update the 'package-lock.json' file to reflect the current state of dependencies. ```shell npm install ``` -------------------------------- ### Install Project Dependencies with npm ci Source: https://github.com/ton-connect/sdk/blob/main/DEVELOPERS.md Installs all project dependencies using `npm ci`. This command ensures consistent dependency versions by relying on `package-lock.json` and prevents automatic updates, crucial for stable development. ```shell npm ci ``` -------------------------------- ### Install TonConnect SDK Source: https://github.com/ton-connect/sdk/blob/main/docs/modules/_tonconnect_sdk.html This command installs the TonConnect SDK package using npm, making it available for use in your project for both frontend and backend applications. ```bash npm i @tonconnect/sdk ``` -------------------------------- ### Publish Package Beta Version to npm Source: https://github.com/ton-connect/sdk/blob/main/DEVELOPERS.md Publishes a beta version of a package (e.g., `@tonconnect/ui`) to the npm registry. The `--access=public` flag makes it publicly available, and `--tag=beta` ensures it's published under the 'beta' tag, preventing accidental installation as a stable version. ```shell cd packages/ui && npm publish --access=public --tag=beta ``` -------------------------------- ### Install @tonconnect/ui-react with npm Source: https://github.com/ton-connect/sdk/blob/main/docs/modules/_tonconnect_ui_react.html Command to install the TonConnect UI React library using npm. ```Shell npm i @tonconnect/ui-react ``` -------------------------------- ### Install @tonconnect/protocol Package Source: https://github.com/ton-connect/sdk/blob/main/docs/modules/_tonconnect_protocol.html Command to install the @tonconnect/protocol package using npm, making its functionalities available for your project. ```bash npm i @tonconnect/protocol ``` -------------------------------- ### Build Demo Application Source: https://github.com/ton-connect/sdk/blob/main/DEVELOPERS.md Build the demo application to ensure it compiles correctly and is ready for testing and deployment. ```shell npm run build ``` -------------------------------- ### Installing Web Animations API Polyfill (npm) (Shell) Source: https://github.com/ton-connect/sdk/blob/main/packages/ui/README.md Provides the command to install the `web-animations-js` polyfill using npm, which is necessary to resolve animation issues in environments lacking native Web Animations API support. ```shell npm install web-animations-js ``` -------------------------------- ### Install Web Animations Polyfill via npm Source: https://github.com/ton-connect/sdk/blob/main/docs/modules/_tonconnect_ui.html This command installs the `web-animations-js` polyfill using npm. This polyfill provides a fallback implementation of the Web Animations API, resolving animation issues in environments that lack native support. ```Shell npm install web-animations-js ``` -------------------------------- ### Install TON Connect SDK via npm Source: https://github.com/ton-connect/sdk/blob/main/docs/modules/_tonconnect_sdk.html Installs the TonConnect SDK package using npm, a package manager for JavaScript. ```Shell npm i @tonconnect/sdk ``` -------------------------------- ### Install @tonconnect/isomorphic-eventsource package Source: https://github.com/ton-connect/sdk/blob/main/packages/isomorphic-eventsource/README.md This command installs the `@tonconnect/isomorphic-eventsource` package using npm, making it available for use in your project. It's the first step to integrate the isomorphic EventSource functionality. ```Shell npm i @tonconnect/isomorphic-eventsource ``` -------------------------------- ### Clone Demo DApp Repository Source: https://github.com/ton-connect/sdk/blob/main/DEVELOPERS.md Clone the 'demo-dapp-with-wallet' repository from GitHub and navigate into its directory to begin updating the demo application. ```shell git clone git@github.com:ton-connect/demo-dapp-with-wallet.git && cd demo-dapp-with-wallet ``` -------------------------------- ### Install and Import Web Animations API Polyfill Source: https://github.com/ton-connect/sdk/blob/main/docs/modules/_tonconnect_ui_react.html Addresses issues with animations not working due to lack of Web Animations API support by demonstrating how to install the `web-animations-js` polyfill via npm and import it into a project. ```Shell npm install web-animations-js ``` ```TypeScript import 'web-animations-js'; ``` -------------------------------- ### Clone Ton Connect SDK Repository Source: https://github.com/ton-connect/sdk/blob/main/DEVELOPERS.md Clones the Ton Connect SDK repository from GitHub and navigates into the project's root directory, which is the first step for setting up the development environment. ```shell git clone git@github.com:ton-connect/sdk.git && cd sdk ``` -------------------------------- ### TonConnect SDK: NodeJS Installation Source: https://github.com/ton-connect/sdk/blob/main/packages/sdk/README.md This command provides the standard way to install the TonConnect SDK package using npm. It ensures the SDK is available for use in NodeJS applications, enabling backend functionalities. ```bash npm i @tonconnect/sdk ``` -------------------------------- ### Install web-animations-js Polyfill via npm (Shell) Source: https://github.com/ton-connect/sdk/blob/main/packages/ui-react/README.md Provides the command to install the `web-animations-js` polyfill using npm, which resolves animation issues due to lack of Web Animations API support. ```shell npm install web-animations-js ``` -------------------------------- ### Install TON Connect Protocol Package Source: https://github.com/ton-connect/sdk/blob/main/packages/protocol/README.md This command installs the `@tonconnect/protocol` package using npm, making its models and utilities available for use in your project. It's the first step to integrate the protocol into your application. ```bash npm i @tonconnect/protocol ``` -------------------------------- ### Build All Packages with Nx Source: https://github.com/ton-connect/sdk/blob/main/DEVELOPERS.md Builds all packages in the monorepo using Nx. The `--parallel=1` flag ensures sequential building to avoid errors caused by inter-package dependencies. ```shell nx run-many --target=build --all --parallel=1 ``` -------------------------------- ### Build All Packages Before Publishing Source: https://github.com/ton-connect/sdk/blob/main/DEVELOPERS.md Builds all packages in the monorepo using Nx after version updates and before publishing. The `--parallel=1` flag ensures sequential building to avoid errors caused by inter-package dependencies. ```shell nx run-many --target=build --all --parallel=1 ``` -------------------------------- ### Commit and Push Demo App Updates Source: https://github.com/ton-connect/sdk/blob/main/DEVELOPERS.md Commit all changes in the demo application repository and push them to the remote to update GitHub Pages with the latest version. ```shell git add . && git commit -m "chore: update @tonconnect/ui-react to CURRENT_VERSION" && git push origin HEAD ``` -------------------------------- ### Install TonConnect UI via npm Source: https://github.com/ton-connect/sdk/blob/main/docs/modules/_tonconnect_ui.html This command-line snippet shows how to install the `@tonconnect/ui` package using npm, the Node.js package manager. It adds the UI kit to your project's dependencies, making it available for import and use in a modular development environment. ```Shell npm i @tonconnect/ui ``` -------------------------------- ### Install TON Connect SDK via npm Source: https://github.com/ton-connect/sdk/blob/main/packages/sdk/README.md Install the TON Connect SDK into your project using the npm package manager. This is the standard way to include the SDK in modern JavaScript/TypeScript projects. ```shell npm i @tonconnect/sdk ``` -------------------------------- ### Install TonConnect UI React with npm Source: https://github.com/ton-connect/sdk/blob/main/packages/ui-react/README.md This command installs the `@tonconnect/ui-react` package using npm, making it available for use in your React project. ```npm npm i @tonconnect/ui-react ``` -------------------------------- ### Install TON Connect SDK via CDN (latest version) Source: https://github.com/ton-connect/sdk/blob/main/docs/modules/_tonconnect_sdk.html Adds the SDK to an HTML file using a CDN link, automatically updating to the latest version. ```HTML ``` -------------------------------- ### Install Web Animations API Polyfill (npm) Source: https://github.com/ton-connect/sdk/blob/main/packages/ui/README.md Install the `web-animations-js` polyfill via npm to resolve animation issues caused by lack of Web Animations API support. This ensures smooth animations in environments where the API is not natively available. ```shell npm install web-animations-js ``` -------------------------------- ### Link Ton Connect Packages in Demo DApp Source: https://github.com/ton-connect/sdk/blob/main/DEVELOPERS.md Links the locally developed `@tonconnect` packages (`ui-react`, `ui`, `sdk`, `protocol`) into a demo decentralized application (dApp) directory. This allows the dApp to use the local, unreleased versions of the packages for testing. ```shell npm link @tonconnect/ui-react @tonconnect/ui @tonconnect/sdk @tonconnect/protocol ``` -------------------------------- ### Link Ton Connect UI Packages Locally Source: https://github.com/ton-connect/sdk/blob/main/DEVELOPERS.md Navigates into specific `@tonconnect` package directories (`ui-react`, `ui`, `protocol`, `sdk`) and runs `npm link` to create symlinks. This makes the local package versions available for linking into other projects, like demo dApps. ```shell cd packages/ui-react && npm link cd ../ui && npm link cd ../protocol && npm link cd ../sdk && npm link ``` -------------------------------- ### Commit and push demo app changes Source: https://github.com/ton-connect/sdk/blob/main/DEVELOPERS.md Stage all changes in the demo application directory, create a chore commit indicating the `@tonconnect/ui-react` version update, and push the changes to the remote repository. ```shell git add . && git commit -m "chore: update @tonconnect/ui-react to CURRENT_VERSION" && git push origin HEAD ``` -------------------------------- ### Push Git Changes and Tags Source: https://github.com/ton-connect/sdk/blob/main/DEVELOPERS.md After publishing a package version, push the local commit and tags to the remote Git repository to reflect the changes. ```shell git push origin HEAD git push origin --tags ``` -------------------------------- ### Install TON Connect SDK via CDN (specific version) Source: https://github.com/ton-connect/sdk/blob/main/docs/modules/_tonconnect_sdk.html Adds the SDK to an HTML file using a CDN link, specifying a concrete version to prevent auto-updates. ```HTML ``` -------------------------------- ### Install TonConnect UI via CDN (Latest Version) Source: https://github.com/ton-connect/sdk/blob/main/docs/modules/_tonconnect_ui.html This HTML snippet demonstrates how to include the TonConnect UI library in a web page using a Content Delivery Network (CDN). It fetches the latest version of the `tonconnect-ui.min.js` script, making the library globally available for use in the application. ```HTML ``` -------------------------------- ### Installing 'encoding' Package to Suppress Next.js Warning (Shell) Source: https://github.com/ton-connect/sdk/blob/main/packages/ui/README.md Provides the command to install the `encoding` package using npm as an optional step to resolve a specific 'Module not found' warning related to `node-fetch` that may appear in Next.js environments. ```shell npm install encoding ``` -------------------------------- ### Build @tonconnect/ui-react in Watch Mode with Nx Source: https://github.com/ton-connect/sdk/blob/main/DEVELOPERS.md Builds the `@tonconnect/ui-react` package in watch mode using Nx, allowing for continuous compilation during development. The `--parallel=1` flag ensures sequential building to prevent dependency-related errors. ```shell nx affected:build --parallel=1 --watch ``` -------------------------------- ### Install TonConnect UI via npm Source: https://github.com/ton-connect/sdk/blob/main/packages/ui/README.md Installs the TonConnect UI library using npm, the Node.js package manager. This is the recommended method for modern JavaScript/TypeScript projects, allowing for better dependency management. ```Shell npm i @tonconnect/ui ``` -------------------------------- ### Update Package Version to Beta Source: https://github.com/ton-connect/sdk/blob/main/DEVELOPERS.md Updates the version of a specific package (e.g., `@tonconnect/ui`) to a beta prerelease using Nx's version command. This command is used for preparing beta versions before full releases. ```shell nx run ui:version --releaseAs=prerelease --preid=beta ``` -------------------------------- ### Importing Web Animations API Polyfill (TypeScript) Source: https://github.com/ton-connect/sdk/blob/main/packages/ui/README.md Shows how to import the installed `web-animations-js` polyfill into a TypeScript project to provide fallback support for the Web Animations API. ```typescript import 'web-animations-js'; ``` -------------------------------- ### Update Package Dependency Version in package.json Source: https://github.com/ton-connect/sdk/blob/main/DEVELOPERS.md Modify the 'dependencies' section of a 'package.json' file to update the version of a dependent package, for example, '@tonconnect/ui' in '@tonconnect/ui-react'. ```json { "dependencies": { "@tonconnect/ui": "CURRENT_VERSION" } } ``` -------------------------------- ### Install TON Connect SDK via CDN Source: https://github.com/ton-connect/sdk/blob/main/packages/sdk/README.md Add the TON Connect SDK to an HTML file using a CDN link. This method allows direct inclusion of the library in web pages. It's recommended to pin a specific version for production to avoid auto-updates. ```html ``` ```html ``` -------------------------------- ### Install 'encoding' package to suppress Next.js warning Source: https://github.com/ton-connect/sdk/blob/main/docs/modules/_tonconnect_ui.html This command installs the `encoding` package using npm. While not strictly necessary for functionality, installing this package can suppress a 'Module not found' warning related to `node-fetch` in Next.js environments, providing a cleaner build output. ```Shell npm install encoding ``` -------------------------------- ### Patch @tonconnect/ui package.json Build Script Source: https://github.com/ton-connect/sdk/blob/main/DEVELOPERS.md Modifies the `build` script in `packages/ui/package.json` to ensure watch mode functions correctly during development. This is a temporary workaround and must be reverted before releasing new versions. ```json { "scripts": { "build": "tsc --noEmit --emitDeclarationOnly false && vite build" } } ``` -------------------------------- ### Full Flow: Fetch and Set Ton Connect Request Parameters (TypeScript) Source: https://github.com/ton-connect/sdk/blob/main/packages/ui/README.md Provides a comprehensive example demonstrating the typical workflow for setting connect request parameters: enabling a loader, asynchronously fetching the tonProofPayload, and then setting the parameters to 'ready' if successful or clearing them if fetching fails. ```TypeScript // enable ui loader tonConnectUI.setConnectRequestParameters({ state: 'loading' }); // fetch you tonProofPayload from the backend const tonProofPayload: string | null = await fetchTonProofPayloadFromBackend(); if (!tonProofPayload) { // remove loader, connect request will be without any additional parameters tonConnectUI.setConnectRequestParameters(null); } else { // add tonProof to the connect request tonConnectUI.setConnectRequestParameters({ state: "ready", value: { tonProof: tonProofPayload } }); } ``` -------------------------------- ### Create Connection Started Event Function Source: https://github.com/ton-connect/sdk/blob/main/docs/types/_tonconnect_sdk.SignDataPayloadText.html A utility function to create a 'connection started' event object in the TonConnect SDK. ```APIDOC function createConnectionStartedEvent() ``` -------------------------------- ### Install TonConnect UI via CDN (latest version) Source: https://github.com/ton-connect/sdk/blob/main/packages/ui/README.md Adds the TonConnect UI library to an HTML file using a CDN, automatically updating to the latest version. This is suitable for quick integration in web projects. ```HTML ``` -------------------------------- ### Install TonConnect UI via CDN (Specific Version) Source: https://github.com/ton-connect/sdk/blob/main/docs/modules/_tonconnect_ui.html This HTML snippet shows how to include a specific version of the TonConnect UI library from a CDN. By specifying a version number like `0.0.9` instead of `latest`, developers can ensure consistent behavior and avoid unexpected changes from automatic updates. ```HTML ``` -------------------------------- ### Fetch supported wallets list using static method Source: https://github.com/ton-connect/sdk/blob/main/docs/modules/_tonconnect_sdk.html Retrieves a list of supported wallets using a static method of the `TonConnect` class, providing an alternative way to get the list without an initialized connector instance. ```TypeScript const walletsList = await TonConnect.getWallets(); ``` -------------------------------- ### Create Connection Restoring Started Event Function Source: https://github.com/ton-connect/sdk/blob/main/docs/types/_tonconnect_sdk.SignDataPayloadText.html A utility function to create a 'connection restoring started' event object in the TonConnect SDK. ```APIDOC function createConnectionRestoringStartedEvent() ``` -------------------------------- ### Publish Package New Release Version to npm Source: https://github.com/ton-connect/sdk/blob/main/DEVELOPERS.md Publishes a new stable release version of a package (e.g., `@tonconnect/ui`) to the npm registry. The `--access=public` flag makes it publicly available under the 'latest' tag by default. ```shell cd packages/ui && npm publish --access=public ``` -------------------------------- ### Install TonConnect UI via CDN (specific version) Source: https://github.com/ton-connect/sdk/blob/main/packages/ui/README.md Adds the TonConnect UI library to an HTML file using a CDN, specifying a concrete version to prevent auto-updates. This ensures stability and predictability in production environments. ```HTML ``` -------------------------------- ### Import Web Animations API Polyfill (TypeScript) Source: https://github.com/ton-connect/sdk/blob/main/packages/ui/README.md Import the `web-animations-js` polyfill into your TypeScript project after installation. This step activates the polyfill, providing fallback implementation for the Web Animations API. ```typescript import 'web-animations-js'; ``` -------------------------------- ### Install 'encoding' package to suppress Next.js warning Source: https://github.com/ton-connect/sdk/blob/main/packages/ui-react/README.md This command installs the 'encoding' package, which resolves a 'Module not found' warning related to 'node-fetch' in Next.js applications. This is an optional step to suppress the warning. ```shell npm install encoding ``` -------------------------------- ### Send Transaction with TonConnectUI Source: https://github.com/ton-connect/sdk/blob/main/docs/modules/_tonconnect_ui.html Demonstrates how to construct and send a transaction using `tonConnectUI.sendTransaction`. The wallet must be connected before calling this method. Includes examples for basic transactions and transactions with extra currencies, along with error handling. ```JavaScript const transaction = { validUntil: Math.floor(Date.now() / 1000) + 60, // 60 sec messages: [ { address: "EQBBJBB3HagsujBqVfqeDUPJ0kXjgTPLWPFFffuNXNiJL0aA", amount: "20000000", // stateInit: "base64bocblahblahblah==" // just for instance. Replace with your transaction initState or remove }, { address: "EQDmnxDMhId6v1Ofg_h5KR5coWlFG6e86Ro3pc7Tq4CA0-Jn", amount: "60000000", // payload: "base64bocblahblahblah==" // just for instance. Replace with your transaction payload or remove } ]}; // you can also include extra currencies in your transaction const transactionWithExtraCurrency = { validUntil: Math.floor(Date.now() / 1000) + 60, messages: [ { address: "EQBBJBB3HagsujBqVfqeDUPJ0kXjgTPLWPFFffuNXNiJL0aA", // Specify the extra currency extraCurrency: { 100: "10000000" } } ] }; try { const result = await tonConnectUI.sendTransaction(transaction); // you can use signed boc to find the transaction const someTxData = await myAppExplorerService.getTransaction(result.boc); alert('Transaction was sent successfully', someTxData); } catch (e) { console.error(e); } ``` -------------------------------- ### TonConnect Project Documentation Modules and Settings Source: https://github.com/ton-connect/sdk/blob/main/docs/modules.html This section outlines the main modules within the TonConnect project documentation, including @tonconnect/protocol, @tonconnect/sdk, @tonconnect/ui, and @tonconnect/ui-react. It also details documentation settings such as member visibility (Inherited, External) and available themes (OS, Light, Dark). ```APIDOC TonConnect Documentation Index: Modules: - @tonconnect/protocol - @tonconnect/sdk - @tonconnect/ui - @tonconnect/ui-react Settings: Member Visibility: - Inherited - External Theme: - OS - Light - Dark ``` -------------------------------- ### Include Web Animations Polyfill via CDN Source: https://github.com/ton-connect/sdk/blob/main/docs/modules/_tonconnect_ui.html This HTML script tag demonstrates how to include the `web-animations-js` polyfill directly from a CDN. This method provides an alternative to npm installation for resolving animation issues by adding the polyfill globally to the web page. ```HTML ``` -------------------------------- ### Initialize TonConnectUI instance with CDN Source: https://github.com/ton-connect/sdk/blob/main/packages/ui/README.md Initializes the TonConnectUI instance using the global `TON_CONNECT_UI` variable after loading the library via CDN. This setup requires a manifest URL for your application and a designated HTML element ID for the connect button anchor. ```HTML ``` -------------------------------- ### TON Connect SDK Modules Overview Source: https://github.com/ton-connect/sdk/blob/main/docs/interfaces/_tonconnect_ui.TonConnectUiOptionsWithManifest.html Lists the core modules and their sub-modules within the TON Connect SDK, providing an overview of the library's structure and dependencies. ```APIDOC Modules: - tonconnect - @tonconnect/protocol - @tonconnect/sdk - @tonconnect/ui - @tonconnect/ui-react ``` -------------------------------- ### Update Package Version for New Release Source: https://github.com/ton-connect/sdk/blob/main/DEVELOPERS.md Updates the version of a specific package (e.g., `@tonconnect/ui`) for a new release using Nx's version command, typically for patch releases. This command is used for preparing stable release versions. ```shell nx run ui:version --releaseAs=patch ``` -------------------------------- ### Initialize TonConnectUI Instance with CDN Source: https://github.com/ton-connect/sdk/blob/main/docs/modules/_tonconnect_ui.html This JavaScript code demonstrates how to initialize the `TonConnectUI` instance when the library is loaded via CDN. It requires a `manifestUrl` pointing to the application's manifest and a `buttonRootId` to specify where the connect button should be rendered, enabling wallet connection functionality. ```JavaScript const tonConnectUI = new TON_CONNECT_UI.TonConnectUI({ manifestUrl: 'https:///tonconnect-manifest.json', buttonRootId: '' }); ``` -------------------------------- ### Create TonConnectUI instance Source: https://github.com/ton-connect/sdk/blob/main/packages/ui/README.md Imports and initializes a new TonConnectUI instance with a manifest URL and a button root ID. This is the standard way to set up the UI kit in a TypeScript or JavaScript project, enabling interaction with TON wallets. ```TypeScript import { TonConnectUI } from '@tonconnect/ui' const tonConnectUI = new TonConnectUI({ manifestUrl: 'https:///tonconnect-manifest.json', buttonRootId: '' }); ``` -------------------------------- ### Resolve 'encoding' Module Warning in Next.js Source: https://github.com/ton-connect/sdk/blob/main/docs/modules/_tonconnect_sdk.html This command installs the `encoding` package to suppress a 'Module not found' warning that may appear in Next.js applications using the TonConnect SDK. While typically not affecting functionality, installing this package can resolve the warning. ```bash npm install encoding ``` -------------------------------- ### TonConnectUI API Reference Source: https://github.com/ton-connect/sdk/blob/main/docs/modules/_tonconnect_ui.html Comprehensive API documentation for the TonConnectUI object, detailing its methods, properties, and their usage for managing wallet connections and modal interactions. ```APIDOC TonConnectUI: getWallets(): Promise Description: Retrieves a list of available wallets. Returns: An array of WalletInfo objects. WalletInfo: name: string imageUrl: string tondns?: string aboutUrl: string universalLink?: string deepLink?: string bridgeUrl?: string jsBridgeKey?: string injected?: boolean (true if wallet is injected to webpage) embedded?: boolean (true if dapp is opened inside wallet's browser) openModal(): Promise Description: Opens the connect modal window programmatically. Returns: A promise that resolves when the modal is opened. Throws: TonConnectUIError | TonConnectError on error. closeModal(): void Description: Closes the connect modal window. modalState: WalletsModalState Description: Getter for the current state of the connect modal window. WalletsModalState: status: 'opened' | 'closed' closeReason?: string onModalStateChange(callback: (state: WalletsModalState) => void): () => void Description: Subscribes to changes in the connect modal window state. Parameters: callback: Function to be called with the new modal state. Returns: An unsubscribe function. modal: ModalControlObject Description: Direct access to the modal window's state and behavior. Use tonConnectUI methods for a more straightforward experience. ModalControlObject: open(): Promise close(): void state: WalletsModalState onStateChange(callback: (state: WalletsModalState) => void): () => void openSingleWalletModal(appName: string): Promise (Experimental) Description: Opens a modal window for a specific wallet. Parameters: appName: The identifier of the wallet application. Returns: A promise that resolves when the modal is opened. closeSingleWalletModal(): void (Experimental) Description: Closes the currently open specific wallet modal. onSingleWalletModalStateChange(callback: (state: WalletsModalState) => void): () => void (Experimental) Description: Subscribes to state changes of the specific wallet modal. Parameters: callback: Function to be called with the new modal state. Returns: An unsubscribe function. singleWalletModalState: WalletsModalState (Experimental) Description: Getter for the current state of the specific wallet modal window. ``` -------------------------------- ### Create Unified Connection Link for Multiple Wallets (TypeScript) Source: https://github.com/ton-connect/sdk/blob/main/packages/sdk/README.md This example illustrates how to generate a unified connection link that can be accepted by various wallets. It involves passing an array of http-wallet-connection-sources to connector.connect(). If multiple wallets share the same bridge URL, it can be listed only once in the array. ```ts const sources = [ { bridgeUrl: 'https://bridge.tonapi.io/bridge' // Tonkeeper }, { bridgeUrl: 'https://' // 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 ```