Truffle – Resolve ‘Error: Exceeds Block Gas Limit’ in Truffle Console

gas

I successfully deployed my contract on ropsten network. But when I try to call any functions in the contract, I got Error: exceeds block gas limit error.
I set gas limit 4700000 in my truffle.js file. How can I check and change the gas limit on truffle console? What is wrong with it?

Best Answer

I just figured out. I needed to run truffle console --network ropsten. gas limit 4700000 is working fine, but gas limit in my development network is set by 471000. (it is too much..I think) Anyway, I should have run truffle console with proper with proper network setting.

module.exports = {
  // See <http://truffleframework.com/docs/advanced/configuration>
  // to customize your Truffle configuration!
    migrations_directory: "./migrations",
    networks: {
        development: {
         host: "127.0.0.1",
         network_id: "*", // Match any network id
         gas: 4710000
    },
    ropsten: {
      host: "localhost",
      port: 1233,
      network_id: "3",
      gas: 4700000,
      gasPrice: 22000000000,
      from: "0xea28ea60ca23156377c6a97241aa29613456424f"
    },
    mainnet: {
      host: "localhost",
      network_id: "1",
      gas: 4324530, 
      gasPrice: 2000000000   
    }
}      
};