write method

Future<String> write({
  1. required String functionName,
  2. required List args,
  3. required Credentials credentials,
  4. BigInt? value,
})

Implementation

Future<String> write({
  required String functionName,
  required List<dynamic> args,
  required web3.Credentials credentials,
  BigInt? value, // Add this line for the value parameter
  //   required BigInt gasPrice,
  //   required BigInt gasLimit,
}) async {
  final function = this.contract.function(functionName);
  final chainId = await this.client.getNetworkId();
  final transaction = web3.Transaction.callContract(
    contract: this.contract,
    function: function,
    parameters: args,
    value: value != null
        ? web3.EtherAmount.fromBigInt(web3.EtherUnit.wei, value)
        : null,
    // gasPrice: gasPrice,
    // maxGas: gasLimit,
  );
  final response = await this.client.sendTransaction(
        credentials,
        transaction,
        chainId: chainId,
      );
  print(response);
  return response;
}