Call a smart contract function
Method
Type
Description
Requirement
//Create the transaction
ContractCreateTransaction transaction = new ContractExecuteTransaction()
.setContractId(newContractId)
.setGas(100_000_000)
.setFunction("set_message", new ContractFunctionParameters()
.addString("hello from hedera again!"))
//Sign with the client operator private key to pay for the transaction and submit the query to a Hedera network
TransactionResponse txResponse = transaction.execute(client);
//Request the receipt of the transaction
TransactionReceipt receipt = txResponse.getReceipt(client);
//Get the transaction consensus status
Status transactionStatus = receipt.status;
System.out.println("The transaction consensus status is " +transactionStatus);
//v2.0.0//Create the transaction
const transaction = new ContractExecuteTransaction()
.setContractId(newContractId)
.setGas(100_000_000)
.setFunction("set_message", new ContractFunctionParameters()
.addString("hello from hedera again!"))
//Sign with the client operator private key to pay for the transaction and submit the query to a Hedera network
const txResponse = await transaction.execute(client);
//Request the receipt of the transaction
const receipt = await txResponse.getReceipt(client);
//Get the transaction consensus status
const transactionStatus = receipt.status;
console.log("The transaction consensus status is " +transactionStatus);
//v2.0.0Last updated