Skip to content
On this page

verifyMessage

Verify that a message was signed by the provided address.

Usage

ts
import { verifyMessage } from 'viem'

const valid = verifyMessage({ 
  address: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
  message: 'hello world',
  signature: '0x66edc32e2ab001213321ab7d959a2207fcef5190cc9abb6da5b0d2a8a9af2d4d2b0700e2c317c4106f337fd934fbbb0bf62efc8811a78603b33a8265d3b8f8cb1c'
})
// true

Returns

boolean

Whether the provided address generated the signature.

Parameters

Address

The Ethereum address that signed the original message.

ts
const valid = verifyMessage({ 
  address: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266', 
  message: 'hello world',
  signature: '0x66edc32e2ab001213321ab7d959a2207fcef5190cc9abb6da5b0d2a8a9af2d4d2b0700e2c317c4106f337fd934fbbb0bf62efc8811a78603b33a8265d3b8f8cb1c'
})

message

  • Type: string

The message to be verified.

ts
const valid = verifyMessage({ 
  address: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266', 
  message: 'hello world', 
  signature: '0x66edc32e2ab001213321ab7d959a2207fcef5190cc9abb6da5b0d2a8a9af2d4d2b0700e2c317c4106f337fd934fbbb0bf62efc8811a78603b33a8265d3b8f8cb1c'
})

signature

  • Type: Hex | ByteArray

The signature that was generated by signing the message with the address's private key.

ts
const valid = verifyMessage({ 
  address: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266', 
  message: 'hello world', 
  signature: '0x66edc32e2ab001213321ab7d959a2207fcef5190cc9abb6da5b0d2a8a9af2d4d2b0700e2c317c4106f337fd934fbbb0bf62efc8811a78603b33a8265d3b8f8cb1c' 
})

Released under the MIT License.