Configuration
This page explains the configuration of SCNs to form a consensus network.
If you installed archive distribution, you can find the binaries and the config file in the directories you extracted the archives. Below is an example of command execution.
$ homi-darwin-amd64/bin/homi setup ...
$ kscn-darwin-amd64/bin/kscnd start
$ vi kscn-darwin-amd64/conf/kscnd.confIn this tutorial, we will not always specify the full path to the command.
Creation of a Genesis File
First, you should create a genesis file and a nodekey file for your own service chain. You can create them using homi like below.
$ homi setup --gen-type local --cn-num 1 --servicechain -o ./homi-output
Created : homi-output/keys/passwd1
Created : homi-output/scripts/genesis.json
Created : homi-output/keys/nodekey1
Created : homi-output/keys/validator1
Created : homi-output/scripts/static-nodes.json
Created : homi-output/Klaytn.json
Created : homi-output/Klaytn_txpool.jsonBelow are examples of genesis file and nodekey file.
$ cat homi-output/scripts/genesis.json
{
"config": {
"chainId": 1000,
"istanbul": {
"epoch": 3600,
"policy": 0,
"sub": 22
},
"unitPrice": 0,
"deriveShaImpl": 2,
"governance": null
},
"timestamp": "0x5dca0732",
"extraData": "0x0000000000000000000000000000000000000000000000000000000000000000f85ad594f8690562c0839c44b17af421f7aaaa9f12dcc62bb8410000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0",
"governanceData": null,
"blockScore": "0x1",
"alloc": {
"f8690562c0839c44b17af421f7aaaa9f12dcc62b": {
"balance": "0x2540be400"
}
},
"number": "0x0",
"gasUsed": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
} Please change the chainID in the genesis file. Use your own number to prevent a replay attack. (Do not use the same chainID with Klaytn Cypress (8217) and Baobab (1001))
If you want, you can change the pre-funded addresses by editing "alloc" in the genesis file. (You can find more details in Genesis JSON.)
SCN Data Directory Creation
Considering the fact that the size of Klaytn blockchain data keeps increasing, it is recommended to use a big enough storage. You can create the data directory on your desired path. In this document, we create ~/kscnd_home as a data directory.
Initialization of a Genesis Block
After that, you can initialize the data directory with the genesis file. Before starting a service chain node, it is necessary to initialize the genesis block of the service chain network using kscn and genesis.json.
Install nodekey
Copy homi-output/keys/nodekey1 to the klay directory in the SCN's data directory like below.
Configuration of the SCN
kscnd.conf is the configuration file for the SCN.
Assume that the SCN uses the default port and mounts a large-scale partition onto ~/kscnd_home. In the default kscnd.conf file, SC_SUB_BRIDGE option is disabled and DATA_DIR is empty.
You can enable SC_SUB_BRIDGE to use the Anchoring/Value transfer feature. Also you should set the DATA_DIR like below.
If you want, you can further modify other options to customize your Service Chain. Otherwise, now you can finish the configuration and you are ready to run the service chain using the default configuration.
Last updated