truffle – How to Fix Invalid EVM Version Requested & Error: Truffle Is Currently Using Solc 0.5.0

truffle

I'm starting to learn solidity with Dapp University guide on youtube, and as soon as 20th minute of this guide I'm running into problem with Truffle compiling.

I cloned this repository:
git clone -b starter-code https://github.com/dappuniversity/defi_tutorial ./
And this is YT link to this tutorial:
https://www.youtube.com/watch?v=CgXQC4dbGUE

Truffle config on this guide looks like this:

require('babel-register');
require('babel-polyfill');

module.exports = {
  networks: {
    development: {
      host: "127.0.0.1",
      port: 7545,
      network_id: "*" // Match any network id
    },
  },
  contracts_directory: './src/contracts/',
  contracts_build_directory: './src/abis/',
  compilers: {
    solc: {
      optimizer: {
        enabled: true,
        runs: 200
      },
      evmVersion: "petersburg"
    }
  }
}

And at this point in the guide, compiling succeeds, but I get an error:

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

So I went to Truffle documentation, I found that I can specify solc version in the config, so I added versionfield, and my config looks now like this:

// ...
compilers: {
    solc: {
      version: "0.5.0",
      optimizer: {
        enabled: true,
        runs: 200
      },
      evmVersion: "petersburg"
    }
  }
// ...

And again my compiling failed, with another error but this time with evmVersion:

Invalid EVM version requested.

Compilation failed. See above.
Truffle v5.1.39 (core: 5.1.39)
Node v16.9.1

Now I've change EVM version from "petersburg" to "byzantium" and I'm getting to another Compilation Faild with error:
Error: Truffle is currently using solc 0.5.0, but one or more of your contracts specify "pragma solidity ^0.5.0

Can someone provide me some knowledge how to deal with this error?

Best Answer

changing the EVM version from "petersburg" to "byzantium" and the compiler version to "0.5.0" worked for me.