Blockchain client configuration

How to configure a blockchain client.

On this page, you’ll learn:

  • Which config options can be changed by node operators?

  • Which config options can only be changed by blockchain developers?

  • What is the default configuration of a client, and where to find it?

  • How to create and use a custom configuration for the client?

Node config reference

To get a complete overview of all configuration options for the Klayr SDK, please refer to the Client configuration.

Configurations for the blockchain developer

A blockchain developer sets the following configurations. A node operator should not change them.

Configurations for the node operator

The following configurations can be changed by the node operator:

Default configuration

The default node configuration is used, if no other config is specified when starting the node.

After initialization

When a new client is initialized with klayr init, a default config template for the client is generated under config/default/.

This config is only a template, which is used to generate a default configuration on the initial start of the node. After the node is started, it will use the config in the client data folder.
Path of the node config template
<BLOCKCHAIN_CLIENT>/config/default/config.json

After the first start

When the blockchain client is started for the first time, the config is copied from the template to the folder for the node data, which is located under ~/.klayr/<CLIENT_NAME>/.

The blockchain client will always use the config in the client data folder by default, if no custom config is specified.

Client config path
~/.klayr/<CLIENT_NAME>/config/config.json

How to use a custom configuration

A best practice to create a custom configuration for a blockchain client is to copy an existing config.json, and then adjust it to suit your requirements.

In the root directory of the blockchain client
cp config/default/config.json config/custom_config.json

To use the custom config in the blockchain client, add the --config flag to the start command and specify the path to the configuration file.

The flag --overwrite-config overwrites the existing config, in case a different config was previously used before.

./bin/run start --config config/custom_config.json --overwrite-config

Example: Configuration for the Hello World client

For the Hello World client, create a custom_config.json, as explained in the previous step How to use a custom configuration.

Then, adjust the RPC configuration as follows:

config/custom_config.json
{
	// [...]

	"rpc": {
		"modes": [
			"ipc",
			"ws",
			"http"
		],
		"port": 7887,
		"host": "127.0.0.1",
		"allowedMethods": [
			"*"
		]
	},

	// [...]
}

This will start the node with the enabled API for IPC, WS, and HTTP.

Such configuration allows sending transactions and other RPC API requests to the node with tools such as Postman or cURL, which use the HTTP protocol.

Whereas the IPC and WS modes can entertain RPC requests made to the node.

The allowedMethods:[*] configuration will allow the node to access all the endpoints offered by various Klayr modules.

After updating the custom_config.json file, restart the client with the --overwrite-config flag to apply the new configuration.

hello_client/
./bin/run start --config config/custom_config.json --overwrite-config

The configuration for the Hello World client is adjusted further in the following guides: