write method

Future<String> write(
  1. String functionName,
  2. List args, {
  3. BigInt? value,
  4. BigInt? gasLimit,
  5. BigInt? gasPrice,
  6. BigInt? maxFeePerGas,
  7. BigInt? maxPriorityFeePerGas,
})
inherited

Executes a state-changing contract function.

Implementation

Future<String> write(
  String functionName,
  List<dynamic> args, {
  BigInt? value,
  BigInt? gasLimit,
  BigInt? gasPrice,
  BigInt? maxFeePerGas,
  BigInt? maxPriorityFeePerGas,
}) async {
  if (walletClient == null) {
    throw StateError('WalletClient required for write operations');
  }

  final function = _getFunction(functionName);
  final callData = AbiEncoder.encodeFunction(function.signature, args);

  final request = TransactionRequest(
    to: address,
    data: callData,
    value: value,
    gasLimit: gasLimit,
    gasPrice: gasPrice,
    maxFeePerGas: maxFeePerGas,
    maxPriorityFeePerGas: maxPriorityFeePerGas,
  );

  return walletClient!.sendTransactionRequest(request);
}