Skip to main content
TonhubConnector allows you to connect to a wallet app from a web browser, bot or backend.

Creating a connector

Before connecting to an app you need to create a connector:

Starting a new session

Before requesting a connection to a wallet you need to create session and persist it’s data somewhere in your app.

You can generate session anywhere

It could be web app, bot, console app. ton-x doesn’t depend on specific environment.

Do not forget to persist session

At this step you need to persist and reuse this session values even in the case of app restart until session was revoked (see later)
After session was created and persisted you can present user a link to connect to your app. On desktop you need to show a QR Code and on mobile you need to show it as a normal link that user will need to press.

Do not try to navigate your user automatically

This is almost never works on mobile

Await session confirmation

After presenting a link the user you can await session confirmation or rejection.

Revoked session couldn’t be restarted

If user rejected connection or backend revoked a token you can’t use it again and have to create a new one.

Requesting Transaction

To request a transaction you can call requestTransaction in connector after successful session.

Requesting Signature

To request a transaction you can call requestTransaction in connector after successful session.

Check session state

If you need to check from time to time that your session is a valid you can call getSessionState method. While it is possible to track session state we are NOT recommending to do so since you can always re-authenticate user if transaction or signature request requested and session became expired.