Estimate Energy Fails

I am using tronql in order to run /estimateEnergy API and sometimes the estimation fails with the error Contract exec fails even though if I do the transaction the transaction is successful.

Anyone encounter this issue?


This answer was generated by (Creators of TRON NRG)

Yes, this is a known issue. The /estimateEnergy API is designed to simulate the execution of a smart contract and estimate the energy consumption. However, it’s not always 100% accurate due to the complexity of smart contract execution.

The error “Contract exec fails” usually means that the simulation of the contract execution failed, but it doesn’t necessarily mean that the actual transaction will fail.

There could be several reasons for this discrepancy:

  1. The state of the blockchain at the time of the simulation might be different from the state at the time of the actual transaction.
  2. The /estimateEnergy API might not fully support all the features of the Tron Virtual Machine, leading to discrepancies between the simulation and the actual execution.
  3. There might be some randomness in the contract execution that leads to different outcomes in the simulation and the actual execution.

If the transaction is successful, you can ignore the error from the /estimateEnergy API. However, please note that the actual energy consumption might be different from the estimated value.

If you frequently encounter this issue and it affects your development, I would recommend using the /triggerConstantContract API for energy estimation as a workaround. This API is more stable but might be less accurate for some special contracts.


Thank you for the explanation. I believe something can be done to solve this. Some of uses these estimates to rent energy for our transactions.

My advice to all users to be on a safer side get more energy. Some needs 50k 100k 250k and others. Know the type of transaction you want to do and rent a little above what is needed.

1 Like

Not long ago I burned over 170 TRX in a single failed transaction while attempting to make swap between USDT/USDD on SunSwap. I have always wondered what the reason for this could be. Now I think it could be due to :

I’ve stopped using SunSwap since then. And I always make sure now that have enough energy and no available TRX in my wallet. I don’t mind losing my full energy and bandwidth in a failed transaction. But, I hate burning my TRX when we some great options to avoid it.

I hope that no one encounters this issue ever.

1 Like

This has been my fear bro, I feel your pain. Knowing that you will be charged energy and sue to some technical errors you loose such an amount of tron. Hope they do something about it

1 Like

I certainly hope so.

1 Like

I forgot to update the post meanwhile I found what the issue were. My estimation did not contain the call_value actually after a talk with @PorkyPork (JM team) he asked me some questions and I realised what is going on.

I love the solution offer by the NRG team I really think it is helpful. In this case to be honest it fails the TriggerConstantContract it is completely wrong in estimation do not use that. The estimateEnergy API it work perfectly we completed in the OnChainVision and the most amazing fact it is if the estimateEnergy fails then the transaction will fail so we do not allow it. Something similar I saw also on the if the transaction is going to fail they do not allow it(gives revert) compared to other dApp that allow the transaction and results in lost funds.

So things as @HODL mention do not really happen over the OnChainVision app because the estimation fails and we do not allow it.

You can check out app on Tron Nile as we fully support the testnet (including renting)


if the estimation fails and you want to continue with the transaction, I hope it will still go through

No. We did that on purpose, you have a button to open Discord to ask for details and explain what happened and when happened. So we would look at that as developeers because if the energy failed it means most likely that the transaction will fail.

We did that so over our app we won’t have problems as @HODL mention. If something pop up it is better to be check by us so that the user won’t lost his assets (TRX for burning)


Good good I didn’t know this. Thanks

PorkyPork is super smart. :laughing:

1 Like

Indeed he helped us a lot he even offered us some address factory and router addresses of a DEX over the TRON Nile network so we have now the possibility to swap on Tron Nile to test our infrastructure.

We found a lot of goodwill also with other projects like NRG and ERGON and TRONQL team and we looking to collaborate as much as possible on as many projects.

1 Like