approve method

Future<String> approve(
  1. EthereumAddress spender,
  2. BigInt amount, {
  3. required Credentials credentials,
  4. Transaction? transaction,
})

Sets amount as the allowance of spender over the caller's tokens. Returns a boolean value indicating whether the operation succeeded. IMPORTANT: Beware that changing an allowance with this method brings the risk that someone may use both the old and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 Emits an Approval event.

The optional transaction parameter can be used to override parameters like the gas price, nonce and max gas. The data and to fields will be set by the contract.

Implementation

Future<String> approve(_i1.EthereumAddress spender, BigInt amount,
    {required _i1.Credentials credentials,
    _i1.Transaction? transaction}) async {
  final function = self.abi.functions[1];
  assert(checkSignature(function, '095ea7b3'));
  final params = [spender, amount];
  return write(credentials, transaction, function, params);
}