Installation
sudo apt-get install software-properties-common
sudo add-apt-repository -y ppa:ethereum/ethereum
sudo apt-get update
sudo apt-get install ethereum
sudo apt-get install solc
Genesis
{
"nonce": ​"0xdeadbeefdeadbeef"​,
"timestamp": ​"0x00"​,
"parentHash": ​"0x0000000000000000000000000000000000000000000000000000000000000000"​,
"extraData": ​"0x686f727365"​,
"gasLimit": ​"0x08000000"​,
"difficulty": ​"0x0400"​,
"mixhash": ​"0x0000000000000000000000000000000000000000000000000000000000000000"​,
"coinbase": ​"0x3333333333333333333333333333333333333333"​,
"alloc": { },
"config": {
"homesteadBlock": ​0​,
"eip155Block": ​0​,
"eip158Block": ​0
}
}
Understanding Genesis
Create Node
geth --datadir ethdir/vijay init vijay.json
Open Geth without console
geth --datadir ethdir/vijay/ --ethash.dagdir ethdag/ --networkid 1234
Open Geth with console
geth --datadir ethdir/vijay/ --ethash.dagdir ethdag/ --networkid 1234 console
2>console.log
Node Info
admin.nodeInfo
List All Accounts
personal.listAccounts
eth.accounts
Check Block number
eth.blockNumber
Check block details
eth.getBlock()
Create an Account
personal.newAccount()
Start Mining
miner.start(1)
Stop Mining
miner.stop()
Unlock Account
personal.unlockAccount(eth.accounts[0])
Check Account Balance
eth.getBalance(eth.accounts[0])
Create More Accounts
Attach More Console to a Node
geth attach ipc:ethdir/vijay/geth.ipc
1. Check node info on both terminal
2. Check accounts and balances
Create More Nodes
1. Create More nodes with above commands
2. Check Node Info
3. Check accounts
4. Check block number
5. Node should be on same network
Add Peers
admin.addPeer("enode")
1. Check Node Info
2. Check Accounts
3. Check Block Number
Check Peers
admin.peers
1. Start Mining
2. Check block
3. Check miner of the block
4. Check block details
5. Check Account and balance
6. Stop mining
7. Create account on node 2
8. Repeat from 1-3
Check total Balance of the miner
eth.getBalance(eth.getBlock(eth.blockNumber).miner)
Transfer funds between them (without or without mining)
Check you have two account on node
Unlock Account before transferring funds
personal.sendTransaction({"from":eth.accounts[0], "to":eth.accounts[1], value:
web3.toWei(1.23,"ether")}, "vijay")
Will give you transaction hash
Check pending Transaction
eth.pendingTransactions
Check balance of both account
Smart Contract
● Open local solidity browser
● Create a contract in IDE
● Start full loaded node
geth --datadir ethdir/vijay/ --ethash.dagdir ethdag/ --networkid 1234 --rpc
--rpcport 8545 --rpccorsdomain "*" console 2>console.log
● Connect to node using web3 provider
● Unlock your Account before deployment
Deploy Smart Contract
Create Contract with required parameter
Check block number
Check pending transaction
Start mining
Contract will be deployed will get an address of the account
DApps
Smart Contract on Geth Console
Greeter.solc 
pragma solidity ^0.4.2; 
contract mortal { 
address owner; 
function mortal() { owner = msg.sender; } 
function kill() { if (msg.sender == owner) suicide(owner); } 
} 
contract greeter is mortal {   
string greeting;   
function greeter(string _greeting) public { 
  greeting = _greeting; 
} 
function newGreeting(string _greeting) public { 
  Modified(greeting, _greeting, greeting, _greeting); 
  greeting = _greeting; 
}   
function greet() constant returns (string) { 
  return greeting; 
}   
event Modified( 
  string indexed oldGreetingIdx, string indexed newGreetingIdx, 
  string oldGreeting, string newGreeting); 
} 
 
 
Compiling the Solidity use solc 
Deploying it on geth console using below setup 
 
