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!

5 Likes

@constantinpricope201 @WindsOfChange92

2 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?

1 Like

(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.

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

2 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.

4 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.

@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.

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

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

Do you have like a repo I could look into