Skip to content

PersonalMessage.encode

Encodes a personal sign message in ERC-191 format: 0x19 ‖ "Ethereum Signed Message:\n" + message.length ‖ message.

Imports

Named
import { PersonalMessage } from 'ox'

Examples

import { Hex, PersonalMessage } from 'ox'
 
const data = PersonalMessage.encode(Hex.fromString('hello world'))
'0x19457468657265756d205369676e6564204d6573736167653a0a313168656c6c6f20776f726c64'
(0x19 ‖ 'Ethereum Signed Message:\n11' ‖ 'hello world')

Definition

function encode(
  data: Hex.Hex | Bytes.Bytes,
): Hex.Hex

Source: src/PersonalMessage.ts

Parameters

data

  • Type: Hex.Hex | Bytes.Bytes

The data to encode.

Return Type

The encoded personal sign message.

Hex.Hex