WDK logoWDK documentation

Sign and Verify Messages

Sign messages and verify signatures with gasless TON accounts.

This guide explains how to sign messages with an owned account and verify signatures.

Sign a Message

You can produce a cryptographic signature for any string message using account.sign():

Sign a Message
const message = 'Hello, TON!'
const signature = await account.sign(message)
console.log('Signature:', signature)

Verify a Signature

You can verify that a signature is valid using account.verify():

Verify a Signature
const isValid = await account.verify(message, signature)
console.log('Signature valid:', isValid)

You can also create a WalletAccountReadOnlyTonGasless from any public key to verify signatures without access to the private key:

Verify with Read-Only Account
import { WalletAccountReadOnlyTonGasless } from '@tetherto/wdk-wallet-ton-gasless'

const readOnlyAccount = new WalletAccountReadOnlyTonGasless(publicKey, {
  tonClient: {
    url: 'https://toncenter.com/api/v3',
    secretKey: 'your-api-key'
  },
  tonApiClient: {
    url: 'https://tonapi.io/v2',
    secretKey: 'your-ton-api-key'
  },
  paymasterToken: {
    address: 'EQ...'
  }
})

const isValid = await readOnlyAccount.verify(message, signature)
console.log('Signature valid:', isValid)

Next Steps

For best practices on handling errors, managing fees, and cleaning up memory, see Handle Errors.

On this page