Documentation
    Preparing search index...

    Class TonConnectUI

    Index

    Constructors

    Properties

    connectionRestored: Promise<boolean> = ...

    Promise that resolves after end of th connection restoring process (promise will fire after onStatusChange, so you can get actual information about wallet and session after when promise resolved). Resolved value true/false indicates if the session was restored successfully.

    connector: ITonConnect

    TonConnect instance.

    Manages the modal window state.

    Accessors

    • get account(): null | Account

      Current connected account or null.

      Returns null | Account

    • get connected(): boolean

      Current connection status.

      Returns boolean

    • get singleWalletModalState(): SingleWalletModalState
      Experimental

      Returns current single wallet modal window state.

      Returns SingleWalletModalState

    • set uiOptions(options: TonConnectUiOptions): void

      Set and apply new UI options. Object with partial options should be passed. Passed options will be merged with current options.

      Parameters

      Returns void

    • get wallet(): null | Wallet | (Wallet & WalletInfoWithOpenMethod)

      Curren connected wallet app and its info or null.

      Returns null | Wallet | (Wallet & WalletInfoWithOpenMethod)

    Methods

    • Experimental

      Close the single wallet modal window.

      Parameters

      Returns void

    • Parameters

      • Optionaloptions: { traceId?: string }

      Returns Promise<ConnectedWallet>

      Connected wallet.

      Use tonConnectUI.openModal() instead. Will be removed in the next major version. Opens the modal window and handles a wallet connection.

      TonConnectUIError if connection was aborted.

    • Disconnect wallet and clean localstorage.

      Parameters

      • Optionaloptions: { traceId?: string }

      Returns Promise<void>

    • Returns available wallets list.

      Returns Promise<WalletInfo[]>

    • Subscribe to the modal window state changes, returns a function which has to be called to unsubscribe.

      Parameters

      Returns () => void

    • Experimental

      Subscribe to the single wallet modal window state changes, returns a function which has to be called to unsubscribe.

      Parameters

      • onChange: (state: SingleWalletModalState) => void

      Returns () => void

    • Subscribe to connection status change.

      Parameters

      Returns () => void

      function which has to be called to unsubscribe.

    • Opens the modal window, returns a promise that resolves after the modal window is opened.

      Parameters

      • Optionaloptions: { traceId?: string }

      Returns Promise<void>

    • Experimental

      Opens the single wallet modal window, returns a promise that resolves after the modal window is opened.

      Parameters

      • wallet: string

      Returns Promise<void>

    • Opens the modal window and handles the transaction sending.

      Pass options.enableEmbeddedRequest: true to allow the request to ride along with the connect URL on mobile, eliminating a round-trip. With that flag, the result is always the embedded shape:

      • { hasResponse: true, response } — the transaction was signed, either folded into connect by an embedded-request-capable wallet, or via the normal bridge flow.
      • { hasResponse: false, connectResult: { dispatched } } — the wallet connected but did not return a signed transaction. The dApp must decide how to recover:
        • dispatched: false — the request never reached the wallet.
        • dispatched: truethe request was delivered to the wallet inside the connect URL. The wallet may have already signed and submitted it; you just didn't get the response. Do not retry silently. Surface an explicit retry button to the user, and ideally check on-chain state (e.g. the user's transaction history for the destination, queryId and amount) before re-submitting to avoid a duplicate transaction.

      Without the flag the method throws if the wallet is not connected and returns the plain SendTransactionResponse otherwise.

      Parameters

      • tx: SendTransactionRequest

        transaction to send.

      • Optionaloptions: ActionOptions

        modal and notifications behaviour settings; set enableEmbeddedRequest: true to opt into the connect-and-send flow described above.

      Returns Promise<OptionalTraceable<SendTransactionResponse>>

    • Opens the modal window and handles the transaction sending.

      Pass options.enableEmbeddedRequest: true to allow the request to ride along with the connect URL on mobile, eliminating a round-trip. With that flag, the result is always the embedded shape:

      • { hasResponse: true, response } — the transaction was signed, either folded into connect by an embedded-request-capable wallet, or via the normal bridge flow.
      • { hasResponse: false, connectResult: { dispatched } } — the wallet connected but did not return a signed transaction. The dApp must decide how to recover:
        • dispatched: false — the request never reached the wallet.
        • dispatched: truethe request was delivered to the wallet inside the connect URL. The wallet may have already signed and submitted it; you just didn't get the response. Do not retry silently. Surface an explicit retry button to the user, and ideally check on-chain state (e.g. the user's transaction history for the destination, queryId and amount) before re-submitting to avoid a duplicate transaction.

      Without the flag the method throws if the wallet is not connected and returns the plain SendTransactionResponse otherwise.

      Parameters

      • tx: SendTransactionRequest

        transaction to send.

      • Optionaloptions: EmbeddedActionOptions

        modal and notifications behaviour settings; set enableEmbeddedRequest: true to opt into the connect-and-send flow described above.

      Returns Promise<OptionalTraceable<EmbeddedSendTransactionResponse>>

    • Set desired network for the connection. Can only be set before connecting. If wallet connects with a different chain, the SDK will throw an error and abort connection.

      Parameters

      • Optionalnetwork: string

        desired network id (e.g., '-239', '-3', or custom). Pass undefined to allow any network.

      Returns void

    • Use it to customize ConnectRequest and add tonProof payload. You can call it multiply times to set updated tonProof payload if previous one is outdated. If connectRequestParameters.state === 'loading' loader will appear instead of the qr code in the wallets modal. If connectRequestParameters.state was changed to 'ready' or it's value has been changed, QR will be re-rendered.

      Parameters

      Returns void

    • Signs the data and returns the signature.

      Pass options.enableEmbeddedRequest: true to allow the request to ride along with the connect URL on mobile, eliminating a round-trip. With that flag, the result is always the embedded shape:

      • { hasResponse: true, response } — the data was signed, either folded into connect by an embedded-request-capable wallet, or via the normal bridge flow.
      • { hasResponse: false, connectResult: { dispatched } } — the wallet connected but did not return a signature. Recovery is the dApp's responsibility:
        • dispatched: false — the request never reached the wallet.
        • dispatched: truethe request was delivered to the wallet inside the connect URL. The wallet may have already signed it; you just didn't get the response back. Do not retry silently. Surface an explicit retry button to the user, and, where it makes sense, verify that you don't already have the signature you need before re-submitting.

      Without the flag the method throws if the wallet is not connected and returns the plain SignDataResponse otherwise.

      Parameters

      • data: SignDataPayload

        data to sign.

      • Optionaloptions: ActionOptions

        modal and notifications behaviour settings; set enableEmbeddedRequest: true to opt into the connect-and-sign flow described above.

      Returns Promise<OptionalTraceable<SignDataResponse>>

    • Signs the data and returns the signature.

      Pass options.enableEmbeddedRequest: true to allow the request to ride along with the connect URL on mobile, eliminating a round-trip. With that flag, the result is always the embedded shape:

      • { hasResponse: true, response } — the data was signed, either folded into connect by an embedded-request-capable wallet, or via the normal bridge flow.
      • { hasResponse: false, connectResult: { dispatched } } — the wallet connected but did not return a signature. Recovery is the dApp's responsibility:
        • dispatched: false — the request never reached the wallet.
        • dispatched: truethe request was delivered to the wallet inside the connect URL. The wallet may have already signed it; you just didn't get the response back. Do not retry silently. Surface an explicit retry button to the user, and, where it makes sense, verify that you don't already have the signature you need before re-submitting.

      Without the flag the method throws if the wallet is not connected and returns the plain SignDataResponse otherwise.

      Parameters

      • data: SignDataPayload

        data to sign.

      • Optionaloptions: EmbeddedActionOptions

        modal and notifications behaviour settings; set enableEmbeddedRequest: true to opt into the connect-and-sign flow described above.

      Returns Promise<OptionalTraceable<EmbeddedSignDataResponse>>

    • Signs a message built from a transaction request and returns the signed internal message BoC.

      Pass options.enableEmbeddedRequest: true to allow the request to ride along with the connect URL on mobile, eliminating a round-trip. With that flag, the result is always the embedded shape:

      • { hasResponse: true, response } — the message was signed, either folded into connect by an embedded-request-capable wallet, or via the normal bridge flow.
      • { hasResponse: false, connectResult: { dispatched } } — the wallet connected but did not return a signed message. Recovery is the dApp's responsibility:
        • dispatched: false — the request never reached the wallet. Calling signMessage(msg) again (over the bridge) is safe.
        • dispatched: truethe request was delivered to the wallet inside the connect URL. The wallet may have already signed (and, for gasless flows, even submitted) it; you just didn't get the BoC back. Do not retry silently. Surface an explicit retry button to the user, and for transfer-style payloads check on-chain (the destination and amount in recent transaction history) before re-submitting to avoid a double send.

      Without the flag the method throws if the wallet is not connected and returns the plain SignMessageResponse otherwise.

      Parameters

      • message: SendTransactionRequest

        transaction-like request describing the internal message to sign.

      • Optionaloptions: ActionOptions

        modal and notifications behaviour settings; set enableEmbeddedRequest: true to opt into the connect-and-sign flow described above.

      Returns Promise<OptionalTraceable<SignMessageResponse>>

    • Signs a message built from a transaction request and returns the signed internal message BoC.

      Pass options.enableEmbeddedRequest: true to allow the request to ride along with the connect URL on mobile, eliminating a round-trip. With that flag, the result is always the embedded shape:

      • { hasResponse: true, response } — the message was signed, either folded into connect by an embedded-request-capable wallet, or via the normal bridge flow.
      • { hasResponse: false, connectResult: { dispatched } } — the wallet connected but did not return a signed message. Recovery is the dApp's responsibility:
        • dispatched: false — the request never reached the wallet. Calling signMessage(msg) again (over the bridge) is safe.
        • dispatched: truethe request was delivered to the wallet inside the connect URL. The wallet may have already signed (and, for gasless flows, even submitted) it; you just didn't get the BoC back. Do not retry silently. Surface an explicit retry button to the user, and for transfer-style payloads check on-chain (the destination and amount in recent transaction history) before re-submitting to avoid a double send.

      Without the flag the method throws if the wallet is not connected and returns the plain SignMessageResponse otherwise.

      Parameters

      • message: SendTransactionRequest

        transaction-like request describing the internal message to sign.

      • Optionaloptions: EmbeddedActionOptions

        modal and notifications behaviour settings; set enableEmbeddedRequest: true to opt into the connect-and-sign flow described above.

      Returns Promise<OptionalTraceable<EmbeddedSignMessageResponse>>

    • Returns Promise<WalletInfo[]>