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 open this interface, the two configuration items
vm.estimateEnergy
andvm.supportConstant
must be enabled in the node configuration file at the same time. - The
wallet/triggerconstantcontract
API can be used to estimate the energy consumption value of calling most smart contracts on the chain, such as USDD, USDT, USDC, TUSD, etc. Meanwhile, Compared to the existingwallet/triggerconstantcontract
API,wallet/estimateEnergy
API will be more accurate in estimating the energy consumption of calling a small number of special contract. But for FullNode, enabling thewallet/estimateEnergy
API is optional. So please pay attention that when developers callwallet/estimateEnergy
, if the error message (this node does not support estimate energy) shows when calling the new API, it is recommended to continue using thewallet/triggerconstantcontract
API to estimate energy consumption. estimateenergy
will not generate an on-chain transaction, nor will it change the status of the current node.- The
energy_required
field in the returned value is the energy estimated amount. Therefore, thefee_limit
of the transaction can be set toenergy_required x energy unit price
. - Parameter encoding and decoding example: Parameter and return value encoding and decoding
Returns
Field | Type | Description |
---|---|---|
result | Return | Run result |
result.result | bool | Is the estimate successful |
result.code | response_code(enum) | response code, an enum type |
result.message | string | Result message |
energy_required | int64 | Estimated energy to run the contract |