Skip to content

BaerChain Private Chain Construction

weidong edited this page Apr 9, 2020 · 2 revisions

Construction and start of BaerChain private network

1. Required configuration file

  • Requires files "genesis.json", "config.json" and execution file "brcd"
1.1 genesis.json file Back Dir
  • genesis.json genesis file, mainly some configuration of the chain
{
  "sealEngine":"SHDpos",
  "params": {
    "accountStartNonce": "0x00",
    "networkID": "0x0",
    "chainID": "0x1",
    "maximumExtraDataSize": "0x20",
    "tieBreakingGas": false,
    "minGasLimit": "0x1388",
    "maxGasLimit": "7fffffffffffffffffffff",
    "minimumDifficulty":"0x14",
    "dposEpochInterval": 0,
    "dposVarlitorInterval":1000,
    "dposBlockInterval": 1000
  },
  "genesis":{
    "nonce": "0x0000000000000042",
    "difficulty": "0x200",
    "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "author": "0x0000000000000000000000000000000000000000",
    "timestamp": "0x00",
    "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "extraData": "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa",
    "gasLimit": "0x7ffffffffffffffffffff",
    "sign":"0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
  },
  "accounts":{
    "000000000067656e657369735661726c69746f72":{
        "genesisVarlitor": [
            "100c08f22b608c446f19c9f3654bb7b19c67f474"
            ]
    },
    "0000000067656e6573697343616e646964617465":{
        "genesisVarlitor": [
            "b5a03d94e9ae7ee45c32f7d458b721cdce18f1e4"
        ]
    },
    "000000000000000000000042616572436861696e":{
        "currency":{
                "cookies": "0",
                "fcookie": "2900000000000000"
        }
    },
    "100c08f22b608c446f19c9f3654bb7b19c67f474":{
        "currency":{
                "cookies": "2900000000000000",
                "brc": "2900000000000000"
        }
    }
}
}
  • Geneis.json file parameter description Back Dir
"sealEngine"           : Consensus algorithm
"accountStartNonce"    : Initial nonce value of account
"networkID"            : Network id
"chainID"              : Chain id
"maximumExtraDataSize" : Maximum number of bytes of additional data
"tieBreakingGas"       : The default is false
"minGasLimit"          : Minimal consumption of transactions in the block
"maxGasLimit"          : Maximum transaction consumption in the block
"minimumDifficulty"    : Block minimum difficulty
"dposEpochInterval"    : Continuous event of block generation cycle 0: means permanent
"dposVarlitorInterval" :Block time of a block node
"dposBlockInterval"    :The longest time to make a block
"genesis"              :Represents the information in the genesis block
"nonce"                :Random number, corresponding to Nonce field of genesis block
"difficulty"           :Difficulty factor, corresponding to the Difficulty field of the genesis block. When building a private chain, you need to select the appropriate difficulty value according to the situation in order to adjust the block
"mixHash"              :A hash value corresponding to the MixDigest field of the genesis block. Together with the nonce value, it proves that enough calculations have been performed on the block.
"author"               :An address, the address of the creator of the genesis block
"timestamp"            :UTC timestamp, corresponding to the Time field of the genesis block
"parentHash"           :A hash, the hash of the parent node of the genesis block
"extraData"            :Extra data, corresponding to the Extra field of the genesis block
"gasLimit"             :Fuel cap, corresponding to the GasLimit field in the genesis block
"sign"                 :Signature, the creation block is 130-bit 0
"accounts"             000000000067656e657369735661726c69746f72 This genegeneVarlitor under this address stores the address of the block
                         0000000067656e6573697343616e646964617465 The genesisVarlitor under this address stores the address for the spare block
"currency"             : The currency to be configured. (brc: chain coins, cookies: fuel coins, fcookie: the number of frozen fuel coins)

  • Remarks
The genesis file has the highest priority, such as: even if the chainID is set in the code, the chainID configured in the genesis.json file will still prevail
1.2 config.json file Back Dir
  • config.json, The file is mainly configured with the private key of the block account
{
  "private_key":[ 
  	"6ca3iZ46XGdq19qZhW8AmWb8BJUpgLabZ3xm2VW14dvK"
  ],
  "peer_host":[
  ]
}
  • config.json file parameter description
private_key : Private key of own block address
peer_host   : Linked nodes, no need to add content at this time
1.3 brcd execution file preparation config.json The file is mainly configured with the private key of the block account
  • please check BaerChain Compile Guide, get the brcd execution file we need

  • Now our execution file "brcd", genesis file "genesis.json", configuration file "config.json" are all ready (recommended to be placed in the same directory), and now start to build a private chain

2. Chain start command Back Dir

  • ./brcd --private 1111111 --config ./genesis.json --accountJson ./config.json -d ./data --db-path ./db -v 2 --listen 36556 --http_port 8111 -a 100c08f22b608c446f19c9f3654bb7b19c67f474 -m on

  • Parameter Description

--private     : This field indicates that the private chain is started. The following data needs to be written by the initiator. For convenience, we simply wrote "1111111" here.
--config      : This field means to read the genesis file, "./genesis.json" is the path of the genesis file and the genesis file
--accountJson : This field means to read the configuration file, "./config.json" is the path and configuration file of the configuration file
-d            : The path behind is where the chain information is saved
--db-path     : Where to save the chain data
-v            : Is the log level after startup
--listen      : It is a port for chain data transmission. If you build a multi-node connection, this port
--http_port   : The port used for the rpc interface, the command is sent to the node through this port
-a   	      : Is the address of your own block account
-m            : Whether to start a block
  • At this point, you can see that the chain has been started. You can view your own server ip through the "ifconfig" command, such as "10.0.5.54", plus the "http_port" port "8111", you can request through "10.0.5.54:8111" Or send data
  • At this time, if the local host is also available "127.0.0.1:8111"

Clone this wiki locally