WDK logoWDK documentation

Sign and Verify Messages

Sign messages and verify signatures with EVM accounts.

This guide explains how to sign arbitrary messages with an owned account and verify signatures using a read-only account.

Sign a Message

Use account.sign() to produce a cryptographic signature for any string message.

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

Verify a Signature

You can get a read-only account from any Account object by calling account.toReadOnlyAccount(). Use a read-only account to verify() that a signature was produced by the corresponding private key.

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 WalletAccountReadOnlyEvm from any public 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 Error Handling.

On this page