readContract static method
Read contract
address
is public address
contractAddress
is contract address
methodName
is a contract method name, such as 'mint', 'balanceOf'
parameters
is parameters required by the method
abiJsonString
is abi json string, such as "[{"inputs":{\"internalType\":\"uint256\",\"name\":\"quantity\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}
,"name":"mint","outputs":[],"stateMutability":"nonpayable","type":"function"}]"
Implementation
static Future<dynamic> readContract(String address, String contractAddress,
String methodName, List<Object> parameters, String abiJsonString) async {
final data = await EvmService.customMethod(
contractAddress, methodName, parameters, abiJsonString);
final req = RequestBodyEntity();
req.chainId = await ParticleBase.getChainId();
const method = "eth_call";
final params = [
{"to": contractAddress, "data": data, "from": address},
"latest"
];
final result = await EvmService.rpc(method, params);
return result;
}