This is the error i get.

ParserError: Expected pragma, import directive or contract/interface/library definition.

This is my Solidity contract code.

pragma solidity ^0.4.6

contract Inbox

    string public message;

    function Inbox(string intialMessage){
        message = intialMessage;
    function setMessage(string newMessage){
        message = newMessage;


I cannot figure out why this parse error is occurring. I tried changing the solidity version as well. Didn't work out.

  • 2
    Do not post screenshots of code, it's hard for others to test. even the error message :) Commented May 1, 2018 at 13:08

3 Answers 3


You have missed the semicolon in the first line. It should be,

pragma solidity ^0.4.6;

I tried the code in Remix IDE and it compiles after the above correction.


As other answers also have pointed, You just have missed the ; at the end of the very first line.


pragma keyword in solidity has a ; at the end of the line. you've forgotten it. It should be like,

pragma solidity ^0.4.6;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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