sign method
Sign The sign method calculates an Ethereum specific signature with: sign(keccak256('\x19Ethereum Signed Message:\n' + len(message) + message))). Note the address to sign with must be unlocked.
Implementation
Future<EthereumData?> sign(
EthereumAddress? account, EthereumData? message) async {
if (account == null) {
throw ArgumentError.notNull('Ethereum::sign - account');
}
if (message == null) {
throw ArgumentError.notNull('Ethereum::sign - message');
}
const method = EthereumRpcMethods.sign;
final params = <String?>[account.asString, message.asString];
final dynamic res = await _client.rpcClient.request(method, params);
if (res != null && res.containsKey(EthereumConstants.ethResultKey)) {
return EthereumData.fromString(res[EthereumConstants.ethResultKey]);
}
_client.processError(method, res);
return null;
}