In Truffle 4, I am performing the migration in truffle develop by using the migrate command in the console.

However it gives the error

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

How can the gas used be changed? I think it requires editing truffle.js? What is the name of the network created when using truffle develop which gives testrpc listening to port 9545?

  • I am suffering from something similar. I have compiled a new function in my contract and when I go to execute MetaMask jumps up with 0 Units in its gas limit. Unlike the other function of my dApp which will automatically fill the field.
    – EwokHugz
    Commented Jan 18, 2018 at 6:49

1 Answer 1


You can change the gas provided in truffle.js. Also, have in mind that truffle 4 has the optimizer turned off by default, so you'll probably want to turn it on if the contract still doesn't get deployed.

module.exports = {
  networks: {
    development: {
      host: "localhost",
      port: 8545,
      network_id: "*", // Match any network id
      gas: 4500000
  solc: {
    optimizer: {
      enabled: true,
      runs: 200
  • If using the testrpc provided by truffle develop, will you change the port to 9545? for the gas value to take effect?
    – Nyxynyx
    Commented Nov 17, 2017 at 17:40
  • All the information is also provided here. I haven't encountered the solc part that you mention in your answer, but it looks very interesting so I'll have a look. You forgot to mention that the default for gas is 4712388, and you also forgot to mention the gasPrice option (with its default being 100000000000). Commented Jan 18, 2018 at 9:02
  • One more thing - I found that "localhost" can lead truffle to fail on some operating systems (namely Windows), when the network is disconnected. In order to resolve this problem, you can simply replace it with "". Commented Jan 18, 2018 at 9:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.