Environment & Configuration

1.download

By downloading the source code git

    
      

under construction

2.install Golang

Reference: (https://golang.org/doc/install)

3.configure validator

3.1 Generate extraData

Open documents/extra/ExtraData.go, change the data inside according to the comments, and then execute the main function

If you are inconvenient to execute Go code locally, you can implement this logic in other languages, and then execute it, or even manually splice it

After execution, you will see a string of strings in the console

    
      

0x000000000000000000000000000000000000000000000000000000000000000058b1E31682C95417be998b27db00731b54b7E5EC64d374ed85C21473ED84A95fD7319D8D55c33320CD2a39BAe63f8A4A8c0230e5c8DE12906c23Bad20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

Additional description:

1. There are several validator accounts configured here, which means only a few nodes can produce blocks. The node producing blocks needs to configure the private key of the validator account, start mining, and see the documentation for the mining method. &Run the mining link in

2. Each node can only be assigned one validator, and the number of nodes producing blocks must be greater than [number of validator accounts / 2]

3.2 Paste the string printed above into the configuration

Open config/Config.go and set the string printed above to the values of these two constants. Almost all the following configurations are changed in this file

    
      

// Mainnet configuration

;const (

  MainNetExtraData =

"0x000000000000000000000000000000000000000000000000000000000000000058b1E31682C95417be998b27db00731b54b7E5EC64d374ed85C21473ED84A95fD7319D8D55c33320CD2a39BAe63f8A4A8c0230e5c8DE12906c23Bad20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"

// MainNetPeriod Block interval

  MainNetPeriod = 5

// MainNetEpoch

  MainNetEpoch = 200

)

// Testnet configuration

const (

  TestNetExtraData =

"0x000000000000000000000000000000000000000000000000000000000000000058b1E31682C95417be998b27db00731b54b7E5EC64d374ed85C21473ED84A95fD7319D8D55c33320CD2a39BAe63f8A4A8c0230e5c8DE12906c23Bad20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"

// MainNetPeriod Block interval

  TestNetPeriod = 5

// MainNetEpoch

  TestNetEpoch = 200

)

4.Allocation of initial assets

4.1 Open core/genesis.json and find this paragraph

Change the addresses and assets inside as required. This passage means to initialize xx assets to xx addresses

    
      

"alloc": {

  "0x58b1E31682C95417be998b27db00731b54b7E5EC": {

     "balance": "0x100000000000000000000"

  }

}

If you want to initialize assets for multiple addresses, you can configure multiple addresses, such as

    
      

"alloc": {

  "0x58b1E31682C95417be998b27db00731b54b7E5EC": {

    "balance": "0x100000000000000000000"

  },

  "0x58b1E31682C95417be998b27db00731b54b7E5EC": {

     "balance": "0x100000000000000000000"

  }

}

Note: in the original file

000000000000000000000000000000000000C000,000000000000000000000000000000000000C001, 000000000000000000000000000000000000C002 These three options must not be changed

4.2 After configuration, execute in the directory where this file is located

    
      

./mkalloc genesis.json

4.3 will output the return value after execution

    
      

const allocData =

"\xf9h\x84\xf9Ic\x82\xc0\x00\x80\xb9I。。。"

4.4 Copy this return value to config/Config.go

Just modify the values of these two constants

    
      

// Mainnet configuration

const (

// MainNetAllocData after modifying genesis.json, execute ./mkalloc genesis.json to obtain

  MainNetAllocData = ''

)

// Testnet configuration

const (

// TestNetAllocData After modifying genesis.json, execute ./mkalloc genesis.json to obtain

   TestNetAllocData = ''

)

If you want to configure the main network and test network separately, you can repeat steps 1-2 to generate two allocData and assign values to these two variables respectively

5.Modify chainId and networkId as required

Open config/Config.go, pay attention to the comments below, the Id of the main network and the test network cannot be the same

    
      

// Mainnet configuration

const (

  MainNetChainId = 520

  MainNetNetworkId = 520

)

// Testnet configuration

const (

  TestNetChainId = 530

  TestNetNetworkId = 530

)

6.Administrator who configures the creation contract

Open config/Config.go and modify the following constants. The following value is the wallet address of the administrator you want to set

    
      

// Mainnet configuration

const (

  MainNetValidatorV1Admin = '0x58b1E31682C95417be998b27db00731b54b7E5EC'

  MainNetGovAdmin = '0x58b1E31682C95417be998b27db00731b54b7E5EC'

  MainNetDevAdmin = '0x58b1E31682C95417be998b27db00731b54b7E5EC'

)

// Testnet configuration

const (

  TestNetValidatorV1Admin = '0x58b1E31682C95417be998b27db00731b54b7E5EC'

  TestNetGovAdmin = '0x58b1E31682C95417be998b27db00731b54b7E5EC'

  TestNetDevAdmin = '0x58b1E31682C95417be998b27db00731b54b7E5EC'

)

7.Modify GenesisHash

This needs to be run to get the value to be configured, so you don't need to worry about it, wait until you finish compiling, and then come back after startup.

7.1 After startup, enter this command in the console

    
      

admin.nodeInfo

Then you will see the return value like this

    
      

{

enode:"enode://bf2bddcec4cb96d65e6b778be69c48c8f71d1b7389451df533bef2748d583d39dc46cd9d2dc1b7657715522@127.0.0.1:40307",

enr: "enr:-J24QNPHhCCtqcOndJo88KRLA1J92XpvbnU3RsS2jL0TRzijF0mIwOvBACg2V0aMfGhA2QHViAgmlkgnY0gmlwhH8AAAGJc2VjcDI1NmsxoQK_K93OxMuW1l5rd4vnUhcVviaRaFAjdAzi46vWVLreQIRzbmFwwIN0Y3CCnXODdWRwgp1z",

  id: "719b126b779eaf3cba913880c063c26da65c3fda",

  ip: "127.0.0.1",

  listenAddr: "[::]:40307",

  name: "Geth/v1.1.2-e7afed17-20211011/linux-amd64/go1.17",

  ports: {

    discovery: 40307,

    listener: 40307

  },

  protocols: {

    eth: {

      config: {

        berlinBlock: 0,

        byzantiumBlock: 0,

        chainId: 772,

        constantinopleBlock: 0,

        daoForkBlock: 0,

        daoForkSupport: true,

        eip150Block: 0,

eip150Hash: "0x0000000000000000000000000000000000000000000000000000000000000000",

        eip155Block: 0,

        eip158Block: 0,

        homesteadBlock: 0,

        istanbulBlock: 0,

        mirrorSyncBlock: 0,

        muirGlacierBlock: 0,

        nielsBlock: 0,

        parlia: {...},

        petersburgBlock: 0,

        ramanujanBlock: 0,

        redCoastBlock: 2

      },

      difficulty: 2517,

genesis: "0x44c9f5c51403be7954fd5bbdecb749e0c8bc77e46", --------genesis块hash

      head: "0x4ba46ebfb4dfd8c26dbabafd9910167ad2eacf175a956",

      network: 772

    },

    snap: {}

  }

}

Copy the value of the genesis attribute and paste it to config/Config.go

    
      

// Mainnet configuration

const (

   MainNetGenesisHash = '0x97b9fd09f9ecbef2ca407c2c039b882ebf7d27'

)

// Testnet configuration

const (

   TestNetGenesisHash = '0x97b9fd09f9ecbef2ca407c2c039b882ebf7d27'

)

Notes:

1. If the other configurations of your main network and test network are separate, then you have to start the main network and test network separately, obtain genesisHash separately, and configure them in the above two brackets

2. After completing this step, recompile and restart the node with the recompiled package [Before starting, you need to delete the data directory generated just before starting]

3. Be sure to finish reading, compiling and starting, and come back to see this later, otherwise it's easy to be confused

Previous

Create Wallet

Next

Compile & Run