view or pure modifier) of a contract for contract data query; or Invoke the non-readonly function of a contract for predicting whether the transaction can be successfully executed and estimating the energy consumption; or estimate the energy consumption of contract deployment.
This method will use 30 Compute Units.
Note:
- TriggerConstantContract operation will not generate an on-chain transaction, nor will it change the status of the current node.
- For estimating energy
- To estimate the energy consumption of contract deployment just by passing the bytecode of contract through the
datafield - To estimate energy consumption of Contract Calls by calling non-read-only methods of contracts
- To estimate the energy consumption of contract deployment just by passing the bytecode of contract through the
- When using triggerconstantcontract to estimate energy consumption, the
energy_usedfield in the returned value is the energy consumption. Therefore, thefee_limitof the transaction can be set toenergy_used x energy unit price. - Parameter encoding and decoding example: Parameter and return value encoding and decoding
Parameters
owner_address- String - Owner address that triggers the contract. If visible=true, use base58check format, otherwise use hex format. For constant call you can use the all-zero address.contract_address- String - Smart contract address. If visible=true, use base58check format, otherwise use hex formatfunction_selector- String - Function call, must not be left blankparameter- String - Parameter encoding needs to be in accordance with the ABI rules, the rules are more complicated, users can use the ethers library to encode,For details, please refer to the document-Guide-Smart Contract-Best Practice-Parameter Encoding and Decoding.data- String - The data for interacting with smart contracts, including the contract function and parameters. You can choose to use this field, or you can choose to use function_selector and parameter for contract interaction. When both of data and function_selector exist, function_selector is preferredcall_value- int64 - Amount of TRX transferred to the contract with this transaction, the unit is sun. This field may be used when estimating energy consumptioncall_token_value- int64 - Amount of TRC10 token transferred with this transactiontoken_id- int64 - TRC10 token idvisible- boolean - Optional. Specifies whether the address is in Base58 format (default: false)