Home > Articles

  • Print
  • + Share This
This chapter is from the book

This chapter is from the book

Running a Private Ethereum Network

For developers, it is often a good idea just to start your own private Ethereum test network. The following command starts the first node on the private network from scratch (i.e., block 0, or the genesis):

$ geth --dev console

Running a single node network is oftentimes sufficient for development tasks. But sometimes you do need a real network with multiple nodes. To start a new peer node, find out the identity of your current (first) node in the interactive console.

> admin.nodeInfo
{
  enode: "enode://c74de1...ce@[::]:55223?discport=0",
  id: "c74de1...ce",
  ip: "::",
  listenAddr: "[::]:55223",
  name: "Geth/v1.7.0-stable-6c6c7b2a/linux-amd64/go1.7.4",
  ports: {
    discovery: 0,
    listener: 55223
  },
  protocols: {
    eth: {
      difficulty: 131072,
      genesis: "0xe5be...bc",
      head: "0xe5...bc",
      network: 1
    },
...

With the enode ID, you can start a second peer node from another computer. Notice that the [::] in the enode ID is your node’s IP address. So, you will need to replace it with the IP address of the first node.

geth --bootnodes "enode://c74de1...ce@192.168.1.3:55223"

You can now start more peer nodes. The bootnodes parameter can take multiple enode addresses separated by commas. Alternatively, you can start each node in the console mode, use admin.nodeInfo to figure out the enode ID for each, and then use admin.addPeer to connect each node to each other.

> admin.addPeer("enode://c74de1...ce@192.168.1.3:55223")
True
> net.peerCount
1

Each new node will start by downloading and syncing the complete blockchain from the private network. They can all mine ethers and validate transactions on the network.

  • + Share This
  • 🔖 Save To Your Account