Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VM Exception while processing transaction: out of gas #44

Open
dreammonkey opened this issue Jan 24, 2022 · 3 comments
Open

VM Exception while processing transaction: out of gas #44

dreammonkey opened this issue Jan 24, 2022 · 3 comments

Comments

@dreammonkey
Copy link

Hi,

In the kickstart project test script I ran into an issue where ganache was refusing to deploy the CampaignFactory.

VM Exception while processing transaction: out of gas

It turned out I had to augment the gasLimit to 10 million when deploying:

factory = await new web3.eth.Contract(compiledFactory.abi)
  .deploy({ data: compiledFactory.evm.bytecode.object })
  .send({
    from: accounts.kickstarter,
    gas: "10000000",
  });

After that the following error appeared:

n: Exceeds block gas limit

Apparently I also needed to raise the global gasLimit in the ganache provider:

const web3 = new Web3(
  ganache.provider({
    gasLimit: 10000000,
  })
);

This resolved the issue and successfully deployed the factory on the test network.
But I have yet to find the reason why this was needed ?
And more importantly what would be the consequences when deploying this on the MainNet ?

Are there any thoughts on this ?

Best Regards,
Diederik

@amateur-dev
Copy link

The issue happened cause the default gas limit per block in local ganache chain was lower than 10 million.

As of the writing this reply, the gas limit on Mainnet is a minimum of 15 million. It is expandable, as per requirement, with the maximum being 30 million.

@dreammonkey
Copy link
Author

Thanks for your answer, I tested some more and I was able to run the test and deploy the contract to the Ropsten Network using a gas price of 3 million. Removing the need to overwrite the ganache default block gas limit.

This makes me wonder: is this a normal process to go through when developing/deploying a contract ? Should one estimate in advance what would be an adequate gas price for a contract ?

Clearly larger contracts and contracts with a larger computational cost consume more gas, but how can we properly check the gas that contracts are likely to consume. I think this is not really addressed during the course...

@amateur-dev
Copy link

amateur-dev commented Jan 25, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants