Get a smart contract function
Method
Type
Description
Requirement
Methods
//Contract call query
ContractCallQuery query = new ContractCallQuery()
.setContractId(contractId)
.setGas(600)
.setFunction("greet");
//Sign with the client operator private key to pay for the query and submit the query to a Hedera network
ContractFunctionResult contractCallResult = query.execute(client);
// Get the function value
String message = contractCallResult.getString(0);
System.out.println("contract message: " + message);
//v2.0.0//Contract call query
const query = new ContractCallQuery()
.setContractId(contractId)
.setGas(600)
.setFunction("greet");
//Sign with the client operator private key to pay for the query and submit the query to a Hedera network
const contractCallResult = await query.execute(client);
// Get the function value
const message = contractCallResult.getString(0);
console.log("contract message: " + message);Last updated