Skip to Content
Ethereum Cookbook
book

Ethereum Cookbook

by Manoj P R
August 2018
Intermediate to advanced
404 pages
11h 19m
English
Packt Publishing
Content preview from Ethereum Cookbook

How to do it...

  1. Here is our simple smart contract example:
pragma solidity ^0.4.21;contract HelloWorld {        string public greeting = "Hello World";        function changeGreeting(string _newGreeting) public {        greeting = _newGreeting;    }    }
  1. Use solc or other alternatives to compile the contract into ABI and bytecode:
$ solc --optimize --bin --abi HelloWorld.sol
  1. Start the geth node with the web3 console:
$ geth console 2>> ./geth.log
  1. Make sure that you have enough Ether for deployment. If you are using a private network, make sure to start mining before performing any transactions.
  2. Unlock the account from which you want to deploy the contract:
> web3.personal.unlockAccount(web3.eth.accounts[0], "<password>");
  1. Create an object of the contract ...
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

Building Ethereum Dapps

Building Ethereum Dapps

Roberto Infante
Ethereum For Dummies

Ethereum For Dummies

Michael G. Solomon

Publisher Resources

ISBN: 9781789133998Supplemental Content