Skip to content

Ethereum Private Chain

Liqing Pan edited this page May 30, 2018 · 8 revisions

Setup Private Chain

Follow this Tutorial

  1. Recompile geth with bootnode. (Could be another way to assign the bootnode by CLI. But not sure yet)

How to join the private chain

  1. Get the recompiled geth, put it to my_path.
  2. Paste the genesis.json provided by the chain generator to my_path
  3. mkdir my_path/chaindata
  4. Go to my_path, run ./geth --datadir ./chaindata init ./genesis.json
  5. Run ./geth --datadir ./chaindata/ --networkid {chainId in genesis.json} console
  6. Wait for the node to connect with other nodes. Be patient, it can take more than 10min.
  7. If you want a new console window without logs, launch a new terminal, cd the same path, then geth attach ipc:chaindata/geth.ipc

Common console operations

  1. Generate new account: personal.newAccount(). Create new account: geth account new. More methods see HERE
  2. Check accounts: eth.accounts
  3. Check main account: eth.coinbase
  4. Mine: miner.start() miner.stop()
  5. Check Balance: web3.fromWei(eth.getBalance(eth.coinbase), "ether"). Not considering decimal, can simply use eth.getBalance({account})

Smart Contract

  • De

Other operations

  • Stop geth in terminal: the best way is to open another terminal, then run killall -HUP geth

Ethereum

  • Geth Console
  • Geth Commend
Clone this wiki locally