Solidity ethereum Language

From rbachwiki
Revision as of 20:55, 10 February 2018 by Bacchas (talk | contribs)
Jump to navigation Jump to search

Solidity Contract

pragma solidity ^0.4.0;

contract HelloWorldContract{
    string word = "Hello";
    address public issuer;
    // constructor
    function HelloWorldContract(){
        issuer = msg.sender;
    }
    
    modifier ifIssuer(){
        if(issuer != msg.sender){
            throw;
        }
        else{
            _; // this means continue 
        }
    }
    
    // creating a getter 
    // the keyword constant is used to make it a getter without it the contract would 
    // use gas and would be a setter
    function getWord() constant returns(string){
        return word;
    }
    
    // setter 
    function setWord(string newWord) returns(string){
        word = newWord;
        return word;
    }
    
}