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,
            options?: OptionalTraceable<
                { openingDeadlineMS?: number; signal?: AbortSignal },
            >,
        ): T extends WalletConnectionSourceJS
            ? void
            : T extends WalletConnectionSourceWalletConnect ? void : string;
        disconnect(
            options?: OptionalTraceable<{ signal?: AbortSignal }>,
        ): Promise<void>;
        getSessionId(): Promise<null | string>;
        getWallets(): Promise<WalletInfo[]>;
        makeSendActionIntent(
            intent: MakeSendActionIntentRequest,
            options?: OptionalTraceable<{ walletUniversalLink?: string }>,
        ): Promise<string>;
        makeSendTransactionIntent(
            intent: MakeSendTransactionIntentRequest,
            options?: OptionalTraceable<{ walletUniversalLink?: string }>,
        ): Promise<string>;
        makeSignDataIntent(
            intent: MakeSignDataIntentRequest,
            options?: OptionalTraceable<{ walletUniversalLink?: string }>,
        ): Promise<string>;
        makeSignMessageIntent(
            intent: MakeSignMessageIntentRequest,
            options?: OptionalTraceable<{ walletUniversalLink?: string }>,
        ): Promise<string>;
        onIntentResponse(
            callback: (
                response: {
                    error?: unknown;
                    id: string;
                    result?: unknown;
                    traceId?: string;
                },
            ) => void,
        ): () => void;
        onStatusChange(
            callback: (walletInfo: null | Wallet) => void,
            errorsHandler?: (err: TonConnectError) => void,
        ): () => void;
        pauseConnection(): void;
        restoreConnection(
            options?: OptionalTraceable<
                { openingDeadlineMS?: number; signal?: AbortSignal },
            >,
        ): Promise<void>;
        sendTransaction(
            transaction: SendTransactionRequest,
            options?: OptionalTraceable<
                { onRequestSent?: () => void; signal?: AbortSignal },
            >,
        ): Promise<OptionalTraceable<SendTransactionResponse>>;
        sendTransaction(
            transaction: SendTransactionRequest,
            onRequestSent?: () => void,
        ): Promise<OptionalTraceable<SendTransactionResponse>>;
        setConnectionNetwork(network?: string): void;
        signData(
            data: SignDataPayload,
            options?: OptionalTraceable<
                { onRequestSent?: () => void; signal?: AbortSignal },
            >,
        ): Promise<OptionalTraceable<SignDataResponse>>;
        signMessage(
            message: SignMessageRequest,
            options?: OptionalTraceable<
                { onRequestSent?: () => void; signal?: AbortSignal },
            >,
        ): Promise<OptionalTraceable<SignMessageResponse>>;
        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

    • Disconnect form thw connected wallet and drop current session.

      Parameters

      Returns Promise<void>

    • Gets the current session ID if available.

      Returns Promise<null | string>

      session ID string or null if not available.

    • Returns available wallets list.

      Returns Promise<WalletInfo[]>

    • Generates a universal link for a send action intent. This allows users to complete actions via a dynamic action URL without being connected to the wallet.

      Parameters

      Returns Promise<string>

      universal link that can be opened in a wallet or displayed as QR code.

    • Generates a universal link for a send transaction intent. This allows users to complete transactions without being connected to the wallet.

      Parameters

      Returns Promise<string>

      universal link that can be opened in a wallet or displayed as QR code.

    • Generates a universal link for a sign data intent. This allows users to sign data without being connected to the wallet.

      Parameters

      Returns Promise<string>

      universal link that can be opened in a wallet or displayed as QR code.

    • Generates a universal link for a sign message intent. This allows users to sign messages without being connected to the wallet.

      Parameters

      Returns Promise<string>

      universal link that can be opened in a wallet or displayed as QR code.

    • Subscribe to intent response events. This allows you to receive responses from intents (e.g., transaction results, sign data results).

      Parameters

      • callback: (
            response: {
                error?: unknown;
                id: string;
                result?: unknown;
                traceId?: string;
            },
        ) => void

        will be called when an intent response is received.

      Returns () => void

      unsubscribe function.

    • 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: OptionalTraceable<{ openingDeadlineMS?: number; signal?: AbortSignal }>

      Returns Promise<void>

    • 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

    • Unpause bridge HTTP connection if it is paused.

      Returns Promise<void>