Creating Private Network

What is Private Network

Private network is the full fledged Ethereum blockchain created on our computer. We can use Geth (Go Ethereum Client) to start our own private network on our computer.

Requirements

Install Geth

Geth is a cli that allows us to run and operate full Etherium node. On Mac we can install it using following commands

brew tap ethereum/ethereum
brew install ethereum

Creating Genesis Block

Genesis Block is the First Block in a Blockchian.

To create Genesis Block we need a Genesis file which is a JSON file, like following

{
  "coinbase"   : "0x0000000000000000000000000000000000000001",
  "difficulty" : "0x10000",
  "extraData"  : "",
  "gasLimit"   : "0x9000000",
  "nonce"      : "0x0000000000000032",
  "mixhash"    : "0x0000000000000000000000000000000000000000000000000000000000000000",
  "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
  "timestamp"  : "0x00",
  "alloc": {},
  "config": {
        "chainId": 15,
        "homesteadBlock": 0,
        "eip155Block": 0,
        "eip158Block": 0
    }
}

Steps

JSON RPC Interface of Geth

To attach to JSON RPC interface of Geth, We can use following command

To start HTTP Restful Interface of Geth

To communicate with Geth from outside Geth console, we need to start Geth with Restful Interface. We use --rpc parameter which will open port 8545 on localhost. We also need to enable CORS (Cross Origin Resource Sharing) by --rpccorsdomain "*". Once it is opened we will see following line in output.

...
...
HTTP endpoint opened                     url=http://127.0.0.1:8545
...

References

SUBSCRIBE TO NEW CONTENT

Tutorials on System Design, BlockChain, Design Patterns and more sent out once a week.

Loading comments...