OUT_OF_ENERGY error when deploying contract on Tron-IDE

I coded a smart contract on tron-ide that is able to compile and deploy on the Javascript VM successfully. However, when I try to deploy the contract using the injected provider (Nile network) I keep getting a OUT_OF_ENERGY error.
Here are the details of my deployment transaction:

  • Fee Limit was set to the default 400000000 (400 TRX from my understanding)
  • TronLink said resources used was to be 18K bandwidth.
  • My TronLink wallet used to deploy the contract had
    • 39K energy
    • 19K bandwidth
    • 2K TRX
  • Create Smart Contract Transaction failed and depleted ALL of my energy and bandwidth as well as 383 TRX

After looking further into the transaction details,
383 TRX was burned as a result of insufficient energy and the transaction failed because my fee limit was set to 400 TRX when there was still more TRX that needed to be burned.

As it turns out, the deployment of my contract needed 952,380 energy (which equates to about 7434 TRX)…
Which is why I kept running of out of energy.

From my understanding, the maximum fee limit is only 1000 TRX (?)

How can I solve this issue? I there something that I’m missing that makes my contract require so much energy? Or do I really just have to set my fee limit to 7500 TRX and collect enough TRX for that deployment?

I included some screenshots below that I thought would be helpful. If you require any further clarification please let me know. I really appreciate any help on the matter. Thank you so much!

8 Likes

@constantinpricope201 @WindsOfChange92

4 Likes

I now see that it could be because my user fee percentage is set to 100. Is that what is causing the problem? Are they any other considerations?

Is my high energy consumption still a concern that can be resolved without deleting code to losing functionality in my smart contract?

2 Likes

(Q1) Can you simplify your smart contract code Reduce unnecessary loops, functions, or storage variables.

(Q2) How much storage does your contract utilize Consider minimizing the data stored on-chain.

2 Likes

This is really serious and this needs a good solution. Anyone to help out?

4 Likes

Out of my knowledge. So the developers in our most would get to see this and help out

3 Likes

Hi @Okorie Thank you for your response.

  1. I think I can shave off some lines of code to make it simpler but it is still insignificant to the the rest of the code I have and still requires a lot of energy.
  2. Here are the things I’m storing on chain. I feel that most of these variables are necessary but I guess I could take 2-3 things off chain. Do you think that would allow me to deploy my contract now?

uint256[4] public categorySupplies; // store the supplies of each category of tickets
uint256[4] public categoryPrices; // store the prices for the different category of tickets (calculated in SUN not TRX)
uint256 public saleStartTime; // store the start time for ticket sales
uint256 public mintLimitPerAddress;

uint256[4] private categoryStartIds; // Starting tokenId for each category
uint256[4] private mintedPerCategory; // Tracks the number of tokens minted in each category
string[4] private categoryURIs = [
    "ipfs://bafkreidozrz3dpxpev3asoz4epyyfd4m3stwixod3fgzolkzvr7sehlk5i",
    "ipfs://bafkreidkxxxt4loonkicv6mhmjzjiglkrdti5hu4xljnp4suefpdb6txgu",
    "ipfs://bafkreid7rdeaoaew4uuafaq3sklgzjup2h2u7mdtxn7ey3jzdgnxdyphka",
    "ipfs://bafkreiab3ypgbks25fkm3tspkfiadyehnvdvmxf5rtxacjf7ptjw6ifgoq"
];

bool public eventCanceled = false; // Indicates if the event has been canceled
mapping(uint256 => bool) public ticketInsurance; // Tracks which tickets have insurance
mapping(uint256 => uint256) private insuranceCostPaid; // Tracks the insurance cost paid for each ticket
mapping(uint256 => uint256) private ticketPricePaid; // Tracks the price paid for each ticket for insurance purposes

mapping(uint256 => bool) private _redeemedTickets; // store the redeemed tickets so that they cannot be redeemed again
mapping(address => uint256) public mintCountPerAddress;
4 Likes

If your issue is still out of energy simply increase the fee_limit.

You could use this nice tools to compute Tron Station

Simply put you restricted the contract not to use more than 400 TRX and due to that it failed.

5 Likes

@gregtanym
Maximum fee limit is 1500 TRX.
Please update the Fee Limit from 400 to 1500 TRX.

Let me know if you still face issue after updating this gas limit.

3 Likes

Hello, I’m facing same issue, but my one is consuming about 14 k bandwidth and approx 1000k energy every time i deploy and similarly to above it consumes the trx, allthough I’m putting energy limit for that too, is constantly giving out same error… anyone who has deployed a contract on chain

p.s. im deploying an contract factory.

2 Likes

@elluminaZK are you still stuck on this issue ? If yes , Is it public repo so i can try out and help you to fix this issue.

1 Like

Its fixed now ,i will let you know for further help, also
it was jus fee limit error…

2 Likes

Hello, my account is maliciously authorized and I can’t call the permission. Can you solve it or help me contact me?

1 Like

Do you have like a repo I could look into

1 Like

Internal transactions also cost energy and these may not be so obvious in the initial transaction and the revert will happen when there is not enough energy for the latter internal operations meaning you will loose all the energy spent on the previous operations

3 Likes

Hey sorry for reply in this topic but I have this problem

Is first time I see this problem.

A friend did this transaction
the hash is this

8af52440a64ca6abac16d1838267a991f9f2bdac6f5a30c19bfefe0fbf9582f8

( before he did one more bigger amount )

the amount from ledger shown as pending until yesterday ( but not shown today in ledger history ( pc or mobile both ) . As you see in transfer status said " Failed -Transaction Revert> "

the amount never reverted back to ledger device.

Anyone has the same problem again ? I search in google etc happened to a lot of users but I don’t find answers.

From ledger they told me 24 hours after the failed ( because our trx address has not full energy and bandwith to complete this transfer of this amount ) or reverted note normally need the funds to be back to my wallet. ( they suggest to stake some tron coins via official staking trx for have more energy and bandwith which we did it yesterday, then after failed transaction. )

Any suggestion will be helpful.

1 Like

You’re getting an OUT_OF_ENERGY error because your contract needs more energy than you initially allowed (400 TRX).
It actually needs around 7434 TRX! To fix this, you can also do this

  • Increase the energy limit to 7500 TRX

  • Make your contract more energy-efficient by reviewing the code

  • Try deploying on a different network with lower energy needs

Did you know you can use special features in Tron to reduce energy usage, Like using ‘constant’ or ‘view’ functions.
These can help make your contract more energy-efficient.

rent 32k energy only for 1.6 TRX
visit cryptoswifts

hello guys can anyone help me out here I’m getting error while sending out it says

Out of energy
Your energy payment ratio is 100% as the contract creator holds insufficient energy

Hello Davidj, welcome to the Tron forum. By that warning, it means that you are responsible for the 100% energy needed to execute your transaction and at the same time, you have insufficient energy/trx to burn for your transaction to be successful. Deposit enough trx to your wallet to be able to complete your transaction. Renting energy reduce the transaction fee you need to pay to execute your transaction