clearBatch method
Clears the batch of contract calls in the current instance.
This function removes all Ethereum transactions stored in the batch, effectively clearing the batch.
Returns:
trueif the batch is successfully cleared.- Throws an exception with an error message if an exception occurs during the process.
Implementation
bool clearBatch() {
try {
// Clear the batch by assigning an empty map to it.
this.batch = {};
// Return true to indicate a successful batch clearing.
return true;
} on Exception catch (e) {
// Print any exception that occurs during the process, then throw a new exception with an error message.
print(e);
throw Exception("Could not clear batch");
}
}