Run your private testnet with single validator

Intro

The fastest and easiest way to test KLY abilities is to run a local single-node network. This network contains:

  • 1 node(which is validator)

  • 1 shard(validator is also a shard creator)

This allows you to check transactions sending, contracts calls and major part of available KLY features. Definitely, to discover more you'll need to run multi-node network(for example, to check how sharding works, test cross-shard interactions and so on).

Prepare genesis and configs

As you remember, to run or join any network you need genesis and configs.

Genesis is a common startpoint where state of accounts pre-set and your node take the data about the first epoch.

Configs are set of files that you can change in a flexible way to play with your node abilities, use plugins, change the node keypair, JSON-RPC routes and so on!

First of all - choose the location where genesis, configs and chain data will be stored. Imagine that it's directory $HOME/klyntar

mkdir $HOME/klyntar

cd $HOME/klyntar

Now, create the subdirectorites for genesis and configs

mkdir CONFIGS GENESIS

Set configuration files

Go to CONFIGS directory and add the following files there

cd CONFIGS

Set genesis

Now, go to GENESIS directory and add the appropriate genesis file there

Finally

Now, the hierarchy should looks like this

β”‚
β”œβ”€β”€β”€CONFIGS
β”‚   β”œβ”€β”€β”€kly_wvm.json
β”‚   β”œβ”€β”€β”€kly_evm.json
β”‚   β”œβ”€β”€β”€workflow.json
└───GENESIS
    β”œβ”€β”€β”€genesis.json

Once you run your node, the structure will be

β”œβ”€β”€β”€CHAINDATA
β”‚   β”œβ”€β”€β”€0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef#0
β”‚   β”œβ”€β”€β”€APPROVEMENT_THREAD_METADATA
β”‚   β”œβ”€β”€β”€BLOCKS
β”‚   β”œβ”€β”€β”€EPOCH_DATA
β”‚   β”œβ”€β”€β”€KLY_EVM
β”‚   └───STATE
β”‚
β”œβ”€β”€β”€CONFIGS
β”‚   β”œβ”€β”€β”€kly_wvm.json
β”‚   β”œβ”€β”€β”€kly_evm.json
β”‚   β”œβ”€β”€β”€workflow.json
└───GENESIS
    β”œβ”€β”€β”€genesis.json

These three directories contain everything necessary for the correct operation of the node

Prepare the env variables

In the environment variables you should specify the core launch mode (testnet/mainnet) and the path to a directory with 3 subdirectories (mentioned earlier). You can set these variables in your shell configuration files (e.g., .bashrc or .zshrc), depending on your OS.

export KLY_MODE=testnet

# Choose your own path
export SYMBIOTE_DIR=$HOME/klyntar

Set appropriate first epoch time

In order to run your local testnet correctly, you need to make some changes to the genesis file. Namely, you need to set the start time of the current epoch.

To get the current time, use the following JS snippet

console.log(new Date().getTime()) // E.g: 1719237980952

Now, modify the genesis.json:

"EPOCH_TIMESTAMP": 1719237980952

Now, you can run your node. From your console run:

klyntar

And you have to see the following:

The password to decrypt your private key(stored in workflow.json, encrypted by AES-256) is qwerty

DO NOT USE THIS PASSWORD FOR PRODUCTION TO PREVENT BRUTEFORCING / DICTIONARY ATTACKS

Keep it work

Once you run node, leave this console and start to work with KLY. Now you can call APIs, create/send transactions, interact with smart-contracts and so on

IMPORTANT

Due to the nature of consensus, the network must generate at least 1 block per epoch in order to correctly change epochs and continue fault-tolerant work

Last updated