I have the following contract (truffle + zeppelin):

contract SampleCrowdsale is CappedCrowdsale, RefundableCrowdsale {

    uint256 public cirCap;

    function SampleCrowdsale(uint256 _startTime, uint256 _endTime, uint256 _rate, uint256 _goal, uint256 _cap, address _wallet) public
    Crowdsale(_startTime, _endTime, _rate, _wallet)
        //As goal needs to be met for a successful crowdsale
        //the value needs to less or equal than a cap which is limit for accepted funds
        require(_goal <= _cap);
        cirCap = getTokenAmount(_cap);

    function createTokenContract() internal returns (MintableToken) {
        return new SampleCrowdsaleToken();

    function airdropCoins(address beneficiary, uint256 cirAmount) onlyOwner public {
        uint256 authorizedCoinsRemaining = cirCap - token.totalSupply();
        require(cirAmount > 0);
        require(cirAmount <= authorizedCoinsRemaining); // <== This fails to deploy !!!
        token.mint(beneficiary, cirAmount);


Any ideas why the "require(cirAmount <= authorizedCoinsRemaining);" makes the contract to fail with the very cryptic message:

Error encountered, bailing. Network state unknown. Review successful transactions manually.
Error: The contract code couldn't be stored, please check your gas amount

Try setting a gas limit in your truffle config.

For example in truffle.js:

module.exports = {
  networks: {
    development: {
      host: "",
      port: 7545,
      gas: 6721975,
      network_id: 5777

The gas limit is the default limit provided by ganache or however you're running your local test network.

  • I've changed the limit on geth but not on the truffle.js. Thanks – Nick De Greek Feb 12 '18 at 19:49

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.