Deploy a Local Testnet

Cross-platform setup script for running a Klever localnet on your machine. Works on Linux, macOS, and Windows.

Prerequisites

Verify Python is installed:

python3 --version

Step 1 — Clone the Repository

Clone the repository to your machine:

git clone https://github.com/klever-io/kleverchain-localnet.git
cd kleverchain-localnet

Step 2 — Run the Setup

Run the one-command setup to generate keys, directories, and configuration files automatically:

# Linux/macOS
python3 setup.py setup-all

# Windows
python setup.py setup-all

This will automatically:

  1. Check all requirements
  2. Generate validator and wallet keys
  3. Create necessary directories
  4. Generate configuration files

Step 3 — Start the Localnet

# Linux/macOS
python3 setup.py start

# Windows
python setup.py start

Your local Klever testnet is now running.


Custom Configuration

You can configure the number of validators and the max token supply:

# Setup with 3 validators
python3 setup.py setup-all -n 3

# Setup with 3 validators and custom max supply
python3 setup.py setup-all -n 3 -s 10000000000000000

Available Commands

Setup

CommandDescription
setup-allComplete automated setup (keys + dirs + config)
check-requirementsVerify all dependencies are installed
generate-keys -n <N>Generate keys for N validators
generate-dirs -n <N>Create node directories
create-localnet -n <N>Generate configuration files
python3 setup.py setup-all -n 3
python3 setup.py check-requirements
python3 setup.py generate-keys -n 3
python3 setup.py generate-dirs -n 3
python3 setup.py create-localnet -n 3

Container Management

CommandDescription
startStart Docker containers
stopStop Docker containers
restartRestart Docker containers
statusShow container status
logsFollow container logs
logs --no-followPrint logs without following
python3 setup.py start
python3 setup.py stop
python3 setup.py restart
python3 setup.py status
python3 setup.py logs
python3 setup.py logs --no-follow

# Follow logs for a specific node
docker logs -f node-0

Cleanup

# Remove generated configs only
python3 setup.py clean

# Remove everything (keys, dbs, logs, configs)
python3 setup.py clean-all

Project Structure

After running setup-all, the directory structure will look like this:

kleverchain-localnet/
├── keys/
│   ├── node-0/
│   │   ├── validatorKey.pem
│   │   └── walletKey.pem
│   ├── node-1/
│   │   ├── validatorKey.pem
│   │   └── walletKey.pem
│   └── walletKey.pem        # Root wallet
├── dbs/
│   ├── node-0/
│   └── node-1/
├── logs/
│   ├── node-0/
│   └── node-1/
├── config/
│   └── node/
│       ├── genesis.json
│       ├── nodesSetup.json
│       ├── api.yaml
│       ├── config.yaml
│       ├── enableEpochs.yaml
│       └── external.yaml
├── docker-compose.yaml
└── setup.py

Root Wallet

In addition to the per-node wallet keys, a root wallet (keys/walletKey.pem) is generated at the root of the keys/ directory. This wallet is pre-funded in genesis and is intended for general use — sending transactions, deploying contracts, testing — without needing to use a validator's wallet directly.

It has a fixed genesis balance of 1,000,000 KLV and 1,000,000 KFI, deducted from the total supply before distributing to validators.


Resetting the Localnet

To wipe all state and start fresh:

python3 setup.py clean-all
python3 setup.py setup-all

Was this page helpful?