WDK logoWDK documentation

Sign and Verify Messages

Sign messages and verify signatures with Solana accounts using Ed25519.

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

Sign a Message

Use account.sign() to produce an Ed25519 signature for any string message.

Sign a Message
const message = 'Hello, Solana!'
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 WalletAccountReadOnlySolana from any public key 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