signToUint8List method

Uint8List signToUint8List(
  1. Uint8List payload, {
  2. int? chainId,
  3. bool isEIP1559 = false,
})

Signs the payload with a private key. The output will be like the bytes representation of the eth_sign RPC method, but without the "Ethereum signed message" prefix. The payload parameter contains the raw data, not a hash.

Implementation

Uint8List signToUint8List(
  Uint8List payload, {
  int? chainId,
  bool isEIP1559 = false,
}) {
  final signature =
      signToEcSignature(payload, chainId: chainId, isEIP1559: isEIP1559);

  final r = padUint8ListTo32(unsignedIntToBytes(signature.r));
  final s = padUint8ListTo32(unsignedIntToBytes(signature.s));
  final v = unsignedIntToBytes(BigInt.from(signature.v));

  // https://github.com/ethereumjs/ethereumjs-util/blob/8ffe697fafb33cefc7b7ec01c11e3a7da787fe0e/src/signature.ts#L63
  return uint8ListFromList(r + s + v);
}