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,370 points
3,741 views

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;

Note: 

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,220 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
3,021 views
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,220 points
2,462 views
0 votes
1 answer

truffle compile shows error: TypeError: Invalid type for argument in function call.

You are getting this error because you ...READ MORE

answered Dec 5, 2018 in Blockchain by Omkar
• 69,220 points
2,211 views
–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,220 points
1,814 views
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,790 points
1,923 views
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,220 points
1,464 views
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 24, 2018 in Blockchain by Shashank
• 10,400 points
4,566 views
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 2,845 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,220 points
2,496 views
+4 votes
2 answers
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP