Skip to content
On this page

hashMessage โ€‹

Calculates an Ethereum-specific hash in EIP-191 format: keccak256("\x19Ethereum Signed Message:\n" + len(message) + message)).

Import โ€‹

ts
import { hashMessage } from 'viem'

Usage โ€‹

ts
import { hashMessage } from 'viem'

hashMessage('hello world') 
// 0xd9eba16ed0ecae432b71fe008c98cc872bb4cc214d3220a36f365326cf807d68

Returns โ€‹

Hex

The hashed message.

Parameters โ€‹

message โ€‹

Message to hash.

  • Type: string

Released under the MIT License.