encodedDataForContractCall static method

String encodedDataForContractCall(
  1. String contractName,
  2. EthereumAddress contractAddress,
  3. String methodName,
  4. List params, {
  5. String? jsonInterface,
  6. bool include0x = false,
  7. int? forcePadLength,
  8. bool padToEvenLength = false,
})

Encodes data for a contract call using the specified function and parameters.

contractName is the name of the contract. contractAddress is the address of the deployed contract. methodName is the name of the function to be called. params is a list of parameters to be passed to the function. jsonInterface is an optional JSON string representing the contract ABI. include0x is a flag to include the '0x' prefix in the encoded data. forcePadLength is an optional integer to force padding of the output data. padToEvenLength is a flag to pad the output data to an even length.

Returns a Future that resolves to the encoded data as a hex string.

Implementation

static String encodedDataForContractCall(
  String contractName,
  EthereumAddress contractAddress,
  String methodName,
  List<dynamic> params, {
  String? jsonInterface,
  bool include0x = false,
  int? forcePadLength,
  bool padToEvenLength = false,
}) {
  final DeployedContract contract = _getDeployedContract(
    contractName,
    contractAddress,
    jsonInterface: jsonInterface,
  );
  final Uint8List data = contract.function(methodName).encodeCall(params);
  return bytesToHex(
    data,
    include0x: include0x,
    forcePadLength: forcePadLength,
    padToEvenLength: padToEvenLength,
  );
}