Skip to content

Instantly share code, notes, and snippets.

@eodgooch
Last active July 7, 2017 20:42
Show Gist options
  • Save eodgooch/b68a14efbb5646a6802fedf331cd36cb to your computer and use it in GitHub Desktop.
Save eodgooch/b68a14efbb5646a6802fedf331cd36cb to your computer and use it in GitHub Desktop.
private ethereum blockchain howto
{
"nonce": "0x0000000000000042",
"timestamp": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"extraData": "0x0",
"gasLimit": "0x8000000",
"difficulty": "0x400",
"mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x3333333333333333333333333333333333333333",
"alloc": {
"<your private chain wallet>": {
"balance": "10000000000000000000"
}
}
}
#!/bin/bash
# run from go-ethereum directory
# creates private chain at `--datadir` location
# expects the my-genesis file in the same directory
# BEWARE -- runs rpc on default 8545 port!
exec ./build/bin/geth --identity "PrivateNode" --rpc --rpccorsdomain "*" --datadir "/Users/aaron/ethereum/privatechain" --port "30303" --nodiscover --rpcapi "db,eth,net,web3" --networkid 1999 console init my-genesis.json

guide to set up private block chain:

prerequisites:

  • install golang

install geth using go:

  • go get -d github.com/ethereum/go-ethereum
  • cd $GOPATH/src/github.com/ethereum/go-ethereum
  • make geth (installs geth to ~/go/src/github.com/ethereum/go-ethereum/build/bin/geth)

set up and run private blockchain:

create new private block chain account

  • from terminal: in a new terminal window run ${HOME}/go/src/github.com/ethereum/go-ethereum/build/bin/geth account new --datadir <your private chain directory>
  • from js console: personal.newAccount("<password>")
  • back in the geth console you can now see the account by running: eth.accounts[0]

mine some ether to your account

  • locate the ipc file on disk. Can be found when first starting local geth. (/Users/aaron/ethereum/privatechain/geth.ipc). This will allow you access to the miner.
  • attach to the running geth IPC node on localhost ./build/bin/geth attach "/Users/aaron/ethereum/privatechain/geth.ipc" --datadir "/Users/aaron/ethereum/privatechain"
  • unlock the eth acccount to mine if necessary personal.unlockAccount(eth.accounts[0], "<your account password>")
  • in the console set your account for the miner miner.setEtherbase(eth.accounts[0]); this should return true
  • finally run miner.start(1) (1 thread)
  • check balances with balance = web3.fromWei(eth.getBalance(eth.accounts[0]), "ether");
@base698
Copy link

base698 commented Jul 1, 2017

Is identity some secret?

@eodgooch
Copy link
Author

eodgooch commented Jul 1, 2017

geth flag: --identity value Custom node name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment