interact method

Future<String> interact({
  1. required ContractFunctionWithValues function,
  2. required Uint8List seed,
  3. required String sender,
  4. EvmFeeInformation<EvmGasPrice>? feeInfo,
  5. BigInt? value,
  6. List<AccessListItem>? accessList,
})

Implementation

Future<String> interact({
  required ContractFunctionWithValues function,
  required Uint8List seed,
  required String sender,
  EvmFeeInformation? feeInfo,
  BigInt? value,
  List<AccessListItem>? accessList,
}) async {
  final functionData = function.buildDataField();

  if (value != null) {
    assert(
      function.stateMutability == StateMutability.payable,
      'Function is not payable and cannot accept a value',
    );
  } else {
    assert(
      function.stateMutability == StateMutability.nonpayable,
      'Function is payable and requires a value to be sent',
    );
  }

  return await rpc.buildAndBroadcastTransaction(
    sender: sender,
    recipient: contractAddress,
    seed: seed,
    feeInfo: feeInfo,
    data: functionData,
    value: value ?? BigInt.zero,
    accessList: accessList,
  );
}