The Blockchain- Dapps Daily — March 30, 2019 — Different Solidity version in truffle
I tried to use my old smart contract in solidity and trying migrate it with truffle but it failed because the solidity version is different from that I installed.
SyntaxError: Source file requires different compiler version (current compiler is 0.5.0+commit.1d4f565a.Emscripten.clang - note that nightly builds are considered to be strictly less than the released version
pragma solidity ^0.4.17;
Solution : specify solc version in truffle configuration file.
Truffle Suite | Documentation | Truffle | Configuration
Your configuration file is called truffle-config.js and is located at the root of your project directory. This file is…
Solidity compiler settings. Supports optimizer settings for
You may specify…
- any solc-js version listed at solc-bin. Specify the one you want and Truffle will get it for you.
- a natively compiled solc binary (you’ll need to install this yourself, links to help below).
- a dockerized solc from one of images published here.
- a path to a locally available solc
Truffle config example:
How to check truffle and solc version ?
> truffle version