0

I have a contract pragma solidity 0.6.12 version that imports several 0.6.12 version contracts and one pragma solidity 0.8.0.

My truffle-config:

compilers: {
    solc: {
       version: "^0.6.12 <=0.8.0",
        },
      },

This configuration throws an error when compiling:

Error: Truffle is currently using solc ^0.6.12 <=0.8.0, but one or more of your contracts specify "pragma solidity ^0.7.0"

How can I correctly import multiple contracts with multiple versions imports ?

3
  • Did you try replacing this ^0.6.12 <=0.8.0 with 0.7.0?
    – Icarus23
    Oct 24, 2021 at 9:38
  • @Icarus23 Yes and it throws "Truffle is currently using solc ^0.7.0, but one or more of your contracts specify "pragma solidity ^0.6.0".
    – user78827
    Oct 29, 2021 at 17:02
  • As far as I've seen from your replies, it means that you have to go through your contracts(it usually shows what contract it is in the terminal after you compile your project) and manually replace the version of that specific contract with the version you're using(which is 0.7.0). Apparently you are using different truffle solc versions for multiple contracts.
    – Icarus23
    Oct 29, 2021 at 20:23

3 Answers 3

0

Go in your truffle-config.js and modify the lines with the version version

...
 // Configure your compilers
  compilers: {
    solc: {
      version: "^0.6.12",    // Fetch exact version from solc-bin (default: truffle's version)
    }
  },
...
1
  • 1
    Already tried, it doesn't work. Throws the same error with different versions
    – user78827
    Oct 27, 2021 at 22:38
0

This worked for me:

compilers: {
  solc: {
    version: "pragma",
  },
}
-1

For your contract, have you used ^0.6.12? That should allow you to interact with any other versions above the one you intend to use.

1
  • 1
    I've already tried this but it will throw the same error with according versions
    – user78827
    Oct 27, 2021 at 22:38

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.