2

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 :) – Achala Dissanayake May 1 '18 at 13:08
2

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.

2

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

2

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, privacy policy and cookie policy

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