increaseAllowance method

Future<String> increaseAllowance(
  1. String ownerPrivateKey,
  2. dynamic contract_Add,
  3. dynamic spender_Add,
  4. dynamic value,
)

Increase the amount of tokens that an owner allowed to a spender. ownerPrivateKey : Owner Private key. contract_Add : Token Address for which , allownce need to to increase. spender_add : The address which will spend the funds. value : The amount of tokens to increase the allowance by.

Implementation

Future<String> increaseAllowance(
    String ownerPrivateKey, contract_Add, spender_Add, value) async {
  final String privateKey = ownerPrivateKey;
  final credentials = await EthPrivateKey.fromHex(privateKey);
  final ownAddress = await credentials.extractAddress();

  final EthereumAddress contractAddr = EthereumAddress.fromHex(contract_Add);
  final contract = DeployedContract(
      ContractAbi.fromJson(abiString, 'XRC20'), contractAddr);
  final tokenAllowance = contract.function('allowance');
  final EthereumAddress spender = EthereumAddress.fromHex(spender_Add);
  final increase = await client.call(
      contract: contract,
      function: tokenAllowance,
      params: [ownAddress, spender]);

  var increase_amount = increase[0];
  var amount = increase_amount + value;

  final tokenApproveincrease = contract.function('approve');
  final increasedAllowance = await Transaction.callContract(
      contract: contract,
      function: tokenApproveincrease,
      parameters: [spender, amount]);
  final increasedAllowances = await client.sendTransaction(
      credentials, increasedAllowance,
      chainId: null, fetchChainIdFromNetworkId: true);

  return '$increasedAllowances';
}