checkIfInitialized method
Checks if the smart contract is initialized.
This function retrieves the bytecode at the provided contract address and checks if it is empty (indicating that the contract is not initialized).
Returns:
- A Future
Implementation
Future<bool> checkIfInitialized() async {
try {
// Get the bytecode at the specified contract address.
var code = await getCodeAt(this.scwAddress);
// Check if the bytecode is empty to determine if the contract is initialized.
if (code == "0x") {
this.isInitialized = false;
} else {
this.isInitialized = true;
}
// Return the initialization status.
return this.isInitialized!;
} catch (e) {
// Print any error that occurs during the process and return false as a default value.
print(e);
return false;
}
}