Truffle Compile Errors

How can I ensure that my IDE compiles for my solidity version every time. I seem to have many errors trying to do this and know it must be easier than I’m making it. Here is the error I have and my public Github link to my code:

https://github.com/aelkins3/DEX201

Compiling your contracts...
===========================
Error: Could not find a compiler version matching >=0.6.0 < 0.8.0. Please ensure you are specifying a valid version, constraint or build in the truffle config. Run `truffle compile --list` to see available versions.
    at VersionRange.getSatisfyingVersionFromCache (/usr/local/lib/node_modules/truffle/build/webpack:/packages/compile-solidity/dist/compilerSupplier/loadingStrategies/VersionRange.js:134:1)
    at VersionRange.<anonymous> (/usr/local/lib/node_modules/truffle/build/webpack:/packages/compile-solidity/dist/compilerSupplier/loadingStrategies/VersionRange.js:54:1)
    at Generator.throw (<anonymous>)
    at rejected (/usr/local/lib/node_modules/truffle/build/webpack:/packages/compile-solidity/dist/compilerSupplier/loadingStrategies/VersionRange.js:6:42)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
truffle(develop)> 
1 Like

you need to change the compiler version in your truffle-config.js file to match the version of solidity that your using in your contract. if you naviate to ypur truffle config file and scroll to the bottowm you will see this

compilers: {
    solc: {
      version: "0.8.10",    // 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"
      // }
    }
  },

see the version there. change this to the version in your contracts. your better off just setting it at 0.8.0 or something

1 Like

Ok, it looks like they need to match all of the OpenZeppelin contracts too. Remaining consistent throughout the entire project.