EstimateEnergy

Estimate the energy required for the successful execution of smart contract transactions or deploying a contract

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

Note:

  • This API is closed by default. To enable this interface, both the vm.estimateEnergy and vm.supportConstant configuration items must be activated simultaneously in the node configuration file.
  • estimateEnergy performs an estimation only; it does not generate an on-chain transaction or alter the current node's status. The energy_required field in its returned value represents the estimated energy amount, allowing the transaction's fee_limit to be set as energy_required X energy unit price.
  • While the triggerconstantcontract API is sufficient for estimating the energy consumption of calling most on-chain smart contracts (e.g., USDD, BTT, TUSD), the estimateEnergy API offers greater accuracy when estimating the energy consumption for a small number of special contracts. Furthermore, the energy estimate returned by estimateEnergy is guaranteed to be sufficient for setting the transaction's fee_limit.
  • Parameter encoding and decoding: Parameter and return value encoding and decoding

Returns

FieldTypeDescription
resultObjectResult of the contract execution simulation.
result.resultboolWhether the estimation was successful.
result.coderesponse_code(enum)Response code indicating the error type. (Returned only on failure)
result.messagestringResponse message describing the error details. (Returned only on failure)
energy_requiredint64Estimated Energy required to execute the transaction.
Body Params
string

Transaction initiator address.(Format: Base58 or Hex).
Example: TZ4UXDV5ZhNW7fb2AMSbgfAEZ7hWsnYS2g

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
Defaults to true

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

Responses

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