Sorry for the newbie question. I am experimenting with hedera Smart Contracts. Whenever trying to call a simple function which compares the uint argument with a uint member of the contract I systematically get a CONTRACT_REVERT_EXECUTED status.
solidity
function compare(uint number_) public view returns (bool){
return (number_ > secret_number);
}
java
public static boolean compare(Client client, ContractId contractId, int guess) throws TimeoutException, PrecheckStatusException
{
// Calls a function of the smart contract
ContractCallQuery contractQuery = new ContractCallQuery()
//Set the gas for the query
.setGas(100_000)
//Set the contract ID to return the request for
.setContractId(contractId)
//Set the function of the contract to call
.setFunction("compare", new ContractFunctionParameters().addUint32(guess))
//Set the query payment for the node returning the request
//This value must cover the cost of the request otherwise will fail
.setQueryPayment(new Hbar(4));
//Submit to a Hedera network
ContractFunctionResult getMessage = contractQuery.execute(client);
return getMessage.getBool(0);
}
Exception
*
Exception in thread "main" com.hedera.hashgraph.sdk.PrecheckStatusException: Hedera transaction 0.0.34318751@1651508840.487521537
failed pre-check with the status CONTRACT_REVERT_EXECUTED
at com.hedera.hashgraph.sdk.Executable$GrpcRequest.mapStatusException(Executable.java:457)
at com.hedera.hashgraph.sdk.Executable.execute(Executable.java:241)
at com.hedera.hashgraph.sdk.Query.execute(Query.java:29)
at com.hedera.hashgraph.sdk.Executable.execute(Executable.java:189)
at com.hedera.hashgraph.sdk.Query.execute(Query.java:29)
at hbarTexting.GuessNumberSmartContract.compare(GuessNumberSmartContract.java:132)
at hbarTexting.GuessNumberSmartContract.main(GuessNumberSmartContract.java:257)
*
What am I doing wrong here?
Any help greatly appreciated!