watchTxStatus method

Future<TransactionReceipt> watchTxStatus(
  1. String txHash
)

Implementation

Future<TransactionReceipt> watchTxStatus(String txHash) async {
  TransactionReceipt? receipt;
  try {
    print('async watch tx status');
    receipt = await getTransactionReceipt(txHash);
  } catch (err) {
    print('could not get $txHash receipt, try again');
  }

  /// with retry:
  int delay = 1;
  int retries = 10;
  while (receipt == null) {
    print('retry: waiting for receipt');
    await Future.delayed(new Duration(seconds: delay));
    delay *= 2;
    retries--;
    if (retries == 0) {
      throw 'transaction $txHash not mined yet...';
    }
    try {
      receipt = await getTransactionReceipt(txHash);
    } catch (err) {
      print('could not get $txHash receipt, try again');
    }
  }
  return receipt;
}