var contractInfo = 
JSON.parse('{"contract_name":"Greeter","abi":[{"constant":false,"inputs":[],"name":
"kill","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function
"},{"constant":false,"inputs":[{"name":"_greeting","type":"string"}],"name":"newGre
eting","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function
"},{"constant":true,"inputs":[],"name":"greet","outputs":[{"name":"","type":"string
"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":
"_greeting","type":"string"}],"payable":false,"stateMutability":"nonpayable","type"
:"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"oldGreetingIdx
","type":"string"},{"indexed":true,"name":"newGreetingIdx","type":"string"},{"index
ed":false,"name":"oldGreeting","type":"string"},{"indexed":false,"name":"newGreetin
g","type":"string"}],"name":"Modified","type":"event"}]}') 
*********************************************************************** 
var mycontract = eth.contract(contractInfo.abi); 
*********************************************************************** 
var 
greeter=mycontract.new("vijay",{from:primaryAddress,data:"0x6060604052341561000f576
00080fd5b6040516106073803806106078339810160405280805160008054600160a060020a03191633
600160a060020a03161790559190910190506001818051610059929160200190610060565b50506100f
b565b828054600181600116156101000203166002900490600052602060002090601f01602090048101
9282601f106100a157805160ff19168380011785556100ce565b828001600101855582156100ce57918
2015b828111156100ce5782518255916020019190600101906100b3565b506100da9291506100de565b
5090565b6100f891905b808211156100da57600081556001016100e4565b90565b6104fd8061010a600
0396000f3006060604052600436106100565763ffffffff7c0100000000000000000000000000000000
00000000000000000000000060003504166341c0e1b5811461005b5780634ac0d66e14610070578063c
fae3217146100c1575b600080fd5b341561006657600080fd5b61006e61014b565b005b341561007b57
600080fd5b61006e60046024813581810190830135806020601f8201819004810201604051908101604
052818152929190602084018383808284375094965061018c95505050505050565b34156100cc576000
80fd5b6100d461037e565b6040516020808252819081018381815181526020019150805190602001908
0838360005b838110156101105780820151838201526020016100f8565b50505050905090810190601f
16801561013d5780820380516001836020036101000a031916815260200191505b50925050506040518
0910390f35b6000543373ffffffffffffffffffffffffffffffffffffffff9081169116141561018a57
60005473ffffffffffffffffffffffffffffffffffffffff16ff5b565b8060405180828051906020019
08083835b602083106101bc5780518252601f19909201916020918201910161019d565b600183602003
6101000a038019825116818451161790925250505091909101925060409150505180910390206001604
05180828054600181600116156101000203166002900480156102455780601f10610223576101008083
540402835291820191610245565b820191906000526020600020905b815481529060010190602001808
311610231575b505091505060405180910390207f047dcd1aa8b77b0b943642129c767533eeacd700c7
c1eab092b8ce05d2b2faf56001846040516040808252835460026000196101006001841615020190911
604908201819052819060208201906060830190869080156102f45780601f106102c957610100808354
0402835291602001916102f4565b820191906000526020600020905b815481529060010190602001808
3116102d757829003601f168201915b5050838103825284818151815260200191508051906020019080
838360005b8381101561032b578082015183820152602001610313565b50505050905090810190601f1
680156103585780820380516001836020036101000a031916815260200191505b509450505050506040
5180910390a3600181805161037a929160200190610427565b5050565b6103866104a5565b600180546
00181600116156101000203166002900480601f01602080910402602001604051908101604052809291
908181526020018280546001816001161561010002031660029004801561041c5780601f106103f1576
1010080835404028352916020019161041c565b820191906000526020600020905b8154815290600101
906020018083116103ff57829003601f168201915b505050505090505b90565b8280546001816001161
56101000203166002900490600052602060002090601f016020900481019282601f1061046857805160
ff1916838001178555610495565b82800160010185558215610495579182015b8281111561049557825
182559160200191906001019061047a565b506104a19291506104b7565b5090565b6020604051908101
6040526000815290565b61042491905b808211156104a157600081556001016104bd5600a165627a7a7
23058209ca1afae1366fec4a6ecbcaf13cd87569d07266c428915c3e44167b091a8bf420029", gas: 
1000000}); 
 
 
****************************************** 
greeter 
**************************************************************** 
 
eth.getTransactionReceipt(greeter.transactionHash); 
******************************************************************* 
 
var storageAddress 
=eth.getTransactionReceipt(greeter.transactionHash).contractAddress 
 
 
 
