Contract deployment

A simple contract can be deployed using geth and interacted with using Web3 via the command-line interface that geth provides (console or attach). The following are the steps to achieve that. As an example, the following source code will be used:

pragma solidity ^0.4.0;contract valueChecker{    uint price=10;    event valueEvent(bool returnValue);    function Matcher (uint8 x) public returns (bool)    {        if (x>=price)        {            valueEvent(true);            return true;        }    }} 
  1. Run geth client using the following command:
$ ./geth --datadir ~/etherprivate/ --networkid 786 --rpc -rpcapi 'web3,eth,debug,personal'  --rpccorsdomain '*'  
  1. You will also want to open another terminal and run the following command. The geth console should already be running by ...

Get Mastering Blockchain - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.