2

I use pragma solidity 0.4.24 on the smart contract, but when running the truffle compile command, an error appears like this:

===========================
> Compiling ./contracts/ImageRegister.sol
> Compiling ./contracts/Migrations.sol

/Users/adobe/Downloads/an_drive/contracts/ImageRegister.sol:1:1: ParserError: Source file requires different compiler version (current compiler is 0.5.16+commit.9c3226ce.Emscripten.clang - note that nightly builds are considered to be strictly less than the released version
pragma solidity 0.4.24;
^---------------------^
,/Users/adobe/Downloads/an_drive/contracts/Migrations.sol:1:1: ParserError: Source file requires different compiler version (current compiler is 0.5.16+commit.9c3226ce.Emscripten.clang - note that nightly builds are considered to be strictly less than the released version
pragma solidity 0.4.24;
^---------------------^

Error: Truffle is currently using solc 0.5.16, but one or more of your contracts specify "pragma solidity 0.4.24".
Please update your truffle config or pragma statement(s).
(See https://trufflesuite.com/docs/truffle/reference/configuration#compiler-configuration for information on
configuring Truffle to use a specific solc compiler version.)

Compilation failed. See above.
Truffle v5.3.3 (core: 5.3.3)
Node v12.17.0

I'm very confused about how to solve this

1

By https://www.trufflesuite.com/docs/truffle/reference/configuration says, set the compile version in truffle.js

 module.exports = {
  compilers: {
    solc: {
      version: <string>, // A version or constraint - Ex. "^0.5.0"
                         // Can also be set to "native" to use a native solc
      }
    }
}
1
  • Thankyou @smart contract_research_Rookie Apr 28 '21 at 1:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.