-
- Install Homebrew: ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
- brew update
- brew upgrade
-
- brew tap ethereum/ethereum
- brew install ethereum
-
- create a private folder e.g.: mkdir privateEth
- Go inside the directory: cd privateEth
- Create a genesis file: touch genesis.json
- Copy paste the contents of genesis file from here genesis file
- Instantiate the genesis block: geth --datadir ./ethdata1 init ./genesis.json
- Start the node: geth --datadir="./ethdata1" --networkid 55580 --nodiscover --rpcport "8546" --rpccorsdomain "*" --port 30304
- Copy the IPC end point displayed at the end (Ex. /Users/user1/Desktop/MonthlyEngiTalk/privateEth/private/geth.ipc)
-
- Open a new console tab
- Start the geth console: geth attach {Paste the end point} (Dont include brackets)
- Ex. geth attach /Users/user1/Desktop/MonthlyEngiTalk/privateEth/private/geth.ipc
-
- To start a geth Node: docker run -it -p 30304:30304 -p 8546:8546 "subhasmitasahoo/privateethereum"
- geth --datadir="./privateEth" --networkid 55580 --nodiscover --rpcport "8546" --rpccorsdomain "*" --port 30304
- To attach a console to the running node:
- Open a new console window
- Check the list of containers running: docker container list
- Get the container id having image id("subhasmitasahoo/privateethereum")
- Run: docker exec -it {container_id} geth attach {IPC endpoint}
- Ex. docker exec -it 408b1c24e459 geth attach /home/eth_user/privateEth/geth.ipc
-
- To see the list of current accounts: eth.accounts
- To create an account personal.newAccount()
- Balance of any account(Here index is 0): eth.getBalance(eth.accounts[0])
- To get the balance in ether: web3.fromWei(eth.getBalance(eth.coinbase),"ether")
- To see the etherbase account: eth.coinbase
- Balance of etherbase account: eth.getBalance(eth.coinbase)
- To start the miner (This adds balance in etherbase account)miner.start()
- To start the miner using specific no. of threads (Ex. 2)miner.start(2)
- To stop the miner: miner.stop()
- To get the admin info. admin
- To add a peer
- Get the enode info of the other node (ex. "enode://591def4c46746d7528837c1a6ef00741b1100c4ad03f0ff0d957991256f21aa947ba4282bf3aea89ed5a02aaf03d548b53bd102904cf8748d47244174ccda804@[::]:30304" (Remove "?discport=0" if present))
- Replace @[::] with @privateIP (Ex. @172.28.143.12)>
- Run admin.addPeer("Final_IPC_END_POINT")
- Ex. admin.addPeer("enode://7dfc49b8d71c17cd123f7e80f75a6deb38b8aa36ec021817772ed2a73f9a7dc9c0d7eb6d4fba9db39cec0d6ab9744492d1a3da710559f26ae5892ac977eb7128@172.28.210.141:30304")
- Run admin and check "peers" field inside it. If successful, you can see the other node entry inside it.
- To unlock an account for specific secs(ex.300 secs): personal.unlockAccount(eth.accounts[0],"{Your password}")
- To send ether from one account to other(Ex. account0 to last account): eth.sendTransaction({from:eth.accounts[0],to:eth.accounts[eth.accounts.length-1],value:web3.toWei(1,"ether")})
- To send ether using account address(Ex. your account0 to other peer account): eth.sendTransaction({from:eth.accounts[0],to:"{address}",value:web3.toWei(1,"ether")})
- To see the pending transactions: eth.pendingTransactions
- To see the latest Block number: eth.blockNumber
- To see the data Inside a Block: eth.getBlock({Block_no})
- To see the transaction detaild from Tx Hash eth.getTransaction("{Tx Hash}");
- Ex: eth.getTransaction("0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421")
- To come out of the geth console: exit
subhasmitasahoo/Ethereum-Private-Network
This repo includes steps to create a private ethereum network and play around with it