Building an Ethereum private chain environment under Windows

Although there may be various unknown errors in the construction of the Ethereum blockchain development environment under Windows, everyone should actively explore.

 

One: Install the geth client

         Windows requires a 64-bit system. Download the compiled win64 client from the official website. After downloading and decompressing, there is only one Geth.exe to ask for the price. Just run and install. The download address is as follows:

https://github.com/ethereum/go-ethereum/releases/

 

After installation, use the cmd command to open the command line, enter the directory where you installed geth, and enter the geth –help command. If a lot of information about geth is output as shown in the figure below, the installation is successful. The current geth command can only be used in the directory corresponding to geth. If you want to use the geth command in any directory, just add the path of the directory where you installed geth to the system environment variable path.



 

Two: configure your own creation file:

         The purpose of configuring your own genesis block is to distinguish the public chain. In the same network, the genesis block must be the same, otherwise it cannot be connected. Place the initial genesis block file named genesis.json in the Geth installation directory

The content of the file is:

{

   "nonce":"0x0000000000000042",

   "mixhash":"0x0000000000000000000000000000000000000000000000000000000000000000",

   "difficulty": "0x4000",

   "alloc": {},

   "coinbase":"0x0000000000000000000000000000000000000000",

   "timestamp": "0x00",

   "parentHash":"0x0000000000000000000000000000000000000000000000000000000000000000",

   "extraData": "PICC GenesisBlock",

   "gasLimit":"0xffffffff"

}

 

Three: Start a private node

         This method is also used to start here after shutdown

Enter the directory where Geth is installed, premise that the configured genesis.json file has been placed, and execute the following command:

geth --datadir "%cd%\chain" initgenesis.json

Create data storage address and initialize genesis block

 

Geth --identity "PICCetherum" –rpc--rpccorsdomain "*" --datadir "%cd%\chain"--port"30303" --rpcapi"db,eth,net,web3" --networkid 95518 console

 

When you see the following, it means that the startup has been successful.

 

 


After starting the node, enter the geth command line mode, enter personal.newAccount() and enter the password according to the prompt to create a new account for you.

(Command to open geth console: geth -datadir "%cd%\chain" console (in your geth directory))

 

Four: Download and install the graphical wallet:

         Download address: https://github.com/ethereum/mist/releases/

 

Find Ethereum-Wallet-win64-xxx.zip to download and install. After following the above steps (do not close the command line to start the node)

 

Under the premise of running the wallet and running Ethereum-Wallet.exe, the startup is successful. If the blockchain is normal, "PRIVATE-NET" will be displayed in the upper right corner, and click "LAUNCH APPLICATION" to enter the graphical interface.


 


Five: Connect to other nodes:

 

First of all, you need to know your own node information, enter the command in the Geth command line interface, pay attention to the case

admin.nodeInfo

system will show

enode:"enode://1e3c1727cd3bee9f25edeb5dbb3b880e03e41f8eec99566557f3ee0422734a8fcad17c161aa93d61bdbfb28ed152c143c7eb501db58bc63502a104a84b62d742@0.0.0.0:30303“

in

enode://1e3c1727cd3bee9f25edeb5dbb3b880e03e41f8eec99566557f3ee0422734a8fcad17c161aa93d61bdbfb28ed152c143c7eb501db58bc63502a104a84b62d742@0.0.0.0:30303

It is the information of your own node. Be careful to replace "0.0.0.0" with your own IP. To send this information to other nodes, enter on the command line of other nodes:

admin.addPeer(‘enode://1e3c1727cd3bee9f25edeb5dbb3b880e03e41f8eec99566557f3ee0422734a8fcad17c161aa93d61bdbfb28ed152c143c7eb501db58bc63502a104a84b62d742@192.168.1.101:30303’)

If the addition is successful, entering admin.peers will display the newly added node.

 

six:

Command to start mining:

miner.start()

End mining:

Miner.stop()


Note: Some operation commands of geth must be performed in the geth command line mode, that is, after starting the node.

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325444531&siteId=291194637