To connect your wallet to TP Wallet, you can use the following code example:
// Check if a wallet is already connected const isConnected = await tp.wallet.isConnected(); // Connect the wallet if (!isConnected) { try { await tp.wallet.connect(); console.log("Wallet connected successfully!"); } catch (error) { console.error("Failed to connect wallet:", error); } } else { console.log("Wallet is already connected!"); }
This code snippet checks if a wallet is already connected to TP Wallet. If it is not connected, it attempts to connect the wallet using the tp.wallet.connect()
function. If the connection is successful, the message "Wallet connected successfully!" will be logged in the console. If there is an error during the connection process, the error message will be logged in the console.
It is important to note that the TP Wallet connection code is using the TP Wallet SDK (Software Development Kit) provided by TP Wallet. Make sure to include the necessary scripts and dependencies in your HTML file.
By using this code example, you can easily enable wallet connectivity for your users, allowing them to interact with TP Wallet seamlessly.