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.
Omit the "^". Not version:"^0.8.0"
compilers: {
solc: {
version: "0.8.0"
}
}
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"
}
}
@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"
}
Uncomment this line from truffle-config.js
compilers: {
solc: {
version: "0.8.10", // <-- this one
.
.
...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.