I am stuck between "out of gas" and "exceed block gas limit" when try deploying my contract onto Test RPC in my mocha test file.

I wonder

  1. Can I manually increase block gas limit on my test RPC (I am not using truffle)? how?
  2. Is this gonna be a problem when I deploy to main net?

Below is my test.js

const assert = require('assert');
const ganache = require('ganache-cli');
const Web3 = require('web3');
const web3 = new Web3(ganache.provider({"total_accounts":20, "debug":true}));

const compiledFactory = require('../build/SyndicateFactory.json');

let accounts;
let factory;
let syndciateAddress;
let syndicate;
let DeployICO1;
let ICO1;
let exchangeAddress;

beforeEach(async()=> {
    accounts = await web3.eth.getAccounts();
    syndicateFeeTimes1000 = 10;
    exchangeAddress = accounts[5];

    factory = await new web3.eth.Contract(JSON.parse(compiledFactory.interface)).deploy({data: compiledFactory.bytecode}).send({from:accounts[0], gas:'7000000'});


1 Answer 1


When you create your web3 instance you can pass gasLimit option to ganache provider:

const web3 = new Web3(ganache.provider({
    "gasLimit": 8000000

Currently gas limit in mainnet is 8M gas. If your contract uses more than that it will fail to deploy on mainnet. You can split into several contracts or use libraries.


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.