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
- Clone this repository https://github.com/chenwenwen11/TestCrowdsale.git
- terminal run: npm install -g truffle
- cd to the TestCrowdsale
- terminal run: npm install zeppelin-solidity
- terminal run: npm install truffle-hdwallet-provider
- terminal run: truffle compile
- terminal run: truffle migrate --network ropsten
Expected Behavior
Contracts are successfully migrated to Ropsten testnet
Actual Results

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:
- Created 5 years ago
- Comments:9 (6 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@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 valuenow
.In your migrations you are setting
startTime
to the current system time. When the contract executesnow
is later thanstartTime
causing the transaction to fail. Could you try adding some spare time to the line below in your migrations and see if that works?@chenwenwen11 Etherscan doesn’t automatically recognize an ERC20 compliant contract. You need to transfer some token to another address first.