"The contract code couldn't be stored, please check your gas limit."


I’m trying to deploy a contract (let’s say, a bit big) and I’m getting a problem
“ContractName deployment failed with error: The contract code couldn’t be stored, please check your gas limit.”

Is the gas limit something that I can set with ZOS or is it the fact that the contract is too big?


1 Like

@obernardovieira that error is the one we get from the node (ganache, geth, or parity) when trying to deploy your contract. From personal experience, it is seldom related to gas limit, but rather to a precondition on the contract. Perhaps you have a constructor (which you should change into an initializer) in your contract that has a require causing issues?

I think a good test would be to try to deploy the contract manually using plain web3 on ganache, and see if you get the same error, even after setting a very high gas limit for the transaction.

1 Like

Well, I decided to remove the content of two methods (not the methods, just what was inside) and try again and I was able to deploy it. Tried by deleting only one and I was still able to deploy it. So I decided that, since I couldn’t delete any of the methods, maybe I would be able to improve something and that would allow me to deploy the contracts. Well, I did it. Simplifying a few things a making cleaner worked.

I guess the reason is really because it’s too big. But now that you said it, I’m thinking about some extra functionality I had.

The thing is that, we (I’m talking in name of my team) actually have the contracts fully tested (even coverage) and we never had problems. Although I know it was expensive, I never though it would be a limitation.

The thing is that block gas limit varies between networks, so while a test on one of them may work, it may fail on another. For instance, at the time of this writing, the limit is 8M in Ropsten but 7M Rinkeby.

1 Like

I’m only interested in Ropsten and mainnet. I see that they have the same block gas limit.
But in this case the problem is related to the contract being so big, which needs to be solved. Thanks again.


A post was split to a new topic: “The contract code couldn’t be stored, please check your gas limit.”