API
@joyid/evm
signMessage

signMessage

Signers an EIP-191 (opens in a new tab) prefixed personal message. If the message is a string, it is signed as UTF-8 encoded bytes. It is not interpretted as a BytesLike; so the string "0x1234" is signed as six characters, not two bytes.

To sign that example as two bytes, the Uint8Array should be used (i.e. new Uint8Array([ 0x12, 0x34 ])).

Types

function signMessage(message: string | Uint8Array, signerAddress?: string): Promise<string>

Example

import { signMessage } from '@joyid/evm'
 
async function signMessageOnClick() {
  const signature = await signMessage('Hello, world!', '<your connected address>')
  console.log(`Signature: ${signature}`)
}