2
pragma solidity ^0.4.19;

contract Stratus {

    string public greeting;
    address public owner;

    event GreetingChanged (string oldGreeting, string newGreeting)

    function Stratus(string _greeting) {
        greeting = _greeting;
        owner = msg.sender;
    }

    function setGreeting (string _greeting){
        require(owner == msg.sender)
        GreetingChanged(greeting,_greeting)
        greeting = _greeting
        }
    }
  • please edit your question and show us what error says – Zeeshan Ahmad Khalil Jun 22 at 8:41
  • use 0.5.0 or at least 0.4.24 man – Majd TL Jun 22 at 8:55
1

The version of solidity you are using is very old. The latest stable compiler for solidity is version:0.5.8+commit.23d335f2.Emscripten.clang. You can use the following code to remove the above error. But you have to use the latest version of solidity.

pragma solidity >=0.4.0 <0.6.0;

contract Stratus {

    string public greeting;
    address public owner;

    event GreetingChanged (string oldGreeting, string newGreeting);

    constructor(string memory _greeting) public {
        greeting = _greeting;
        owner = msg.sender;
    }

    function setGreeting (string memory _greeting) public {
        require(owner == msg.sender);
        emit GreetingChanged(greeting,_greeting);
        greeting = _greeting;
        }
    }

If you want to get ABI and Bytecode of above contract then you can get it by pasting the code in Remix.

enter image description here

But first, Change the compiler version in the remix to version:0.5.8+commit.23d335f2.Emscripten.clang

enter image description here

Use the older layout of remix if its showing new layout.

enter image description here

Changes I made:

  1. I added newer version of solidity as pragma solidity >=0.4.0 <0.6.0;
  2. I added semi-colon after some instructions
  3. I added keyword public for the function, you can also make them private
  4. I added keyword memory as if we are creating an array as a parameter of a function then we have to reserve memory for it first.
  5. We have to use emit in latest solidity if we are calling a function which is not returning a value.

You can also check the syntax of latest stable version of the solidity.

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.