0

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?

4
  • Try to comment out the "evmVersion" and compile your project or change it to antoher version like "byzantium" for ex.
    – Icarus23
    Nov 7, 2021 at 15:43
  • I have updated this post, I've change to "byzantium" and I'm getting other error. Commenting out "evmVersion" gives the same result. And without version: "0.5.0" error is the same but saying about other solc version on truffle: Error: Truffle is currently using solc 0.5.16
    – BlackH3art
    Nov 7, 2021 at 17:06
  • If you right-click inside a solidity contract, you will have a couple of options to chose from including "Change global compile version". Once you click on it, you will see a list of solidity versions. Click on the one you need(0.5.0) and it should work.
    – Icarus23
    Nov 7, 2021 at 21:40
  • Probably it worked.. I dont't know yet, cause I'm running into next errors, but this time: ParserError: Expected ';' but got '}' or ParserError: Expected ';' but got end of source depends on where I put ";" as I don't know much about syntax yet, etc. So I guess it's for different thread.
    – BlackH3art
    Nov 7, 2021 at 23:08

3 Answers 3

0

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

0

You need to download the compiler version needed, or change contract solidity version.

1
  • How can I know which compiler version is needed in this case? You mean update Truffle?
    – BlackH3art
    Nov 7, 2021 at 17:10
0

Change the config at truffle-config.js to your contract solidity version

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.