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!
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.
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;
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
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
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. )
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.
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