WDK logoWDK documentation

Sign and Verify Messages

Sign messages and verify signatures with Tron accounts using secp256k1.

This guide explains how to sign messages with an owned account and verify signatures using a read-only account. Tron uses secp256k1 cryptography for signing.

Sign a Message

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

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

Verify a Signature

You can verify that a signature was produced by the corresponding private key using readOnlyAccount.verify():

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

You can also create a WalletAccountReadOnlyTron from any Tron address to verify signatures without access to the private key.

Next Steps

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

On this page