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?


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: "",
         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   
  • happy to know you've solved your problem, don't forget to accept your own answer
    – Badr Bellaj
    Jul 15 '18 at 5:52

I faced a similar problem and found a solution somewhere in the truffle github issues.

Wherever you pass your byte code to be deployed after compilation with solc, add a '0x' in front of it

That is, pass '0x' + bytecode.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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