signPersonalMessageToUint8List method

Uint8List signPersonalMessageToUint8List(
  1. Uint8List payload, {
  2. int? chainId,
})

Signs an Ethereum specific signature. This method is equivalent to signToUint8List, but with a special prefix so that this method can't be used to sign, for instance, transactions.

Implementation

Uint8List signPersonalMessageToUint8List(Uint8List payload, {int? chainId}) {
  final prefix = _messagePrefix + payload.length.toString();
  final prefixBytes = ascii.encode(prefix);

  // will be a Uint8List, see the documentation of Uint8List.+
  final concat = uint8ListFromList(prefixBytes + payload);

  return signToUint8List(concat, chainId: chainId);
}