approve method

Future<void> approve(
  1. String spender,
  2. double amount
)

Implementation

Future<void> approve(String spender, double amount) async {
  final params = Args();
  params.addString(spender);
  params.addU256(BigInt.from(doubleToMassaInt(amount)));
  const targetFunction = "approve";
  final functionParameters = params.serialise();
  const maximumGas = GasLimit.MAX_GAS_CALL;
  final smartContracAddress = getTokenAddress(token, grpc.isBuildnet);

  await grpc.scCall(
    account: grpc.account,
    fee: 0.01,
    coins: 0.0,
    maximumGas: maximumGas.value / 1e9,
    smartContracAddress: smartContracAddress,
    functionName: targetFunction,
    functionParameters: functionParameters,
  );
}