scCall method

  1. @override
Future<(String, bool)> scCall({
  1. required Account account,
  2. required double fee,
  3. required double maximumGas,
  4. required double coins,
  5. required String smartContracAddress,
  6. required String functionName,
  7. required Uint8List functionParameters,
})
override

scCall executes smart contract

Implementation

@override
Future<(String, bool)> scCall(
    {required Account account,
    required double fee,
    required double maximumGas,
    required double coins,
    required String smartContracAddress,
    required String functionName,
    required Uint8List functionParameters}) async {
  try {
    final status = await _grpc.getStatus();
    final expirePeriod = status.lastExecutedFinalSlot.period + status.config.operationValidityPeriods;
    final operation = await callSC(
        account, smartContracAddress, functionName, functionParameters, fee, maximumGas, coins, expirePeriod.toInt());
    String operationID = "";
    await for (final resp in _grpc.sendOperations([operation])) {
      if (resp.operationIds.operationIds.isEmpty) {
        return (operationID, false);
      }
      operationID = resp.operationIds.operationIds[0];
      final status = await waitForFinalOperationStatus(operationID);
      return (operationID, status);
    }
    return (operationID, false);
  } catch (error) {
    throw Exception(error);
  }
}