case 1. When my contract estimate gas is 72,75,790 by web3.eth.estimateGas method in my private blockchain.It works fine and contract deployed.
case 2. My Contract estimate gas is 50,000,000.and passing gas amount as 50,000,000 + 300,000. but unable to store contract in ethereum-blockchain using web3 api in nodejs Error: The contract code couldn't be stored, please check your gas amount.
Note:- I have already setted gasLimit is 200,000,000,000(i.e more than estimated gas) at the time of private blockchain creation.

  • provide your contract code
    – Badr Bellaj
    Commented Dec 28, 2016 at 12:33
  • @BadrBellaj it's about 350 plus line of code. do you need?
    – Imroz
    Commented Dec 28, 2016 at 13:02
  • only the payable functions
    – Badr Bellaj
    Commented Dec 28, 2016 at 13:09
  • @BadrBellaj I have not added any payable function in my contract. because i am not sending ether to contract.
    – Imroz
    Commented Dec 28, 2016 at 13:32
  • 2
    share the contract code in a gist
    – Badr Bellaj
    Commented Dec 28, 2016 at 13:47

1 Answer 1


The contract may just be too large, period.

In the most recent hardfork, a maximum contract size was implemented. Chances are that your contract--if it uses 50,000,000 gas--is far beyond that. If this is indeed the case, the contract will always fail to be created.

It's possible that you can set your private blockchain to have a higher maximum code size, assuming you're only using Parity. (See the end of the discussion in the link.) But if that's not possible, or you want to use the public chain, you'll just have to shrink the contract.

Here's some suggestions.

  1. Use libraries. This will split your contract into multiple subcontracts, but more importantly, it can make your code a lot more elegant and easier to read.
  2. Stay off the strings. Unlike nearly every other language, strings are expensive in solidity, and the less you use them, the better off you'll be. For example, you return strings from functions and in logs. Rather than that, you can return an error code (or different kinds of events) and have the frontend display it in human-readable form.
  3. I also see places where you could use enums instead of text strings.
  4. For every event, you have now as one of the arguments. This isn't really necessary--if you have access to an event in web3.js, you can also know what block it's from, and then what time it happened, too.

Hope this helps!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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