transfer method

Future<Map> transfer({
  1. required String token,
  2. required double amount,
  3. required String to,
  4. required String sender,
  5. required String pass,
  6. required Map gasOptions,
  7. required dynamic onStatusChange(
    1. Map
    ),
})

Implementation

Future<Map> transfer(
    {required String token,
    required double amount,
    required String to,
    required String sender,
    required String pass,
    required Map gasOptions,
    required Function(Map) onStatusChange}) async {
  final code =
      'eth.keyring.transfer("$token", $amount, "$to", "$sender", "$pass", ${jsonEncode(gasOptions)})';
  print('send evm transfer:');
  print(code);
  final res = await serviceRoot.webView!.evalJavascript(code);
  if (res != null && res['hash'] != null) {
    serviceRoot.webView!.addMsgHandler(res['hash'], (Map res) {
      onStatusChange(res);
      if ((res['confirmNumber'] ?? -1) > 1) {
        serviceRoot.webView!.removeMsgHandler(res['hash']);
      }
    });
  }
  return res;
}