Documentation
    Preparing search index...

    Interface ITonConnect

    interface ITonConnect {
        account: null | Account;
        connected: boolean;
        wallet: null | Wallet;
        connect<
            T extends
                | WalletConnectionSource
                | Pick<WalletConnectionSourceHTTP, "bridgeUrl">[],
        >(
            wallet: T,
            request?: ConnectAdditionalRequest,
        ): T extends WalletConnectionSourceJS ? void : string;
        disconnect(options?: { signal?: AbortSignal }): Promise<void>;
        getWallets(): Promise<WalletInfo[]>;
        onStatusChange(
            callback: (walletInfo: null | Wallet) => void,
            errorsHandler?: (err: TonConnectError) => void,
        ): () => void;
        pauseConnection(): void;
        restoreConnection(
            options?: { openingDeadlineMS?: number; signal?: AbortSignal },
        ): Promise<void>;
        sendTransaction(
            transaction: SendTransactionRequest,
            options?: { onRequestSent?: () => void; signal?: AbortSignal },
        ): Promise<SendTransactionResponse>;
        sendTransaction(
            transaction: SendTransactionRequest,
            onRequestSent?: () => void,
        ): Promise<SendTransactionResponse>;
        signData(
            data: SignDataPayload,
            options?: { onRequestSent?: () => void; signal?: AbortSignal },
        ): Promise<SignDataResponse>;
        unPauseConnection(): Promise<void>;
    }

    Implemented by

    Index

    Properties

    account: null | Account

    Current connected account or null if no account is connected.

    connected: boolean

    Shows if the wallet is connected right now.

    wallet: null | Wallet

    Current connected wallet or null if no account is connected.

    Methods

    • Generates universal link for an external wallet and subscribes to the wallet's bridge, or sends connect request to the injected wallet.

      Type Parameters

      Parameters

      • wallet: T

        wallet's bridge url and universal link for an external wallet or jsBridge key for the injected wallet, or list of bridges urls for creating an universal connection request for the corresponding wallets.

      • Optionalrequest: ConnectAdditionalRequest

        (optional) additional request to pass to the wallet while connect (currently only ton_proof is available).

      Returns T extends WalletConnectionSourceJS ? void : string

      universal link if external wallet was passed or void for the injected wallet.

    • Disconnect form thw connected wallet and drop current session.

      Parameters

      • Optionaloptions: { signal?: AbortSignal }

      Returns Promise<void>

    • Returns available wallets list.

      Returns Promise<WalletInfo[]>

    • Allows to subscribe to connection status changes and handle connection errors.

      Parameters

      • callback: (walletInfo: null | Wallet) => void

        will be called after connections status changes with actual wallet or null.

      • OptionalerrorsHandler: (err: TonConnectError) => void

        (optional) will be called with some instance of TonConnectError when connect error is received.

      Returns () => void

      unsubscribe callback.

    • Pause bridge HTTP connection. Might be helpful, if you want to pause connections while browser tab is unfocused, or if you use SDK with NodeJS and want to save server resources.

      Returns void

    • Try to restore existing session and reconnect to the corresponding wallet. Call it immediately when your app is loaded.

      Parameters

      • Optionaloptions: { openingDeadlineMS?: number; signal?: AbortSignal }

      Returns Promise<void>

    • Asks connected wallet to sign and send the transaction.

      Parameters

      • transaction: SendTransactionRequest

        transaction to send.

      • Optionaloptions: { onRequestSent?: () => void; signal?: AbortSignal }

        (optional) onRequestSent callback will be called after the transaction is sent and signal to abort the request.

      Returns Promise<SendTransactionResponse>

      signed transaction boc that allows you to find the transaction in the blockchain. If user rejects transaction, method will throw the corresponding error.

    • Parameters

      Returns Promise<SendTransactionResponse>

      use sendTransaction(transaction, options) instead

    • Parameters

      • data: SignDataPayload
      • Optionaloptions: { onRequestSent?: () => void; signal?: AbortSignal }

      Returns Promise<SignDataResponse>

    • Unpause bridge HTTP connection if it is paused.

      Returns Promise<void>