sign method

  1. @Deprecated('Please use [signToUint8List]')
Future<Uint8List> sign(
  1. Uint8List payload, {
  2. int? chainId,
  3. bool isEIP1559 = false,
})
inherited

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

@Deprecated('Please use [signToUint8List]')
Future<Uint8List> sign(
  Uint8List payload, {
  int? chainId,
  bool isEIP1559 = false,
}) async {
  final signature =
      await signToSignature(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);
}