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 in Blockchain by slayer
• 29,040 points
274 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
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 by Omkar
• 65,820 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 in Blockchain by Loki
37 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
• 65,820 points
38 views
0 votes
1 answer
0 votes
1 answer

Not able to compile truffle project

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

answered Jan 17 in Blockchain by Omkar
• 65,820 points
106 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
61 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
• 65,820 points
28 views
0 votes
2 answers
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
• 16,450 points

edited Aug 10, 2018 by Omkar 350 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
• 65,820 points
127 views
+4 votes
2 answers

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.