Skip to main content

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.

Overview

This guide shows you how to sign messages with your TON wallet. Message signing uses Ed25519 and returns the signature as a base64 string. It is commonly used for authentication, nonce verification, and data integrity checks.

Prerequisites

Basic Message Signing

import { authenticatedTonClient } from './client';

const tonClient = await authenticatedTonClient();

const signature = await tonClient.signMessage({
  message: 'Hello, TON!',
  accountAddress: 'YourTonWalletAddress',
});

console.log('Message signed (base64):', signature);

Simple Message Signing

Whether you need to provide externalServerKeyShares depends on how you created your wallet: If you created your wallet with backUpToClientShareService: true, you don’t need to provide external key shares:
// ✅ Simple signing - no externalServerKeyShares needed
const signature = await tonClient.signMessage({
  message: 'Hello, TON!',
  accountAddress: 'YourTonWalletAddress',
});

console.log('Message signed (base64):', signature);

With Manual Backup

If you created your wallet with backUpToClientShareService: false, you must provide external key shares:
// First, retrieve your stored key shares
const keyShares = await retrieveStoredKeyShares('YourTonWalletAddress');

// ❌ Must provide externalServerKeyShares
const signature = await tonClient.signMessage({
  message: 'Hello, TON!',
  accountAddress: 'YourTonWalletAddress',
  externalServerKeyShares: keyShares, // Required for manual backup!
  password: 'your-password', // Only if wallet was created with password
});

console.log('Message signed (base64):', signature);
Password Handling Notes:
  • If your wallet was created without a password, omit the password parameter
  • If your wallet was created with a password, you must provide it for all operations
  • The password parameter is always optional in the API, but required if the wallet is password-protected

Common Use Cases

Authentication

const nonce = Date.now().toString();
const message = `Sign this message to authenticate: ${nonce}`;
const signature = await tonClient.signMessage({
  message,
  accountAddress: 'YourTonWalletAddress',
});
// signature is a base64-encoded Ed25519 signature

Data Integrity

const data = { userId: 123, action: 'transfer', amount: '100' };
const message = JSON.stringify(data);
const signature = await tonClient.signMessage({
  message,
  accountAddress: 'YourTonWalletAddress',
});

Next Steps