Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to build VPC for Geth in Block chain

Shulou Source: shulou.com Published: 2022-06-01 14:29:01 09月12日 Update

Today, I will talk to you about how to build a private network in Geth in the blockchain, which may not be well understood by many people. In order to make you understand better, the editor has summarized the following contents for you. I hope you can get something from this article.

[Windows] step 1:

Create a directory tmpPrivate

Create a genesis.json file and write the following

{"config": {"chainId": 15, "homesteadBlock": 0, "eip155Block": 0, "eip158Block": 0}, "coinbase": "0x0000000000000000000000000000000000000000", "difficulty": "0x40000", "extraData": "", "gasLimit": "0xffffffff", "nonce": "0x0000000000000042", "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000" "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", "timestamp": "0x00", "alloc": {} step 2:

CMD enters tmpPrivate, executes commands, and creates Genesis Block.

Geth-- datadir ". /" init genesis.json

At this point, you can notice that two new folders geth and keystore will be added under the current directory.

What is saved in geth is the data related to the block chain.

What is saved in keystore is the user information in the chain.

Step 3:

Create your own private chain

Geth-datadir ". /"-nodiscover console 2 > > geth.log

Console2 > > geth.log means to output part of the console to the file geth.log

Step 4:

Create users on your own private chain

Eth.accounts

The return value is [] because the private chain of Ethernet Fong is created, but there is no account.

Create a new user

Personal.newAccount ("123456")

"123456" is the user's password

You can create several

Step 5:

Start / stop (start digging)

Miner.start () miner.stop ()

Check the account

Eth.accountspersonal.listAccounts

View individual account balance

Eth.getBalance (eth.accounts [0])

Or:

Acc0=eth.accounts [0] eth.getBalance (acc0) after reading the above, do you have any further understanding of how to build a VPC in Geth in the blockchain? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

Tags: Private step block content user file account chain network directory output two representative balance information single command password console data Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei MySQL Shulou Tech Info Microsoft Linux