getPredictSmartContractAddress method

Future<String> getPredictSmartContractAddress(
  1. String address
)

Implementation

Future<String> getPredictSmartContractAddress(String address) async {
  var addr = toBuffer(address);
  var epoch;
  DnaGetEpochResponse dnaGetEpochResponse =
      await AppService().getDnaGetEpoch();
  if (dnaGetEpochResponse != null && dnaGetEpochResponse.result != null) {
    epoch = intToBuffer(dnaGetEpochResponse.result.epoch);
  }
  var nonce = intToBuffer(await AppService().getLastNonce(address) + 1);
  var res = Uint8List.fromList([
    ...addr,
    ...epoch,
    ...Uint8List(2 - epoch.length),
    ...nonce,
    ...Uint8List(4 - nonce.length)
  ]);
  var hash = crypto.keccak256(res);
  String addressSC =
      AppHelpers.toHexString(hash.sublist(hash.length - 20), true);
  //print('addressSC: ' + addressSC);
  return addressSC;
}