Sign and Verify Messages
Sign messages and verify signatures with gas-free Tron 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():
const message = 'Hello, Tron!'
const signature = await account.sign(message)
console.log('Signature:', signature)Verify a Signature
You can verify that a signature is valid using account.verify():
const isValid = await account.verify(message, signature)
console.log('Signature valid:', isValid)You can also create a WalletAccountReadOnlyTronGasfree 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.