## General
The default configuration for the necessary hosts in the new network consists of three [[Node#Root Node - consists of all blockchains of all subchains and shards|root nodes]] and three [[Node#Master Node - is like Full Node but with validator permission|master nodes]]. The number of these nodes may vary, but changes can be easily made through the parameters described in the [[Cellframe Node General Config|configuration files]]. Currently, all Cellframe networks operate in a hybrid regime based on two consensus mechanisms: the first one is a [[Proof of Authority (PoA)]] based on a [[DAG]], and the second one is our enhanced [[Proof of Stake (PoS)]] consensus - [[ESBOCS Consensus|ESBOCS]]. So, at least **one root node** is necessary for blockchain synchronization and for the functioning of the DAG-POA consensus. And at least **one master node** is required for starting up the very blockchain and work as a validator.
## Preparation
> [!HINT] Important
> In the next example, we will use **2** root and **3** master nodes for setting up the network. A brand new network must have a name. Let it be **foobar**. Also, there must be main network token specified, let it be **BUZ**.
> But while setting up your own network, you should use your unique names.
Let's name the first chain **zerochain** and the second one **main** in a traditional way.
### Sequence of preliminary actions
1. Set up 5 VPS hosts, preferably in different locations and with different hosting providers. For convenience, it is customary to give standard names to the hosts, indicating their role in the network: `0-root-foobar`, `1-root-foobar`, `0-master-foobar`, `1-master-foobar`, `2-master-foobar`. Update the packages and install additional software that may be needed, such as `midnight commander`, `htop`, `gdb`.
2. It is not mandatory, but desirable for convenience, to assign DNS names following the same principle, for example, _[0.root.foobar.cellframe.net](https://0.root.foobar.cellframe.net/)_.
3. Download and install the required version of a [[1. Cellframe Node Installation|cellframe node]] on each host.
4. Stop the node process on all hosts. To update the system variable #PATH and be able to run the node binary files from any location, restart the SSH session.
Command for stop the process:
```bash
systemctl stop cellframe-node
```
5. On each host create pairs of private and public certificates with corresponding names. For convenience, the certificate names should match the host names. It is also preferable to give the private certificate a `pvt` suffix.
In our case public certs would be:
```
foobar.root.0
foobar.root.1
foobar.master.0
foobar.master.1
foobar.master.2
```
And the private are:
```
foobar.root.pvt.0
foobar.root.pvt.1
foobar.master.pvt.0
foobar.master.pvt.1
foobar.master.pvt.2
```
6. Here is an example of the necessary commands to execute on the host with the name `0-root-foobar`:
```actionscript
cellframe-node-tool cert create foobar.root.pvt.0 sig_dil
```
```actionscript
cellframe-node-tool cert create_cert_pkey foobar.root.pvt.0 foobar.root.0
```
As a result, there will be created two files `foobar.root.pvt.0.dcert` (private certificate) and `foobar.root.0.dcert` (public certificate) in the catalog `/opt/cellframe-node/var/lib/ca`.
> [!ERROR] Important
> The `.dcert` extension is never specified either in the config or in the node commands as well.
7. Copy all the public certificates from the all nodes into the catalog `/opt/cellframe-node/share/ca` on the every node.
## Configuration settings
After the `cellframe-node` installation, you will get a pack of configuration files for the networks in the `opt/cellframe-node/etc/`.
You need four configuration files:
1. `cellframe-node.cfg`
2. `network_name.cfg` from the `/network` folder (for example, `Backbone.cfg`)
3. `chain-0.cfg` and `main.cfg` which you can acquire after the `cellframe-node` process started in the `opt/cellframe-node/etc/network/network_name`
You have to use them as templates for your network configuration. But they must be seriously modified.
Get `cellframe-node.cfg` and one of the network configs.
For example, take `Backbone.cfg`, rename it using your network name and use it as a scratch.
On the all hosts where your network will be set up, make two copies of configuration files, one is for **root** nodes, the second one is for **master** nodes.
> [!ERROR] Important
> Remember, most of the parameters are the same on all hosts, but some of them are different between root and master nodes, and some are different between each other. Below you can find hints of which parameter must be changed individually.
Let's make some necessary changes in the configuration files:
### General config
[[Cellframe Node General Config]] is located in `/opt/cellframe-node/etc/cellframe-node.cfg`.
Config consists of sections and their parameters with the following structure:
```ini
[section]
key=value (string/boolean/array/integer)
#commentaries in the config
```
The `seed mode` must be activated on the all **root** and **master** nodes during network starting:
```ini
[general]
# General debug mode
debug-mode=true
# seed mode. WARNING. Used true only when you start the new network
seed-mode=true
```
For convenience, you should specify the `IP address` of the every **master** and **root** node:
```ini
[server]
# By default you don't need to open you to the world
enabled=true
news-url_enabled=false
bugreport-url_enabled=false
listen-address=[0.0.0.0:8079]
# External IPv4 address
ext-address=8.9.10.11
```
In the `ext-address` field specify a real IP address of the node (the IP address is different on all hosts, this parameter is individual)
Also, you have to enable [[mempool]] auto processing on the **master** nodes.
```ini
# Mempool
[mempool]
# Automatically false, for enabling need role master or higher
auto-proc=true
```
### Network config
[[Cellframe Node Network Config]] is located in the `/opt/cellframe-node/etc/network/` catalog with the following name - `NetName.cfg` (in our case ` foobar.cfg`). Here [[Cellframe Node Chain Config]] is also located.
For the next stage, you have to get all 5 node addresses. You can obtain them by starting `cellframe-node` process and using [[Node Command - NET GET|net get status]] command.
Command for start the process:
```bash
systemctl start cellframe-node
```
Use [[Node Command - NET GET]].
`Command:`
```actionscript
cellframe-node-cli net get status -net Backbone
```
Instead of **Backbone** you can use any active network, list of active networks can be obtained by using [[Node Command - NET LIST|NET LIST]] command.
`Response:`
```actionscript
status:
net: Backbone
current_addr: ABCD::0000::0000::0000 (this is the node address)
links:
active: 1
total: 1
sync_status:
sync_datums: 20
total_datums: 20
percent: 100.000
states:
current: NET_STATE_ONLINE
target: NET_STATE_ONLINE
```
Then, make some changes in the [general] section of the network config:
```ini
[general]
id=0x000000000000ffff
name=foobar
native-ticker=BUZ
gdb-groups-prefix=foobar
bridged-network-ids = []
```
`id` - specify a new network ID which is unlike from other existing (for example, `0x2490100301000000`)
`name` - a new name of the network
`native-ticker` - a name of the native token for your network
`gdb-groups-prefix` - prefix name of the [[GDB]] tables, use the name of your network
`bridged-network-ids` - here you can specify ID's of the networks for bridge connections
```ini
# Possible values: light, full, archive, master, root
node-role=root
```
Specify `root` for the root nodes and `master` for the master ones.
```ini
seed-nodes-hosts=[]
```
Seed nodes are used for starting the network, it's like an entering point, only root nodes can serve for this purpose (here you must specify your seed nodes IP's or domain names and port).
Example: `[0.root.scorpion.cellframe.net:8079]` or `[109.202.1.195:8079]`.
```ini
#permanent-nodes-addrs=[]
```
It is optional parameter which is useful when you want some nodes to be connected with your node all the time, also your node connects to them first.
Example - [FE39::A741::BCD1::1920, FR87::A659::BCD1::2140].
```ini
links-required= 3
```
Here you must specify required number of links for node operation, it works the next way: if you specified, for example, 2 permanent node links, while the required number of links is 3, so the balancer will provide 1 additional link with another node.
```ini
#permanent-nodes-hosts= [ip/domain names:port]
```
Here you can specify hosts of permanent nodes for direct connection, if you want to synchronize firstly with exactly these nodes.
Then, let's specify the name of the certificate for the root nodes. This parameter is individual, after replacing original configuration files, paste the name of the certificate in every config separately.
On the root node 0:
```ini
[dag-poa]
events-sign-cert=foobar.root.pvt.0
```
On the root node 1:
```ini
[dag-poa]
events-sign-cert=foobar.root.pvt.1
```
After, do the same thing for the master nodes (also, specify additional parameters for [[ESBOCS Consensus]]).
On the master node 0:
```ini
[esbocs]
blocks-sign-cert=foobar.master.pvt.0
```
On the master node 1:
```ini
[esbocs]
blocks-sign-cert=foobar.master.pvt.1
```
On the master node 2:
```ini
[esbocs]
blocks-sign-cert=foobar.master.pvt.2
```
### Chain configs
Finally, make changes in the [[Cellframe Node Chain Config]] for both zerochain `chain-0.cfg` and mainchain `main.cfg`. In the section [files] change the name of the catalog, where chains will be stored:
```ini
[files]
storage-dir=../../../var/lib/network/foobar/zerochain/
```
The path must contain folder with your the name of your network:
`storage-dir=../../../var/lib/network/` your_network_name`/zerochain/`
#### Chain-0
This changes are needed to make on the both **root** and **master** nodes.
In the [chain] section, add authorized nodes. Authorized nodes have special permissions in the GDB groups, and some privileges in the network, they can write to nodelist or zerochain mempool, delete any orders and clean mempool (here you must specify privileged nodes).
```ini
authorized-nodes-addrs=[]
```
For example: authorized-nodes-addrs=[FE39::A741::BCD1::1920, FR87::A659::BCD1::2140]
In the [dag-poa] section of the `chain-0.cfg` file change name in the certificate's prefix:
```ini
[dag-poa]
auth-certs-prefix=foobar.root
auth-certs-number=2
auth-certs-number-verify=1
```
Change `auth-certs-prefix` value like this `network_name.root`.
Parameter `auth-certs-number` shows how many root certs will be in use in the network. In other words, how many certs will have the prefix `foobar.root`.
#### Main
Do the same thing in the [esbocs] section of the `main.cfg` file only for the **master** nodes. Also, specify addresses of the validators nodes (this role belongs to master nodes), without them a consensus won't start:
```ini
[esbocs]
min-validators-count=2
#poa-mode=true
auth-certs-prefix=foobar.master
validators-addrs=[FFFF::1234::0000::0000,FFFF::1234::0000::0001,FFFF::1234::0000::0002]
new-round-delay=45
```
Parameter `min-validators-count` shows how many validators are required to pass the consensus.
Change `auth-certs-prefix` value like this `network_name.master.
Paste all master node addresses who will play a validator role in your network in the `validators-addrs` parameter.
## End of preparation
We have already prepared two sets of configuration files, the one is for the **root** nodes, and the second is for the **master** nodes. Then, replace default config files of the corresponding nodes in the `/opt/cellframe-node/etc/` catalog with the newly created config files.
Start the nodes:
```bash
systemctl start cellframe-node
```
Use [[Node Command - NODE ADD]] to add node addresses into the node list.
From the root node add the rest nodes using this command.
`Syntax:`
```actionscript
node add -net <net_name> [-port] <port> [-host] <host> [-addr] <node_addr>
```
`Example:`
```actionscript
cellframe-node-cli node add -net foobar -addr 7869::7BE7::A2FF::01F8 -host 70.34.250.24:8079
```
After this, you can start the `cellframe-node` process on the all hosts, and do some checkages:
1. You can make sure that a new **foobar** network is set up, and the nodes "see" each other by using commands [[Node Command - NET LIST|NET LIST]], [[Node Command - NET GET|NET GET STATUS]] and [[Node Command - NODE DUMP|NODE DUMP]].
2. Make sure that DAG-POA consensus has started on the root nodes by reading log messages.
3. Also, you have to check the work of the ESBOCS consensus on the master nodes.
Master nodes (validators) won't work without [[fee|commissions]] specified. You have to use [[Node Command - SRV_STAKE ORDER CREATE|SRV_STAKE ORDER CREATE]] command for the every master node.
`Syntax:`
```actionscript
srv_stake order create -net <net_name> -value <value> -cert <priv_cert_name>
```
`Example:`
```actionscript
cellframe-node-cli srv_stake order create -net foobar -value 0.05e+18 -cert foobar.master.pvt.0
```
After this, restart the nodes:
```bash
systemctl stop cellframe-node
```
and
```bash
systemctl start cellframe-node
```
## DAG-POA consensus starting
In the current versions of the Cellframe networks, interaction with global blockchain ecosystems such as **ETH** and **BSC** is implemented via the [[bridge]]. The description of the emission center's operation and configuration is not included in the scope of this guide, but it is necessary to consider its functionality.
For security requirements, emissions can only be performed after being signed by the same certificates used during token declaration ([[Node Command - TOKEN DECL]]). Therefore, we need certificates for the bridge nodes, which can be created on any of the root nodes and then transferred to the respective bridge nodes during the emission center setup.
1. Create 3 certificates (the number of certificates may vary depending on emission center requirements, so there is a corresponding command - [[Node Command - TOKEN UPDATE]], which can update tokens, and in particular, sign it with additional certificates).
```actionscript
cellframe-node-tool cert create foobar.bridge.pvt.0 sig_dil
```
```actionscript
cellframe-node-tool cert create foobar.bridge.pvt.1 sig_dil
```
```actionscript
cellframe-node-tool cert create foobar.bridge.pvt.2 sig_dil
```
2. Declare the token via the [[Node Command - TOKEN DECL|TOKEN DECL]] command.
`Example (parameters are divided by line breaks for convenient):`
```actionscript
cellframe-node-cli token_decl
-net foobar
-chain zerochain
-token BUZ
-decimals 18
-signs_total 3
-signs_emission 2
-certs foobar.bridge.pvt.0,foobar.bridge.pvt.1,foobar.bridge.pvt.2
-type CF20
-total_supply 0
```
3. In case not all bridge certificates were used to sign token declaration datum, you can use the following command for signing datum by additional bridge certificates.
`Example (parameters are divided by line breaks for convenient):`
```actionscript
cellframe-node-cli token_decl_sign
-net foobar (name of the net)
-chain main (chain name)
-datum 0xFE3C0D5CEBAB54957121C01C12017164E516D60709B6BE10BC7EE98758BF4429 (hash of the declaration)
-certs foobar.bridge.pvt3 (enter required certificates)
```
After this, hash of the declaration datum will change.
4. Let's process the token declaration datum that is in the mempool of the zerochain using the [[Node Command - MEMPOOL PROC]].
`Example (parameters are divided by line breaks for convenient):`
```actionscript
cellframe-node-cli mempool proc
-net foobar (name of the net)
-chain zerochain (chain name)
-datum 0x990A5F50723B21BCEDFCB40EF09B9720AEAC2A4C92ADDCA5E778B53F569E186F (use changed hash)
```
5. After that, this datum will undergo consensus rounds, and eventually, the first event will be formed, which we must add to the zerochain configuration file as the genesis event. You can see the hash of this event in the logs or after some time following the execution of the declaration command using [[Node Command - DAG EVENT LIST]] with `-from events` parameter.
6. Stop the cellframe-node process on the root nodes and make changes to the zerochain configuration file in the [dag] section.
```ini
[dag]
is-single-line=true
is-celled=false
is-add-directly=false
datum-add-hashes-count=1
is-static-genesis-event=true "uncomment this string if it's commented"
static-genesis-event=
0x990A5F50723B21BCEDFCB40EF09B9720AEAC2A4C92ADDCA5E778B53F569E186F "here you must input previously given hash"
```
7. After that, you can start the node process on all hosts. Node synchronization will be almost instantaneous, and you can verify that the first event is presented everywhere using the [[Node Command - DAG EVENT LIST]].
## ESBOCS consensus starting
Let's execute token emission ([[Node Command - TOKEN EMIT]]) in the zerochain, and create [[basic transaction]].
1. [[Node Command - WALLET NEW|Create the wallet]] on the node with the bridge certificates:
```actionscript
cellframe-node-cli wallet new -w main_wallet
```
[[Node Command - WALLET INFO|Get its address]]:
```actionscript
cellframe-node-cli wallet info -w main_wallet -net foobar
```
2. Make some changes in the **master** nodes network `cellframe-node.cfg` configuration file.
```ini
[esbocs]
collecting-level=10.0
fee-addr=myaddr
```
`collecting-level` - when specified sum (in native token) is accumulated, validator's wallet automatically collects it
`fee-addr` - the name of the wallet, which will be used for collecting fees
3. Execute emission using [[Node Command - TOKEN EMIT]]:
`Example (parameters are divided by line breaks for convenient):`
```actionscript
cellframe-node-cli token_emit
-net foobar
-chain_emission zerochain
-no_base_tx
-token BUZ
-certs foobar.bridge.pvt.0,foobar.bridge.pvt.1,foobar.bridge.pvt.2
-emission_value
10000000000000000000000000000000000000000000000000000000000000
-addr
jrmnGqeeds4Dp67AaNgMRugT7deFuJeJsxwAnWnMGSixDnjQJt93WFja3HmXciJzDWnnKrHXmoT7jJ2q8RJ1ciTpvVgDN9D9Cf8vsrih
```
4. Let's process the emission datum in the zerochain's [[mempool]] using the [[Node Command - MEMPOOL PROC]]. Within a several minutes (the time of waiting depends on round duration, specified in the configuration), we should already see the emission [[event]] in the chain.
5. Hash of the emission appears in the terminal after requesting the [[Node Command - TOKEN EMIT|TOKEN EMIT]] command.
6. After that, we can perform a [[basic transaction]] in the mainchain, specifying the transaction [[fee]], which should be not less than the one specified in the network configuration, and the name of the certificate that will be used to sign the transaction.
`Example (parameters are divided by line breaks for convenient):`
```actionscript
cellframe-node-cli tx_create
-net foobar
-chain main
-emission_chain zerochain
-from_emission
0xA78BB75079DEC48FF67370DD2E8B47F3D69DDA26B4751C5D705B95E13F8A522A
-token BUZ
-to_addr
jrmnGqeeds4Dp67AaNgMRugT7deFuJeJsxwAnWnMGSixDnjQJt93WFja3HmXciJzDWnnKrHXmoT7jJ2q8RJ1ciTpvVgDN9D9Cf8vsrih
-value 10000000000000000000000000000000000000000000000000000000000000
-fee 0.05e+18
-certs foobar.root.pvt.0
```
7. Almost instantly, there will be generated the first block in the mainchain, which can be checked using [[Node Command - BLOCK LIST]]. Also, you can see how tokens come to the node wallet using [[Node Command - WALLET INFO]].
Eventually, a new network has started.