Difference between revisions of "Solidity ethereum Language"

From rbachwiki
Jump to navigation Jump to search
(Created page with "== Solidity Contract == pragma solidity ^0.4.0; contract HelloWorldContract{ string word = "Hello"; address public issuer; // constructor function Hello...")
 
Line 1: Line 1:
== Solidity Contract ==
== Solidity Contract ==


pragma solidity ^0.4.0;
pragma solidity ^0.4.0;
 
  contract HelloWorldContract{
  contract HelloWorldContract{
     string word = "Hello";
     string word = "Hello";

Revision as of 20:55, 10 February 2018

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;
    }
    
}