0

I am trying to deploy a crowdsale contract which is build upon openzeppelin while deploying it on geth --dev and ganache it gets deployed perfectly but whenever I am trying to deploy the contract on the testnet I am getting following error.

1_deploy.js
===========
Deploying Token Crowdsale:
        Rate                    : 1
        Wallet                  : 0xDc6234d567eBA03B465f519596E679A8d3959935
        Opening Time            : 1539087204
        Closing Time            : 1539238404
        Cap                     : 4000000000000000
        Individual Min Cap      : 1000
        Goal                    : 800000000000000
        Token Address           : 0x3FEc09Fab0dbb7EdaDbD4a4c06908a3Eb846308f
        Token Wallet            : 0xDc6234d567eBA03B465f519596E679A8d3959935

   Deploying 'TokenCrowdsale'
   --------------------------
   > transaction hash:    0xb2f48b6418021476827c8aeeb51762927c319dc74cd10ffaaa8482f06e3dae5c
Error:  *** Deployment Failed ***

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

    at /home/paradox/.config/yarn/global/node_modules/truffle/build/webpack:/packages/truffle-deployer/src/deployment.js:361:1
    at process._tickCallback (internal/process/next_tick.js:68:7)

I am passing 8000000 as the gas amount, any leads would be appreciated.

SourceCode

1

Ropsten has lower gas limit - around 4.7M and you can't set it yourself, since it's a public testnet. Gas limit value that you put in your settings can't override the blockchain's gas limit. You can try Rinkeby - it has 7693375, check the number at the top of the stats page: https://www.rinkeby.io/#stats

Check this related question: Is there a reason Ropsten doesn't have the same block gas limit as mainnet?

I tried running your deploy with Ganache v6.1.8, default gas limit 6721975, but it didn't even deploy the token:

truffle migrate --reset --network development
Using network 'development'.

Running migration: 1_deploy.js
Deploying Token:
        Name            : Sportist
        Symbol          : S
        Decimals        : 6
        Cap             : 10000000000000000
  Deploying Token...
  ... undefined
Error encountered, bailing. Network state unknown. Review successful transactions manually.
Error: Exceeds block gas limit

You don't have to inherit every conract in OpenZeppelin's collection, your crowdsale contract is clearly too big:

contract TokenCrowdsale is AllowanceCrowdsale, RefundableCrowdsale, IndividuallyCappedCrowdsale, StagedCrowdsale

Nevertheless, when I put the default value, 6700000, which is, by no coinscidence, less than Ganache's block gas limit, both transactions passed.

Try putting a value less than your target blockchain's limit.

  • But according to truffle the gas used is just 2824348 which is less then the limit – Paradox Oct 9 '18 at 13:24
  • And what does truffle report on successful deploys to the local environment? – Utgarda Oct 9 '18 at 13:29
  • It would just display the addresses – Paradox Oct 9 '18 at 13:35
  • Well, you can check the actual transaction cost in ganache, UI or CLI. – Utgarda Oct 9 '18 at 13:43
  • Ganache=> Gas usage: 2824284 – Paradox Oct 9 '18 at 13:53

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.