Skip to Content
Mastering Blockchain - Second Edition
book

Mastering Blockchain - Second Edition

by Ankur Daharwal, Imran Bashir, Pranav Burnwal
March 2018
Beginner to intermediate
656 pages
20h 9m
English
Packt Publishing
Content preview from Mastering Blockchain - Second Edition

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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering Blockchain - Third Edition

Mastering Blockchain - Third Edition

Imran Bashir
Mastering Blockchain

Mastering Blockchain

Lorne Lantz, Daniel Cawrey
Mastering Ethereum

Mastering Ethereum

Andreas M. Antonopoulos, Gavin Wood

Publisher Resources

ISBN: 9781788839044Supplemental Content