### Fetch Supported Wallets List with TonConnect Source: https://github.com/romanovichim/darttonconnect/blob/main/README.md Example of initializing the TonConnect connector and asynchronously fetching a list of all supported wallets. The `connector.getWallets()` method retrieves available wallet applications, which can then be displayed to the user. ```Dart import 'package:darttonconnect/ton_connect.dart'; Future main() async { final connector = TonConnect('https://raw.githubusercontent.com/XaBbl4/pytonconnect/main/pytonconnect-manifest.json'); final List wallets = await connector.getWallets(); print('Wallets: $wallets'); } ``` -------------------------------- ### Declare Darttonconnect Dependency in pubspec.yaml Source: https://github.com/romanovichim/darttonconnect/blob/main/README.md Shows how the `darttonconnect` dependency is declared in the `pubspec.yaml` file after installation. This entry specifies the package name and its version constraint. ```YAML dependencies: darttonconnect: ^1.0.1 ``` -------------------------------- ### Install Darttonconnect Package Source: https://github.com/romanovichim/darttonconnect/blob/main/README.md Command to add the darttonconnect package to a Dart project using `pub add`. This automatically updates the `pubspec.yaml` file and fetches dependencies. ```Dart $ dart pub add darttonconnect ``` -------------------------------- ### Initialize Wallet Connection with Dart TonConnect Source: https://github.com/romanovichim/darttonconnect/blob/main/README.md Demonstrates how to initiate a wallet connection using a universal link with the `darttonconnect` library. The generated URL should be presented to the user as a QR code or deep link for approval, and the console will update upon user approval. ```Dart import 'package:darttonconnect/ton_connect.dart'; final generatedUrl = await connector.connect(wallets.first); print('Generated url: $generatedUrl'); } ``` -------------------------------- ### Import Darttonconnect Modules Source: https://github.com/romanovichim/darttonconnect/blob/main/README.md Essential import statements for various modules within the darttonconnect SDK. These imports provide access to core functionalities like crypto, exceptions, parsers, providers, storage, and the main TonConnect class. ```Dart import 'package:darttonconnect/crypto/session_crypto.dart'; import 'package:darttonconnect/exceptions.dart'; import 'package:darttonconnect/logger.dart'; import 'package:darttonconnect/parsers/connect_event.dart'; import 'package:darttonconnect/parsers/rpc_parser.dart'; import 'package:darttonconnect/parsers/send_transaction.dart'; import 'package:darttonconnect/provider/bridge_gateway.dart'; import 'package:darttonconnect/provider/bridge_provider.dart'; import 'package:darttonconnect/provider/bridge_session.dart'; import 'package:darttonconnect/provider/provider.dart'; import 'package:darttonconnect/storage/default_storage.dart'; import 'package:darttonconnect/storage/interface.dart'; import 'package:darttonconnect/ton_connect.dart'; import 'package:darttonconnect/wallets_list_manager.dart'; ``` -------------------------------- ### Send Toncoin Transaction with Dart TonConnect Source: https://github.com/romanovichim/darttonconnect/blob/main/README.md Illustrates how to construct and send a transaction using the `darttonconnect` library. It includes a basic transaction object structure with `validUntil` and `messages` fields, and provides error handling for user rejections or other unexpected issues during the transaction process. ```Dart const transaction = { "validUntil": 1718097354, "messages": [ { "address": "0:575af9fc97311a11f423a1926e7fa17a93565babfd65fe39d2e58b8ccb38c911", "amount": "20000000" } ] }; try { await connector.sendTransaction(transaction); } catch (e) { if (e is UserRejectsError) { logger.d( 'You rejected the transaction. Please confirm it to send to the blockchain'); } else { logger.d('Unknown error happened $e'); } } ``` -------------------------------- ### Define TonConnect Manifest JSON Source: https://github.com/romanovichim/darttonconnect/blob/main/README.md JSON structure for the `tonconnect-manifest.json` file, which is required for the app to pass meta information to the wallet. It includes essential fields like `url`, `name`, and `iconUrl`, along with optional fields for terms of use and privacy policy URLs. ```JSON { "url": "", // required "name": "", // required "iconUrl": "", // required "termsOfUseUrl": "", // optional "privacyPolicyUrl": "" // optional } ``` -------------------------------- ### Subscribe to TonConnect Status Changes Source: https://github.com/romanovichim/darttonconnect/blob/main/README.md Shows how to subscribe to connection status changes using `connector.onStatusChange()`. This allows the application to react to updates in the wallet connection state, such as a wallet connecting or disconnecting, and update the UI accordingly. ```Dart /// Update state/reactive variables to show updates in the ui. void statusChanged(dynamic walletInfo) { print('Wallet info: $ walletInfo'); } connector.onStatusChange(statusChanged); ``` -------------------------------- ### Disconnect from Wallet with Dart TonConnect Source: https://github.com/romanovichim/darttonconnect/blob/main/README.md Shows how to disconnect an active wallet session using the `disconnect` method provided by the `darttonconnect` library, effectively ending the connection. ```Dart connector.disconnect(); ``` -------------------------------- ### Restore TonConnect Connection in Flutter Source: https://github.com/romanovichim/darttonconnect/blob/main/README.md Demonstrates how to restore a previously established TonConnect connection when the application or page reloads. This is typically done by calling `connector.restoreConnection()` within a Flutter widget's `initState` or a similar lifecycle method, ensuring a seamless user experience. ```Dart import 'package:darttonconnect/ton_connect.dart'; @override void initState() { // Override default initState method to call restoreConnection // method after screen reloading. super.initState(); WidgetsBinding.instance.addPostFrameCallback((_) { if (!connector.connected) { restoreConnection(); } }); } /// Restore connection from memory. void restoreConnection() { connector.restoreConnection(); } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.