> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dynamic.xyz/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# generateTonConnectProof

# generateTonConnectProof

Generates a TonConnect proof for authentication with backend services. This creates a cryptographic proof that the user owns the wallet.

## Usage

```javascript theme={"system"}
import { generateTonConnectProof, isTonWalletAccount } from "@dynamic-labs-sdk/ton";
import { getPrimaryWalletAccount } from "@dynamic-labs-sdk/client";

const walletAccount = getPrimaryWalletAccount();

if (walletAccount && isTonWalletAccount(walletAccount)) {
  const proof = await generateTonConnectProof({
    payload: "authentication-challenge-from-backend",
    walletAccount,
  });

  console.log("TON Connect Proof:", proof);
  // {
  //   address: "UQ...",
  //   domain: { lengthBytes: 11, value: "example.com" },
  //   timestamp: 1704067200,
  //   payload: "authentication-challenge-from-backend",
  //   signature: "base64-encoded-signature"
  // }

  // Send this proof to your backend for verification
}
```

## Parameters

| Parameter | Type | Description |
| - | - | - |
| `payload` | `string` | The proof payload, typically a nonce or challenge from your backend |
| `walletAccount` | `TonWalletAccount` | The wallet account to generate the proof for |
| `client` | `DynamicClient` (optional) | The Dynamic client instance. Only required when using multiple clients. |

## Returns

`Promise<TonConnectProof>` - A promise that resolves to the proof object:

| Field | Type | Description |
| - | - | - |
| `address` | `string` | Wallet address |
| `domain` | `TonConnectDomain` | Domain information (see below) |
| `payload` | `string` | The payload string that was signed |
| `signature` | `string` | Signature as a base64 string |
| `timestamp` | `number` | Unix timestamp in seconds |

### TonConnectDomain

| Field | Type | Description |
| - | - | - |
| `lengthBytes` | `number` | Length of domain value in bytes |
| `value` | `string` | Domain value (e.g., "example.com") |

## Errors

| Error | Description |
| - | - |
| `NotTonProviderError` | Thrown if the wallet account's provider is not a TON provider |
| `MethodNotImplementedError` | Thrown if the wallet provider does not support proof generation |

## Related functions

* [isTonWalletAccount](https://docs.dynamic.xyz/docs/javascript/reference/ton/checking-ton-wallet-account-type.md) - Check if a wallet account is a TON account
* [sendTon](https://docs.dynamic.xyz/docs/javascript/reference/ton/send-ton.md) - Send native TON


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.