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 '19 at 8:41
-
use 0.5.0 or at least 0.4.24 man – Majd TL Jun 22 '19 at 8:55
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.
But first, Change the compiler version in the remix to version:0.5.8+commit.23d335f2.Emscripten.clang
Use the older layout of remix if its showing new layout.
Changes I made:
- I added newer version of solidity as
pragma solidity >=0.4.0 <0.6.0;
- I added semi-colon after some instructions
- I added keyword
public
for the function, you can also make them private - 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. - 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.