getInitCode method
Implementation
Future<String> getInitCode() async {
try {
await checkIfInitialized();
if (!this.isInitialized!) {
print(this.ownerAddress!);
print(this.salt!);
print(this.plugins!);
String contractCallCode = hex.encode(OctacoreSmartAccountFactory()
.deployedContract
.function("createSmartAccount")
.encodeCall([
EthereumAddress.fromHex(this.ownerAddress!),
EthereumAddress.fromHex(SmartAccountFactory.entryPoint), // this.salt,
BigInt.from(this.salt!),
this.plugins!.map((e) => EthereumAddress.fromHex(e)).toList(),
]));
this.initCode =
OctacoreSmartAccountFactory().contractAddress + contractCallCode;
return "0x" + contractCallCode;
} else {
return "";
}
} on Exception catch (e) {
print(e);
throw Exception("Could not get init code");
}
}