Ethereum : Create a greeter

In the ethereum's greeter sample, if you following it here,  it requires user to save the following code into a file, say greetcontract.js

contract Mortal { /* Define variable owner of the type address */ address owner; /* This function is executed at initialization and sets the owner of the contract */ function Mortal() { owner = msg.sender; } /* Function to recover the funds on the contract */ function kill() { if (msg.sender == owner) selfdestruct(owner); } } contract Greeter is Mortal { /* Define variable greeting of the type string */ string greeting; /* This runs when the contract is executed */ function Greeter(string _greeting) public { greeting = _greeting; } /* Main function */ function greet() constant returns (string) { return greeting; } }

To run it, you fire up your geth console.

Then type the followings :-

loadScript("greetcontract.js")      // case sensitive

if you get an error saying  invalid account try checking if you have associated an account.


If you get empty array[], create one by using the following command :-


Enter your password and re-confirm it.


Popular posts from this blog

A quick tutorial for OWASP ZAP tool for beginners

Owin component : Modifying owin response