Skip to main content

hashMessage

Callable

  • hashMessage(message: string): string

  • Hashes the given message. The data will be UTF-8 HEX decoded and enveloped as follows: "\x19Ethereum Signed Message:\n" + message.length + message and hashed using keccak256.


    Parameters

    • message: string

      A message to hash, if its HEX it will be UTF8 decoded.

    Returns string

    The hashed message

    web3.eth.accounts.hashMessage("Hello world")

    > "0x8144a6fa26be252b86456491fbcd43c1de7e022241845ffea1c3df066f7cfede"

    web3.eth.accounts.hashMessage(web3.utils.utf8ToHex("Hello world")) // Will be hex decoded in hashMessage

    > "0x8144a6fa26be252b86456491fbcd43c1de7e022241845ffea1c3df066f7cfede"