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.

web3.eth.accounts

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

personal.newAccount()

Enter your password and re-confirm it.




Comments

Popular posts from this blog

ionic2 cordova build android - Unable resolve gradle 2.2.3

A quick tutorial for OWASP ZAP tool for beginners

OpenCover code coverage for .Net Core