read method
Implementation
Future<ExternalContractFunctionWithValuesAndOutputs> read({
required ExternalContractFunctionWithValues function,
BlockNum? atBlock,
required List<FunctionParam>? outputs,
StateMutability? stateMutability,
}) async {
final _stateMutability = stateMutability ?? function.stateMutability;
if (_stateMutability != StateMutability.pure &&
_stateMutability != StateMutability.view) {
throw ArgumentError('Function is not view or pure');
}
final _outputs = outputs ?? function.outputTypes;
if (_outputs == null || _outputs.isEmpty) {
throw ArgumentError('Outputs must be provided');
}
final data = function.buildDataField();
final String result =
await rpc.call(contractAddress: contractAddress, data: data);
final resultBuffer = result.hexToBytesWithPrefix;
return ExternalContractFunctionWithValuesAndOutputs.decode(
data: resultBuffer,
function: function,
outputs: _outputs,
stateMutability: stateMutability,
);
}