******************************************************************** 
var storage = mycontract.at(storageAddress); 
 
 
****************************************************************************** 

Geth important commands

  • 1.
    Installation sudo apt-get installsoftware-properties-common sudo add-apt-repository -y ppa:ethereum/ethereum sudo apt-get update sudo apt-get install ethereum sudo apt-get install solc Genesis { "nonce": ​"0xdeadbeefdeadbeef"​, "timestamp": ​"0x00"​, "parentHash": ​"0x0000000000000000000000000000000000000000000000000000000000000000"​, "extraData": ​"0x686f727365"​, "gasLimit": ​"0x08000000"​, "difficulty": ​"0x0400"​, "mixhash": ​"0x0000000000000000000000000000000000000000000000000000000000000000"​, "coinbase": ​"0x3333333333333333333333333333333333333333"​, "alloc": { }, "config": { "homesteadBlock": ​0​, "eip155Block": ​0​, "eip158Block": ​0 } } Understanding Genesis Create Node geth --datadir ethdir/vijay init vijay.json Open Geth without console geth --datadir ethdir/vijay/ --ethash.dagdir ethdag/ --networkid 1234 Open Geth with console geth --datadir ethdir/vijay/ --ethash.dagdir ethdag/ --networkid 1234 console 2>console.log Node Info admin.nodeInfo
  • 2.
    List All Accounts personal.listAccounts eth.accounts CheckBlock number eth.blockNumber Check block details eth.getBlock() Create an Account personal.newAccount() Start Mining miner.start(1) Stop Mining miner.stop() Unlock Account personal.unlockAccount(eth.accounts[0]) Check Account Balance eth.getBalance(eth.accounts[0]) Create More Accounts Attach More Console to a Node geth attach ipc:ethdir/vijay/geth.ipc 1. Check node info on both terminal 2. Check accounts and balances Create More Nodes 1. Create More nodes with above commands 2. Check Node Info 3. Check accounts 4. Check block number 5. Node should be on same network
  • 3.
    Add Peers admin.addPeer("enode") 1. CheckNode Info 2. Check Accounts 3. Check Block Number Check Peers admin.peers 1. Start Mining 2. Check block 3. Check miner of the block 4. Check block details 5. Check Account and balance 6. Stop mining 7. Create account on node 2 8. Repeat from 1-3 Check total Balance of the miner eth.getBalance(eth.getBlock(eth.blockNumber).miner) Transfer funds between them (without or without mining) Check you have two account on node Unlock Account before transferring funds personal.sendTransaction({"from":eth.accounts[0], "to":eth.accounts[1], value: web3.toWei(1.23,"ether")}, "vijay") Will give you transaction hash Check pending Transaction eth.pendingTransactions Check balance of both account Smart Contract ● Open local solidity browser ● Create a contract in IDE ● Start full loaded node geth --datadir ethdir/vijay/ --ethash.dagdir ethdag/ --networkid 1234 --rpc --rpcport 8545 --rpccorsdomain "*" console 2>console.log ● Connect to node using web3 provider ● Unlock your Account before deployment Deploy Smart Contract Create Contract with required parameter Check block number
  • 4.
    Check pending transaction Startmining Contract will be deployed will get an address of the account DApps
  • 5.
    Smart Contract onGeth Console Greeter.solc  pragma solidity ^0.4.2;  contract mortal {  address owner;  function mortal() { owner = msg.sender; }  function kill() { if (msg.sender == owner) suicide(owner); }  }  contract greeter is mortal {    string greeting;    function greeter(string _greeting) public {    greeting = _greeting;  }  function newGreeting(string _greeting) public {    Modified(greeting, _greeting, greeting, _greeting);    greeting = _greeting;  }    function greet() constant returns (string) {    return greeting; 
  • 6.
    }    event Modified(   string indexed oldGreetingIdx, string indexed newGreetingIdx,    string oldGreeting, string newGreeting);  }      Compiling the Solidity use solc  Deploying it on geth console using below setup    var contractInfo =  JSON.parse('{"contract_name":"Greeter","abi":[{"constant":false,"inputs":[],"name": "kill","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function "},{"constant":false,"inputs":[{"name":"_greeting","type":"string"}],"name":"newGre eting","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function "},{"constant":true,"inputs":[],"name":"greet","outputs":[{"name":"","type":"string "}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name": "_greeting","type":"string"}],"payable":false,"stateMutability":"nonpayable","type" :"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"oldGreetingIdx ","type":"string"},{"indexed":true,"name":"newGreetingIdx","type":"string"},{"index ed":false,"name":"oldGreeting","type":"string"},{"indexed":false,"name":"newGreetin g","type":"string"}],"name":"Modified","type":"event"}]}')  ***********************************************************************  var mycontract = eth.contract(contractInfo.abi);  ***********************************************************************  var  greeter=mycontract.new("vijay",{from:primaryAddress,data:"0x6060604052341561000f576 00080fd5b6040516106073803806106078339810160405280805160008054600160a060020a03191633 600160a060020a03161790559190910190506001818051610059929160200190610060565b50506100f b565b828054600181600116156101000203166002900490600052602060002090601f01602090048101 9282601f106100a157805160ff19168380011785556100ce565b828001600101855582156100ce57918 2015b828111156100ce5782518255916020019190600101906100b3565b506100da9291506100de565b 5090565b6100f891905b808211156100da57600081556001016100e4565b90565b6104fd8061010a600 0396000f3006060604052600436106100565763ffffffff7c0100000000000000000000000000000000 00000000000000000000000060003504166341c0e1b5811461005b5780634ac0d66e14610070578063c fae3217146100c1575b600080fd5b341561006657600080fd5b61006e61014b565b005b341561007b57 600080fd5b61006e60046024813581810190830135806020601f8201819004810201604051908101604 052818152929190602084018383808284375094965061018c95505050505050565b34156100cc576000 80fd5b6100d461037e565b6040516020808252819081018381815181526020019150805190602001908 0838360005b838110156101105780820151838201526020016100f8565b50505050905090810190601f 16801561013d5780820380516001836020036101000a031916815260200191505b50925050506040518 0910390f35b6000543373ffffffffffffffffffffffffffffffffffffffff9081169116141561018a57 60005473ffffffffffffffffffffffffffffffffffffffff16ff5b565b8060405180828051906020019 08083835b602083106101bc5780518252601f19909201916020918201910161019d565b600183602003 6101000a038019825116818451161790925250505091909101925060409150505180910390206001604 05180828054600181600116156101000203166002900480156102455780601f10610223576101008083 540402835291820191610245565b820191906000526020600020905b815481529060010190602001808 311610231575b505091505060405180910390207f047dcd1aa8b77b0b943642129c767533eeacd700c7 c1eab092b8ce05d2b2faf56001846040516040808252835460026000196101006001841615020190911 604908201819052819060208201906060830190869080156102f45780601f106102c957610100808354 0402835291602001916102f4565b820191906000526020600020905b815481529060010190602001808 3116102d757829003601f168201915b5050838103825284818151815260200191508051906020019080 838360005b8381101561032b578082015183820152602001610313565b50505050905090810190601f1 680156103585780820380516001836020036101000a031916815260200191505b509450505050506040 5180910390a3600181805161037a929160200190610427565b5050565b6103866104a5565b600180546 00181600116156101000203166002900480601f01602080910402602001604051908101604052809291
  • 7.
    908181526020018280546001816001161561010002031660029004801561041c5780601f106103f1576 1010080835404028352916020019161041c565b820191906000526020600020905b8154815290600101 906020018083116103ff57829003601f168201915b505050505090505b90565b8280546001816001161 56101000203166002900490600052602060002090601f016020900481019282601f1061046857805160 ff1916838001178555610495565b82800160010185558215610495579182015b8281111561049557825 182559160200191906001019061047a565b506104a19291506104b7565b5090565b6020604051908101 6040526000815290565b61042491905b808211156104a157600081556001016104bd5600a165627a7a7 23058209ca1afae1366fec4a6ecbcaf13cd87569d07266c428915c3e44167b091a8bf420029", gas:  1000000});      ******************************************  greeter  ****************************************************************    eth.getTransactionReceipt(greeter.transactionHash);  *******************************************************************    var storageAddress  =eth.getTransactionReceipt(greeter.transactionHash).contractAddress        ********************************************************************  varstorage = mycontract.at(storageAddress);      ******************************************************************************