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.

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

See original GitHub issue

New issue 😃 This exemple: http://truffleframework.com/tutorials/robust-smart-contracts-with-openzeppelin No --testnet flag.

/home/testnet/go-ethereum-1.7.3/build/bin/geth --rpc --port 30304 --rpcport 8599 --networkid 3 --rpcapi db,eth,web3,net,admin,miner,personal --cache 1024 --maxpeers 25 --datadir /home/testnet/.ethereum --keystore /home/testnet/.ethereum/keystore --nousb --mine --minerthreads 1 --unlock 0xC1320531dF2612B85e6FEDFd4d6358ed711bbe66 --password /home/testnet/pass

cat genesis.json

{
  "config": {
    "chainId": 3,
    "homesteadBlock": 0,
    "eip155Block": 0,
    "eip158Block": 0
  },
  "nonce": "0x0000000000000033",
  "timestamp": "0x0",
  "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "gasLimit": "0x8000000",
  "difficulty": "0x100",
  "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "coinbase": "0x3333333333333333333333333333333333333333",
  "alloc": {}
}

cat truffle.js

module.exports = {
  // See <http://truffleframework.com/docs/advanced/configuration>
  // for more about customizing your Truffle configuration!
  networks: {
    development: {
      host: "127.0.0.1",
      port: 8599,
      network_id: 3,
      from: "0xC1320531dF2612B85e6FEDFd4d6358ed711bbe66",
      gas: 1000000,
      gasPrice: 10000000000,
    }
  }
};

result:

testnet@e3:~/oz-workspace$ truffle compile
testnet@e3:~/oz-workspace$ truffle migrate
Using network 'development'.

Running migration: 1_initial_migration.js
  Deploying Migrations...
  ... 0x2281a6116824b0941b5b12c6086d0845bdfd8be82873f2c32ee05ca6f88a0e35
  Migrations: 0x2092eb6cc176d5313335fd2adb06af98473d0d51
Saving successful migration to network...
  ... 0x779632747cd77cde0461e1e6bd442d5882d12450fe552227e9c96561403326ed
Saving artifacts...
Running migration: 2_deploy_contracts.js
  Deploying TutorialToken...
  ... 0x2eb61ab6893bbafea70a43a96dde844751279356ad49aad468f6e5f10808f582
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 XMLHttpRequest.request.onreadystatechange (/usr/local/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/httpprovider.js:128:1)
    at XMLHttpRequestEventTarget.dispatchEvent (/usr/local/lib/node_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:64:1)
    at XMLHttpRequest._setReadyState (/usr/local/lib/node_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:354:1)
    at XMLHttpRequest._onHttpResponseEnd (/usr/local/lib/node_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:509:1)
    at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:469:1)

Whi? Operating System: Ubuntu 16.04.3 LTS Truffle v4.0.6 (core: 4.0.6) Solidity v0.4.19 (solc-js) Ethereum client: go-ethereum-1.7.3 node version: v9.4.0 npm version: 5.6.0

Issue Analytics

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

github_iconTop GitHub Comments

9reactions
sweatyccommented, Aug 2, 2018

I had this error too and it turns out nothing to do with gas, it’s my ERC721 token contract didn’t implement the contractor of the ERC721Token correctly…

I flatten the contracts and put it into remix, it did show me the problem.

A correct error should be shown in truffle!

8reactions
cgeweckecommented, Feb 28, 2018

@freshonline Ok everything looks good as far as I can see. Could you try changing the gas amount in your truffle.js to 2000000 as below?

module.exports = {
  // See <http://truffleframework.com/docs/advanced/configuration>
  // for more about customizing your Truffle configuration!
  networks: {
    development: {
      host: "127.0.0.1",
      port: 8599,
      network_id: 3,
      from: "0xC1320531dF2612B85e6FEDFd4d6358ed711bbe66",
      gas: 2000000,   // <--- Twice as much
      gasPrice: 10000000000,
    }
  }
};

Read more comments on GitHub >

github_iconTop Results From Across the Web

The contract code couldn't be stored, please check your gas ...
In your 2_deploy_contracts.js file, change the gas price defaults to a higher number, i.e.: // 2_deploy_contracts.js const MyContract ...
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
Ive sucessfully created web3 object using truffle-hdwallet-provider and I sucessfullly get the account list but the deployment to the testnet ...
Read more >
abort(Error: The contract code couldn't be stored, please ...
The error is presented to implement a contract through the abi and ... The contract code couldn't be stored, please check your gas...
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