waitForTxReceipt method

Future<Map?> waitForTxReceipt(
  1. String txId, {
  2. int timeout = 20,
})

Wait for tx receipt, for several seconds Returns the receipt or Null

Implementation

Future<Map?> waitForTxReceipt(String txId, {int timeout = 20}) async {
  int rounds = timeout; //how many attempts
  Map? receipt;
  for (var i = 0; i < rounds; i++) {
    receipt = await getTransactionReceipt(txId);
    if (receipt != null) {
      return receipt;
    } else {
      sleep(const Duration(seconds: 3)); // interval
    }
  }

  return null;
}