This is a React-only guide.
Overview
After signing messages, you’ll often need to decode and verify signatures. Viem provides utilities for signature verification and recovery. This guide shows you how to decode signatures to extract the signer’s address and verify message authenticity.Decode a Simple Message Signature
Best Practices
- Always verify signatures: Don’t just recover the address - also verify the signature is valid
- Handle errors gracefully: Signature decoding can fail for various reasons
- Validate addresses: Ensure the recovered address matches the expected signer
- Use case-insensitive comparison: Compare addresses using
toLowerCase()
for consistency