Setting up private network or local cluster - usechain/doc GitHub Wiki
This page describes how to set up a local cluster of nodes and advise how to make it private. A fully controlled use network is useful as a backend for network integration testing (core developers working on issues related to networking/blockchain synching/message propagation, etc or DAPP developers testing multi-block and multi-user scenarios).
We assume you are able to build used following the build instructions
An Usechain network is a private network if the nodes are not connected to the main network nodes. In this context private only means reserved or isolated, rather than protected or secure.
Since connections between nodes are valid only if peers have identical protocol version and network ID, you can effectively isolate your network by setting either of these to a non default value. We recommend using the --networkid command line option for this. Its argument is an integer, the main network has id 1 (the default) and the moonet network has id 2. So if you supply your own custom network ID which is different than the main or moonet network your nodes will not connect to other nodes and form a private network.
Every blockchain starts with the genesis block. When you run used with default settings for the first time, the main net genesis block is committed to the database. For a private network, you usually want a different genesis block.
To facilitate setting up the private network, we provide a genesisSingle.json file available in the ./buidl/config directory
Now,you can start up your first nodes by:
./used --testnet consoleSince your network will be completely cut off from the main and test networks, you'll also need to configure a miner to process transactions and create new blocks for you.
Before you start running a private miner,you need a account first:
>personal.newAccount("123456")
"123456" is your account's password,and then you should unlock the account:
>personal.unlockAccount(use.accounts[0],"123456",0)
then you can run a private miner:
>miner.start()
With all nodes that you want to run initialized to the desired genesis state, you'll need to start a bootstrap node that others can use to find each other in your network and/or over the internet. You can use the node above as a bootstrap node.First you need to know the node's nodeInfo:
>admin.nodeInfo.enode
"enode://74f0eadf83c2d6c858fdb2d4ec6ff258907d81109d47a19312b24f6dd6b90b1c01b7ae26a50dd80cd96c4dc9bff8750ecbf2cf044aca4ecae9ebd98347659128@[::]:40404"
With the bootnode operational and externally reachable (you can try telnet to ensure it's indeed reachable), start every subsequent Used node pointed to the bootnode for peer discovery via the --bootnodes flag. It will probably also be desirable to keep the data directory of your private network separated, so do also specify a custom --datadir flag.
./used --testnet --bootnodes <bootnode-enode-url-from-above>
With these steps, you will set up a private network and start single node mining.