Module com.hedera.hashgraph.sdk
Package com.hedera.hashgraph.sdk
Class MirrorNodeContractQuery<T extends MirrorNodeContractQuery<T>>
java.lang.Object
com.hedera.hashgraph.sdk.MirrorNodeContractQuery<T>
- Direct Known Subclasses:
MirrorNodeContractCallQuery,MirrorNodeContractEstimateGasQuery
MirrorNodeContractQuery returns a result from EVM execution such as cost-free execution of read-only smart contract
queries, gas estimation, and transient simulation of read-write operations.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected StringDoes transient simulation of read-write operations and returns the result in hexadecimal string format.(package private) static StringcreateJsonPayload(byte[] data, String senderAddress, String contractAddress, long gas, long gasPrice, long value, Long block, boolean estimate) protected longReturns gas estimation for the EVM executionbyte[]longlonglonggetValue()(package private) static StringparseContractCallResult(String responseBody) (package private) static longparseHexEstimateToLong(String responseBody) protected Tself()setBlockNumber(Long block) Sets the block number for the simulation of the contract call.setContractEvmAddress(String contractEvmAddress) Set the 20-byte EVM address of the contract to call.setContractId(ContractId contractId) Sets the contract instance to call.setFunction(String name) Sets the function name to call.setFunction(String name, ContractFunctionParameters params) Sets the function to call, and the parameters to pass to the function.setFunctionParameters(com.google.protobuf.ByteString functionParameters) Sets the function parameters as their raw bytes.setGasLimit(long gasLimit) Sets the gas limit for the contract call.setGasPrice(long gasPrice) Sets the gas price to be used for the contract call.Sets the sender of the transaction simulation.setSenderEvmAddress(String senderEvmAddress) Set the 20-byte EVM address of the sender.setValue(long value) Sets the amount of value (in tinybars or wei) to be sent to the contract in the transaction.toString()
-
Constructor Details
-
MirrorNodeContractQuery
public MirrorNodeContractQuery()
-
-
Method Details
-
self
-
getContractId
-
setContractId
Sets the contract instance to call.- Parameters:
contractId- The ContractId to be set- Returns:
this
-
getContractEvmAddress
-
setContractEvmAddress
Set the 20-byte EVM address of the contract to call.- Parameters:
contractEvmAddress-- Returns:
this
-
getSender
-
setSender
Sets the sender of the transaction simulation.- Parameters:
sender- The AccountId to be set- Returns:
this
-
getSenderEvmAddress
-
setSenderEvmAddress
Set the 20-byte EVM address of the sender.- Parameters:
senderEvmAddress-- Returns:
this
-
getCallData
public byte[] getCallData() -
setFunction
Sets the function to call, and the parameters to pass to the function.- Parameters:
name- The String to be set as the function nameparams- The function parameters to be set- Returns:
this
-
setFunction
Sets the function name to call.The function will be called with no parameters. Use
setFunction(String, ContractFunctionParameters)to call a function with parameters.- Parameters:
name- The String to be set as the function name- Returns:
this
-
setFunctionParameters
Sets the function parameters as their raw bytes.Use this instead of
setFunction(String, ContractFunctionParameters)if you have already pre-encoded a solidity function call.- Parameters:
functionParameters- The function parameters to be set- Returns:
this
-
getValue
public long getValue() -
setValue
Sets the amount of value (in tinybars or wei) to be sent to the contract in the transaction.Use this to specify an amount for a payable function call.
- Parameters:
value- the amount of value to send, in tinybars or wei- Returns:
this
-
getGasLimit
public long getGasLimit() -
setGasLimit
Sets the gas limit for the contract call.This specifies the maximum amount of gas that the transaction can consume.
- Parameters:
gasLimit- the maximum gas allowed for the transaction- Returns:
this
-
getGasPrice
public long getGasPrice() -
setGasPrice
Sets the gas price to be used for the contract call.This specifies the price of each unit of gas used in the transaction.
- Parameters:
gasPrice- the gas price, in tinybars or wei, for each unit of gas- Returns:
this
-
getBlockNumber
-
setBlockNumber
Sets the block number for the simulation of the contract call.The block number determines the context of the contract call simulation within the blockchain.
- Parameters:
block- the block number at which to simulate the contract call- Returns:
this
-
estimate
Returns gas estimation for the EVM execution- Parameters:
client-- Throws:
ExecutionExceptionInterruptedException
-
call
Does transient simulation of read-write operations and returns the result in hexadecimal string format. The result can be any solidity type.- Parameters:
client-- Throws:
ExecutionExceptionInterruptedException
-
createJsonPayload
-
parseContractCallResult
-
parseHexEstimateToLong
-
toString
-