question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: The contract code couldn't be stored, please check your gas amount.

See original GitHub issue
  • I’ve asked for help in the Truffle Gitter before filing this issue.

Issue

I followed tutorial to create a very simple token and crowdsale contract with Truffle and zeppelin-solidity. I managed to successfully migrate to Ganache locally, but when I tried to migrate to ropsten I encountered the following error:

Error encountered, bailing. Network state unknown. Review successful transactions manually.
Error: The contract code couldn't be stored, please check your gas amount.
    at Object.callback (/usr/local/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/contract.js:147:1)
    at /usr/local/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/method.js:142:1
    at /usr/local/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/requestmanager.js:89:1
    at /usr/local/lib/node_modules/truffle/build/webpack:/~/truffle-migrate/index.js:225:1
    at /usr/local/lib/node_modules/truffle/build/webpack:/~/truffle-provider/wrapper.js:134:1
    at Web3ProviderEngine._inspectResponseForNewBlock (/Users/wenwenchen/Documents/TestCrowdsale/node_modules/web3-provider-engine/index.js:231:12)
    at /Users/wenwenchen/Documents/TestCrowdsale/node_modules/web3-provider-engine/index.js:131:14
    at /Users/wenwenchen/Documents/TestCrowdsale/node_modules/async/dist/async.js:473:16
    at replenish (/Users/wenwenchen/Documents/TestCrowdsale/node_modules/async/dist/async.js:993:25)
    at iterateeCallback (/Users/wenwenchen/Documents/TestCrowdsale/node_modules/async/dist/async.js:983:17)
...

I researched online and some answers said that this happened because of trying to deploy abstract contract to the testnet. But it seems this is not the case for me.

Steps to Reproduce

  1. Clone this repository https://github.com/chenwenwen11/TestCrowdsale.git
  2. terminal run: npm install -g truffle
  3. cd to the TestCrowdsale
  4. terminal run: npm install zeppelin-solidity
  5. terminal run: npm install truffle-hdwallet-provider
  6. terminal run: truffle compile
  7. terminal run: truffle migrate --network ropsten

Expected Behavior

Contracts are successfully migrated to Ropsten testnet

Actual Results

screen shot 2018-04-15 at 9 11 04 pm

Environment

  • Operating System: macOS High Sierra
  • Ethereum client: web3
  • Truffle version (truffle version): v4.1.3
  • node version (node --version): v9.8.0
  • npm version (npm --version): 5.6.0
  • solidity version: v0.4.19
  • zeppelin-solidity version: 1.7.0
  • Ganache version: 1.0.2

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

5reactions
cgeweckecommented, Apr 16, 2018

@chenwenwen11 It looks like you are using a Zeppelin contract called TimedCrowdsale which has a constructor that checks to make sure the crowdsale start time value is greater than the chain value now.

function TimedCrowdsale(uint256 _openingTime, uint256 _closingTime) public {
    require(_openingTime >= now);
    require(_closingTime >= _openingTime);

    openingTime = _openingTime;
    closingTime = _closingTime;

In your migrations you are setting startTime to the current system time. When the contract executes now is later than startTime causing the transaction to fail. Could you try adding some spare time to the line below in your migrations and see if that works?

const startTime = Math.round((new Date(Date.now()).getTime())/1000); // <--- Too soon! 
const endTime = startTime + (86400 * 2); // 30 days;
0reactions
tomcbeancommented, Apr 19, 2018

@chenwenwen11 Etherscan doesn’t automatically recognize an ERC20 compliant contract. You need to transfer some token to another address first.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The contract code couldn't be stored, please check your gas ...
when deployed. will issue error: The contract code couldn't be stored, please check your gas amount. solution is to implement the function.
Read more >
The contract code couldn't be stored, please check your gas ...
The error "Error: The contract code couldn't be stored, please check your gas amount." shows up when deploying Crowdsale contract on Ropsten/Rinkeby. #984....
Read more >
"The contract code couldn't be stored, please check your gas ...
Hi, 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...
Read more >
The contract code couldn't be stored, please check your gas limit
EDIT: I tried using Remix and it deployed successfully but when trying with truffle-hdwallet-provider it gives error: The contract code couldn't ...
Read more >
abort(Error: The contract code couldn't be stored, please ...
The error is: RuntimeError: abort(Error: The contract code couldn't be stored, please check your gas limit.). Build with -s ASSERTIONS= ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found