post
https://api.shasta.trongrid.io/wallet/estimateenergy
Estimate the energy required for the successful execution of smart contract transactions or deploying a contract
Note:
- This API is closed by default. To enable this interface, both the
vm.estimateEnergyandvm.supportConstantconfiguration items must be activated simultaneously in the node configuration file. estimateEnergyperforms an estimation only; it does not generate an on-chain transaction or alter the current node's status. Theenergy_requiredfield in its returned value represents the estimated energy amount, allowing the transaction'sfee_limitto be set asenergy_requiredXenergy unit price.- While the
triggerconstantcontractAPI is sufficient for estimating the energy consumption of calling most on-chain smart contracts (e.g., USDD, BTT, TUSD), theestimateEnergyAPI offers greater accuracy when estimating the energy consumption for a small number of special contracts. Furthermore, the energy estimate returned byestimateEnergyis guaranteed to be sufficient for setting the transaction'sfee_limit. - Parameter encoding and decoding: Parameter and return value encoding and decoding
Returns
| Field | Type | Description |
|---|---|---|
| result | Object | Result of the contract execution simulation. |
| result.result | bool | Whether the estimation was successful. |
| result.code | response_code(enum) | Response code indicating the error type. (Returned only on failure) |
| result.message | string | Response message describing the error details. (Returned only on failure) |
| energy_required | int64 | Estimated Energy required to execute the transaction. |