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,050 points
354 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 by Omkar
• 67,200 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
78 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
• 67,200 points
50 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
• 67,200 points
140 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
107 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
• 67,200 points
54 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
• 17,010 points

edited Aug 10, 2018 by Omkar 411 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
• 67,200 points
182 views
+4 votes
2 answers