Build a private chain with one node
NEO-CLI 2.10.2 and the later clients support generating blocks without consensus nodes, which means you can set up a private chain with one node.
You can directly download the project NEO-Private-Net to run a private chain quickly. Note that this project assumes you use Windows 10 and has .NetFramework 4.7.1 installed.
You can also build a private chain with one node by yourself, which will be elaborated in the following sections.
Installing NEO node
Refer to Installation of NEO-CLI to install NEO-CLI.
Installing plug-in (Optional)
Install the plug-in SimplePolicy which is used to output the log of generated blocks . Place the unzipped plugin under the Plugins folder of NEO-CLI.
You can also install other plugins with reference to the following list:
Creating a wallet file
From NEO-CLI or NEO-GUI create a wallet a.json and place it in the node folder.
Modifying config.json
Make the following configurations in config.json of the node:
-
Specify the ports so that each port is not duplicated and is not occupied by other applications.
-
In "UnlockWallet" specify the wallet path and wallet password.
-
Set
StartConsensus
andIsActive
as true.
You can refer to the following example:
Modifying protocol.json
Configure the following parameters in NEO-CLI protocol.json. If you configure other nodes later ensure the configuration in each file is consistent.
-
Magic: The private chain ID, which can be any integer in the range of [0 - 4294967295].
-
StandbyValidators :The public key of the alternate consensus node. Enter the public key of the wallet a.json (It is single node mode when there is only one public key included in StandbyValidators).
-
SeedList: The IP address and port number of the seed node. Specify the IP address as
localhost
and the ports as the P2P port configured in config.json.
You can refer to the following example:
Starting the private chain
Run the command line and enter the NEO-CLI directory. Then enter neo-cli.exe
to start the private chain. The private chain is set up successfully when it goes as shown below:
The private chain is terminated if you close the window.
Withdrawing NEO and GAS
In the genesis block of the Neo network, 100 million NEOs are generated. Additionally, GAS is generated with the generation of new blocks. When the private chain is set up, you can withdraw those NEO and GAS from a multi-party address with Neo-CLI or Neo-GUI, to facilitate your blockchain development and testing.
Withdrawing NEO/GAS using Neo-CLI
-
From Neo-CLI command line enter
open wallet a.json
to open the wallet. -
Enter the command
import multisigaddress m pubkeys
to create a multi-part signed address, where:m
is 1 as the minimal signature number andpubkeys
is the public key of a.json -
Enter
list asset
,then you should see 100 million NEO shares showing up. -
Use the command
send <id|alias> <address> <value>
to transfer NEO to the normal address desired.Since this multi-signature address only requires one signature, operations for transferring assets from a contract address are as same as the normal address.
Installing and configuring Neo-GUI
-
Download Neo-GUI from Github and extract the file.
-
Replace the protocol.json in the Neo-GUI folder with the one configured before.
-
Configure the file config.json to make sure the Neo-GUI port is not conflict with the one of Neo-CLI; otherwise, Neo-GUI cannot work as Neo-CLI is running.
Start Neo-GUI and open a.json, if you see the connection number in the lower left corner is not 0 and the client has been downloading the blocks, the client has been successfully connected to the private chain.
Transferring NEO/GAS
-
In NEO-GUI, right-click on the blank area of account page, click
Create Contract Address
->Multi-Signature
. -
Enter the public key and set the minimum number of signatures to 1. Click
Confirm
. -
Click
Wallet
->Rebuild wallet index
.
Now you should see the contract address has 100 million NEO shares. Since this multi-signature address only requires one signature, operations for transferring assets from a contract address are as same as the normal address.