2

I run migrate in the terminal, but it shows

Error: Truffle is currently using solc 0.5.8, but one or more of your contracts specify "pragma solidity ^0.4.27".

Please update your truffle config or pragma statement(s).

enter image description here

When I follow the error and update config it doesn't work. What should I do? Thanks.

2
  • 1
    The error is self explanatory.. your contracts are based on an earlier version of solidity. I would advise downgrading your solc compiler or setting it a different version ,
    – 0xsegfault
    Aug 25, 2019 at 20:59
  • there is no compiler version satisfying ^0.4.27 the latest 0.4.x compiler version is 0.4.26 and, btw, if you're using Ubuntu the config file should be named truffle.js Aug 27, 2019 at 14:01

2 Answers 2

2

Inside of the truffle-config.js you can update the solc version like so:

compilers: {
  solc: {
    version: "^0.8.0"
  }
}

Here is a full example:

module.exports = {
  networks: {
    development: {
      host: "127.0.0.1",
      port: 8545,
      network_id: "*" // Match any network id
    }
  },
  compilers: {
    solc: {
      version: "^0.8.0"
    }
  }
};
1
  • i put the right version in solc, but i'm still getting the same error Apr 8, 2022 at 22:59
0

On MacOS, change compiler settings in truffle-config.js. Also, make sure the pragma versions in your contracts are the same as in your config settings as you won't be able to run truffle compile successfully otherwise.

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.