TriggerConstantContract

Simulate contract calls without broadcasting a transaction to query contract data, test whether calls to non-read-only functions can execute successfully, or estimate Energy consumption for contract calls and deployments.

Recent Requests
Log in to see full request history
TimeStatusUser Agent
Retrieving recent requests…
LoadingLoading…

triggerconstantcontract simulates contract execution without broadcasting a transaction. This endpoint can simulate calls to read-only functions, such as those marked as view or pure, as well as calls to non-read-only functions that may modify on-chain state.

Any state changes produced during the simulation are not committed to the blockchain. Calling this endpoint does not consume any Bandwidth or Energy from the account, so fee_limit is not required in the request.

Execution time limit

Simulated execution is subject to a TVM execution time limit. Starting with GreatVoyage-v4.8.2, node operators can configure this limit separately with vm.constantCallTimeoutMs. If vm.constantCallTimeoutMs is greater than 0, the node uses the configured value; otherwise, it uses the value of the getMaxCpuTimeOfOneTx chain parameter. Both values are measured in milliseconds. If execution exceeds the limit, the simulation fails.

To adjust this limit, see Configuring the simulation timeout.

Understanding simulation results

The execution context used for this simulation includes the state view available to the node when it processes the request and the TVM rules in effect at that time. Because the node continuously processes blocks and pending transactions and may run other constant calls concurrently, a transaction submitted later may execute on-chain in a different execution context, and its result may differ from the result of this simulation. This is an expected characteristic of point-in-time simulation.

The execution context used for a simulation is primarily affected by the following:

  • Processing blocks: A node executes the transactions in a block sequentially, updating accounts, contract storage, resources, and chain parameters as it proceeds. A simulation initiated during this process uses the data visible to the node at that moment.
  • Processing pending transactions: /wallet provides a view of the latest state. While a node validates or replays pending transactions, this view may include local state updates and may continue to change as transactions are included in blocks or new blocks arrive.
  • Other constant calls: Calls made through /wallet and /walletsolidity may use different proposal activation states and TVM rules. When calls with different execution contexts run concurrently, in rare cases a simulation may reflect the proposal activation state and TVM rules being applied by the node at that moment.

constant_result, energy_used, logs, and internal_transactions are produced by the current simulation. If the simulation reads different state or applies different TVM rules, the contract may follow a different execution path, and the values returned in these fields may also differ. The top-level result reports the status of the API request, while transaction.ret[0].ret reports the TVM execution result of the simulation.

Choose the endpoint based on the state view you need: /wallet provides the latest state, whereas /walletsolidity provides a slightly older, solidified state. When preparing a transaction, treat the simulation results as a reference and leave an appropriate margin in fee_limit to account for changes in Energy consumption as state changes. After broadcasting the transaction, rely on the transaction receipt for the actual on-chain execution result.


Related resources

Body Params
string
required

Transaction initiator address. (Format: Base58 or Hex)

string

Contract address. (Format: Base58 or Hex).
Example: TG3XXyExBkPp9nzdajDZsozEu4BkaSJozs

string

Function selector.
Example: transfer(address,uint256)

string

ABI-encoded function parameters (Hex String).
Example: 000000000000000000000000a614f803b6fd780986a42c78ec9c7f77e6ded13c

string

This field transmits the necessary data for smart contract interaction, including the function being called and its parameters. You may choose to use the data field, which contains the complete ABI-encoded information, or use the function_selector and parameter fields separately. Note that if both data and function_selector are present, the system will prioritize using the function_selector and parameter fields for the contract interaction.

int64

Amount of TRX transferred into the contract. (Unit: sun)

int64

Amount of TRC-10 token transferred into the contract.

int64

TRC-10 token id

boolean

Optional. Set to true to format addresses in Base58; set to false for hex format. (Default: false)

Responses

Language
URL
LoadingLoading…
Response
Click Try It! to start a request and see the response here! Or choose an example:
application/json