waitForTxConfirmation method

Future<bool> waitForTxConfirmation(
  1. String hash, {
  2. Duration interval = const Duration(seconds: 5),
})

Implementation

Future<bool> waitForTxConfirmation(
  String hash, {
  Duration interval = const Duration(seconds: 5),
}) async {
  while (true) {
    await Future.delayed(interval);

    final receipt = await performTask(
      (client) => client.getTransactionReceipt(hash),
    );

    switch (receipt?['status']) {
      case '0x1':
        return true;
      case '0x0':
        return false;
      default:
    }
  }
}