Switch branches/tags
Nothing to show
Find file Copy path
360f81b Jun 12, 2017
2 contributors

Users who have contributed to this file

@dkullmann @fivedogit
43 lines (34 sloc) 1.5 KB
The following is an extremely basic example of a solidity contract.
It takes a string upon creation and then repeats it when greet() is called.
contract Greeter // The contract definition. A constructor of the same name will be automatically called on contract creation.
address creator; // At first, an empty "address"-type variable of the name "creator". Will be set in the constructor.
string greeting; // At first, an empty "string"-type variable of the name "greeting". Will be set in constructor and can be changed.
function Greeter(string _greeting) public // The constructor. It accepts a string input and saves it to the contract's "greeting" variable.
creator = msg.sender;
greeting = _greeting;
function greet() constant returns (string)
return greeting;
function getBlockNumber() constant returns (uint) // this doesn't have anything to do with the act of greeting
{ // just demonstrating return of some global variable
return block.number;
function setGreeting(string _newgreeting)
greeting = _newgreeting;
Standard kill() function to recover funds
function kill()
if (msg.sender == creator) // only allow this action if the account sending the signal is the creator
suicide(creator); // kills this contract and sends remaining funds back to creator