transfer method

Future<String> transfer(
  1. String receiverAddress,
  2. int amountInWei
)

Implementation

Future<String> transfer(
  String receiverAddress,
  int amountInWei,
) async {
  print('transfer --> receiver: $receiverAddress, amountInWei: $amountInWei');

  bool isApproved = await _approveCb;
  if (!isApproved) {
    throw 'transaction not approved';
  }

  EthereumAddress receiver = EthereumAddress.fromHex(receiverAddress);
  EtherAmount amount = EtherAmount.fromUnitAndValue(
    EtherUnit.wei,
    BigInt.from(amountInWei),
  );

  String txHash = await _sendTransactionAndWaitForReceipt(
    Transaction(to: receiver, value: amount),
  );
  print('transction $txHash successful');
  return txHash;
}