How to Setup Private Ethereum Blockchain on Windows [Complete Guide]

In this Ethereum tutorial, we will discuss how to setup a private Ethereum Blockchain on Windows operating system. Here, we will give a step-by-step tutorial to create your own private Ethereum blockchain. Moreover, this tutorial includes the following steps.

How do you deploy a local private Ethereum blockchain?

Now let us see, step by step how to do you deploy a local private Ethereum blockchain? Below are the steps:

  • Step-1: Install & Setup Geth on Windows
  • Step-2: Create a local Ethereum account
  • Step-3: Generate a new genesis block
  • Step-4: Export the genesis file
  • Step-5: Initialize private Ethereum Blockchain

1. Install & setup Geth on Windows

To set up a private Ethereum blockchain, first, we need to download an Ethereum Client. And for this implementation, we will be using Geth.

Geth (Go Ethereum) is a Go language-based command-line interface for running Ethereum nodes. Geth allows you to join the Ethereum network, send and receive ether, and even mine ether.

  • Now, we can download Geth from the following download page. On the download page, click on Geth for Windows and it will start downloading it.
  • Once the Geth got downloaded, run the setup file.
  • First, we need to agree to the license agreement by clicking on the “I Agree” button.
Installing Geth for private Ethereum
Agree to the Licence Agreement
  • Next, it will ask to select the required components that we want to install. Here, we need to select both Geth as well as Development tools and click on Next.
Installing Geth with development tools
Installing Geth with development tools
  • After this, we will display the installation location for Geth. We can also change this installation location.
Installing Geth on Windows
Installing Geth on Windows
  • In the end, click on the Install button to install Geth in Windows. And once the installation got completed, click on the Close button.
How to install Geth in Windows
Completed Geth installation on windows
  • Now, to check if the Geth is installed properly, we can run the following command either in a command prompt or in PowerShell.
geth

Important: After running the above command, use Ctrl+C to stop it. Otherwise it will start downloading the complete blokchain from Ethereum MainNet.

Here is the sample output of the above geth command in the command prompt.

Setup Private Ethereum Blockchain on Windows
checking geth installation on windows

With the above steps, we have successfully installed Geth on Windows operating system

Note: If you are unable to run the geth command, try to add the location of geth in the PATH environment variable. The default location of geth is as follows “C:\Program Files\Geth

Read What is Ethereum Network

2. Create a local Ethereum account

Now that we have successfully installed the Ethereum Client, let’s use it to create a local Ethereum account.

For this task, run the PowerShell or command prompt and execute the following command.

geth account new

After running the above command, get will ask to set a password. Moreover, we need to specify the password twice.

How to Setup Private Ethereum Blockchain on Windows
create a new local Ethereum account

As a result of the above command, it will create a new account and also generate keys for it.

Read Ethereum Use Cases

3. Create a new genesis block

Now, to create a private Ethereum blockchain, we need to create a genesis block. A genesis block is the very first block in the blockchain. For this task, we will use the puppeth tool.

The puppeth is a private Ethereum management tool. We will use this tool to first create a genesis file and then export it.

  • First, run the following puppeth command in your Windows command prompt or PowerShell.
puppeth
  • When we run the above command, it will ask to specify a network name. And we will use this name to identify our private Ethereum blockchain.
How do you deploy a local private Ethereum blockchain
Using puppeth for Ethereum management
  • After this, it will ask for further instructions. Next, from the set of options, we will select the 2nd option that states, “Configure new genesis“.
  • Right after this, it will give 2 more options. And we will select the 1st option that states, “Create new genesis from scratch“.
  • After selecting the first option, puppeth will ask for the consensus engine that we want to use. Here we are selecting Clique consensus which is the proof-of-authority method.
create private ethereum blockchain on windows
create new genesis block using geth
  • Next, we need to specify the number of seconds a block should take. In this case, we have specified the block time as 10.
  • Right after this, it will ask to specify an account allowed to seal. Here, we have to specify the public address of our Ethereum account that we created before.
  • Again, it will ask to specify the account address that should be refunded. Here also, we have to specify the account address.
How to create private ethereum blockchain on windows
Configure new genesis block
  • Next, it will ask whether the precompile addresses should be pre-funded with 1 Wei or not. For this option, we will specify Yes as it’s just a collection of addresses that will be needed to compile the blockchain.
  • At last, it will ask to specify the Network ID / Chain ID. Here we can specify any number greater than 100. We have specified 137 in this case.
How do I run private ethereum blockchain on Windows
create private ethereum blockchain on windows

With this, we have successfully created a new genesis block for our private Ethereum blockchain.

Read Ethereum Ecosystem

4. Export the genesis file

Now to start our private Ethereum blockchain, we need to export the genesis file created in the previous section.

  • To implement this task, we have to use puppeth. And this time, from the list of options, we will select “Manage existing genesis“.
  • After this, it will again provide some options and from there, we will select “Export genesis configuration“.
How to create private ethereum blockchain on windows
export existing genesis
  • Next, we need to specify the location where the json file will be exported. Once we specify the location, it will create 4 json files at that location.
How to Setup Private Ethereum Blockchain on Windows
exporting existing genesis file

With this, we have successfully exported the existing genesis file.

5. Initialize private Ethereum Blockchain

Now, in this step, we are ready to start our private Ethereum blockchain. And for this, we need to initialize the genesis file.

To do so, we will use the following command in another terminal.

geth init <your-genesis-file-location>.json

In our case, the command is as follows.

geth init D:\test\ethereumdots.json

Once we execute the above command, we will get the following result.

Setup Private Ethereum Blockchain on Windows
initialize the genesis block for private blockchain

Important: If you got an error stating “Failed to write genesis block: database already contains an incompatible genesis block” then use geth removedb command and try again.

Now, let’s, start our private Ethereum blockchain. For this, we will use the following command.

geth --nodiscover --networkid 137 --unlock 0x<Your-Ethereum-Address> --mine

In our case, the command with a public address is shown below.

geth --nodiscover --networkid 137 --unlock 0xFD79FA4C4Cf1AE468edC9FFC631e9D4a1EE2C542 --mine

After executing the above command, it will ask for the password corresponding to that address. Once we specify the password, we can observe blockchain ready to mine new blocks.

How to Setup Private Ethereum Blockchain on Windows
Mining on the private Ethereum Blockchain

So, in this tutorial, we have discussed how to set up private Ethereum Blockchain on Windows operating system. However, the setup of a private Ethereum Blockchain includes the following steps.

  • Install & Setup Geth on Windows
  • Create a local Ethereum account
  • Generate a new genesis block
  • Export the genesis file
  • Initialize private Ethereum Blockchain

Related Ethereum tutorials: