Skip to main content

Connection

Before receiving and handling wallet events, set up an events handler and establish a connection with a dApp.

Setting up events handler

Create your own implementation of an events handler and add it to the WalletKit instance:
If a handler is not needed anymore or needs to be replaced by some other handler, remove it:

Establishing connection with dApp

To establish a connection with a dApp, one needs a connection request URL from any source: copy/paste, QR code, deep link, etc. Send it to the WalletKit to initiate a connection request.
Once the connection request is fired, the corresponding event will be sent to your event handler. The connection event contains an object you can use to display request information to your app’s users and to approve (or reject) the request to complete connection establishment.
After approval, the connection will be established, and the wallet service will be able to receive and handle other events associated with the corresponding TON wallet.

Handling events

All event handling is made through a custom event handler. Received events carry a lot of useful information that can be displayed to the user to allow them to approve or reject the request based on their action. The only exception is a disconnection request. Even though it contains information you can show to a user, there is no need to approve or reject it on their end.

Transaction event handling

Sign data event handling

Disconnection event handling

Alternatively, explore the complete demo wallet with WalletKit integration:

Demo wallet, GitHub