I'm trying to deploy a contract into ethereum, but I keep getting "out of gas" error.

How can I know in advance how much ethers I need to deploy a contract?

  • 1
    Duplicate and answered here: ethereum.stackexchange.com/questions/799/… Apr 12 '17 at 11:42
  • Out of gas may be a manifestation of a constructor failure. If there are any required arguments or some other reason the constructor could fail or possibly invalid ByteCode, the error might bubble up and present as out of gas. Maybe post the source to see if someone can spot a problem. Apr 12 '17 at 12:00
  • It doesn't really answer my question, there is this spreadsheet in that answer that only mentions low level programming, how can I estimate my code based on that? Is there any tool that can pre calculate the cost or something?
    – Resten
    Apr 12 '17 at 12:00
  • @Rob there is no tool out there to calculate this?
    – Resten
    Apr 12 '17 at 12:01
  • 1
    @DakotaQuint What Tjaden said, or drop the source code into Remix and see what it estimates. Either will work. In any case, out-of-gas may be misleading. If there is a problem with the contract deployment then no amount of gas will suffice, so pointing this out for you. Not trying to confuse the issue. Apr 12 '17 at 13:20

One online tool (no syncing, no installing) is Remix a.k.a. Browser Solidity.


In screen shot below, a trivial contract called "Mortal" cost 319,273 gas to deploy.

enter image description here

Hope it helps.

  • But my contract includes other small contract, and other contracts that I have installed through npm. Looks like Remix doesn't useful in this case.
    – hqt
    Apr 28 '18 at 21:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.