Truffle compile compilation failed

0 votes

I am getting error while compiling a smart contract:

sudo truffle compile

Compiling ./contracts/Hello-world.sol...

Compiling ./contracts/Migrations.sol...

/home/user/truffle/contracts/Hello-world.sol:1:1: 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.15;


Compilation failed. See above.

Truffle v5.0.2 (core: 5.0.2)

Node v8.10.0
Jan 17, 2019 in Blockchain by slayer
• 29,300 points

1 answer to this question.

0 votes

This is a version compatibility problem. In your code you have mentioned to use version 0.4.15 but the compiler version installed in your system is 0.5.0 (mentioned in the error). There are two solutions to this.

  1. Use the current version pragma solidity 0.5.0; 
  2. Use pragma solidity ^0.4.15;


pragma solidity 0.4.15; is mentioned to use the exact version whereas pragma solidity ^0.4.15; is mentioned to use the mentioned version and the above versions

answered Jan 17, 2019 by Omkar
• 69,150 points

^0.4.15 means >= 0.4.15 and < 0.5.0

More specifically, 

^0.4.15 means >=0.4.15 and <= latest version

Related Questions In Blockchain

0 votes
2 answers

Truffle compile: Cant find module error

You can install babel-register and try again. ...READ MORE

answered Feb 19, 2019 in Blockchain by Loki
0 votes
1 answer

Truffle compile shows DeclarationError: Undeclared identifier.

Hey. You might have missed declaring the "myaddress"  ...READ MORE

answered Dec 4, 2018 in Blockchain by Omkar
• 69,150 points
0 votes
1 answer
–1 vote
1 answer

Not able to compile truffle project

Hi. If you look at the error ...READ MORE

answered Jan 17, 2019 in Blockchain by Omkar
• 69,150 points
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,830 points
0 votes
1 answer

Solidity geth: Error encountered during contract execution [Bad instruction]

recipes is a dynamic storage array. You need ...READ MORE

answered Oct 15, 2018 in Blockchain by Omkar
• 69,150 points
0 votes
2 answers

Why is network already up to date while trying to deploy a contract on truffle?

I guess you have ganache running already ...READ MORE

answered Apr 23, 2018 in Blockchain by Shashank
• 10,400 points
0 votes
1 answer

How can I deploy a HelloWorld contract on my testrpc network?

The problem lies in the command: truffle migrate Your truffle migrate command ...READ MORE

answered Apr 27, 2018 in Blockchain by Perry
• 17,100 points

edited Aug 10, 2018 by Omkar 1,344 views
0 votes
1 answer

Truffle Compile failing, ParserError: Expected token LParen got Identifier function

Your parentheses are mismatched. pragma solidity ^0.4.17; import "truffle/Assert.sol"; import ...READ MORE

answered Oct 9, 2018 in Blockchain by Omkar
• 69,150 points
+4 votes
2 answers