1

I am trying to compile the following contract on Remix IDE (online): pragma solidity ^0.4.24;

contract ProofofExistence{
   event ProofCreated(
      uint256  indexed id,
      bytes32 documentHash);//an event can be listened by any client

   address public owner;//getters are already generated for public variables
   mapping  (uint => bytes32) hashesById;

   modifier onlyOwner() {
      require(msg.sender == owner);
      _;
   }

   modifier noHashExistsYet(uint256 id) {
      require(hashesById[id] == "");
      _;
   }//The modifeir can be prepended to any function

   constructor() public {//constructor is executed when the contract s created 
      owner = msg.sender;
   }

   function notarizeHash(uint256 id, bytes32 documentHash) onlyOwner noHashExistsYet(id) public{
      hashesById[id] = documentHash;
      emit ProofCreated(id, documentHash);//Proof created event is emited to the block chain
   }//The core function of this contract allows its owner
   //to confirm a document id with a certain content

   function doesProofExist(uint256 id, bytes32 documentHash) public view returns (bool) {
      return hashesById[id] == documentHash;
   }//view/constant functions are read-only and do not cost gas
}

I am getting the following compilation error message:

browser/ProofofExistence.sol:1:1: SyntaxError: Source file requires different compiler version (current compiler is 0.5.1+commit.c8a2cb62.Emscripten.clang - note that nightly builds are considered to be strictly less than the released version pragma solidity ^0.4.24; ^----------------------^

Can somebody please guide me how to fix this problem?

Zulfi.

1

You need to change remix compiler version to 0.4.24

enter image description here

  • 1
    browser/ProofofExistence.sol:1:1: SyntaxError: Source file requires different compiler version (current compiler is 0.5.1+commit.c8a2cb62.Emscripten.clang - note that nightly builds are considered to be strictly less than the released version pragma solidity ^0.4.24+commit.e67f0147; ^--------------------------------------^ – zak100 Dec 15 '18 at 1:18
  • 1
    Please guide me how to change the compiler version in online Remix IDE. I have used following pragma directive: pragma solidity ^0.4.24+commit.e67f0147; but I am getting above error. – zak100 Dec 15 '18 at 1:20

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.