11

Error: Truffle is currently using solc 0.5.16, but one or more of your contracts specify “pragma solidity ^0.8.0”

Here is a photo of the error - https://gyazo.com/2f5ea2f50cc1d4ef5eea2f21d0e04fe7

All my contracts are using the ^0.8.0 pragma. My truffle-config is also using the same version as you can see here - https://gyazo.com/1ec8b28ca48902c091004f8659cf678d

Please help. Thank you very much.

Yilmaz
  • 35,338
  • 10
  • 157
  • 202
Palm
  • 360
  • 2
  • 17

5 Answers5

11

Omit the "^". Not version:"^0.8.0".

compilers: {
       solc: {
           version: "0.8.0"  
       }
}
Pang
  • 9,564
  • 146
  • 81
  • 122
Yilmaz
  • 35,338
  • 10
  • 157
  • 202
3

Uncomment this line from truffle-config.js:

compilers: {
  solc: {
    version: "0.8.10",  // <-- this one
    .
    .
    ...
Pang
  • 9,564
  • 146
  • 81
  • 122
drjorgepolanco
  • 7,479
  • 5
  • 46
  • 47
2

@Yilmaz is correct that the version needs to be modified. Change the truffle-config.js file to the correct compiler version. Make sure that you have a version set. I had the same error because the version was not set. If your file looks like this:

compilers: {
  solc: {
    // version: "0.5.1",    // Fetch exact version from solc-bin (default: truffle's version)
    // docker: true,        // Use "0.5.1" you've installed locally with docker (default: false)
    // settings: {          // See the solidity docs for advice about optimization and evmVersion
    //  optimizer: {
    //    enabled: false,
    //    runs: 200
    //  },
    //  evmVersion: "Byzantium"
    // }
}

Change it to something like this:

compilers: {
  solc: {
    version: "^0.8.0"
}
Pang
  • 9,564
  • 146
  • 81
  • 122
1

If you're using windows change your "truffle.js" file name to "truffle.config.js" and inside your truffle config file add this line of code if it doesn't exist

  compilers: {
solc: {
  version: "0.8.0" 

make sure don't use "^" in version:"0.8.0"

}
  }
Iheb Saad
  • 327
  • 2
  • 6
0

Put the compilers option just like what is in the below module.exports;

module.exports = {
  compilers: {
    solc: {
      version: "0.8.6"
    }
  },
}
Tyler2P
  • 2,324
  • 26
  • 22
  • 31