Intermediate

 

How to Run a Local Klaytn Network

Welcome to this tutorial on how to run a local Klaytn network. Running a local Klaytn network can be useful for testing and developing smart contracts and applications without the need to use the public Klaytn testnet or mainnet. In this tutorial, you will learn how to set up and run a local Klaytn network using the Klaytn Console. We will walk you through the steps needed to configure and start your local Klaytn network

The simplest way to test your Solidity contracts is to set up your own local Klaytn network. You’ll get 10 sample accounts and private keys to run transactions, unlimited API calls for unlimited testing, and no need to spend money on gas for your test transactions. Let’s get started!

1. Prerequisite – Install the necessary tools

We’ll need some basic tools to get started. Let’s download them from the links below:

Git: Install git and check the version using

git --version

 

Docker: Install docker and make sure the docker is running

Jq: Install Jq and check the version using

jq --version

 

2. Starting the Klaytn network

The git repository below has all the required scripts to run a dockerized version of the Klaytn network. Start by executing the following scripts:

$ git clone <https://github.com/klaytn/local-klaytn-deploy.git>
$ cd local-klaytn-deploy
$ ./1.prepare.sh
$ ./2.start.sh

 

It will deploy one Klaytn consensus network by default. The prepare script downloads the latest Klaytn docker image and boots up a local blockchain network in a docker container. The below parameters are the default for testnet in 1.prepare.sh.

 

3. Checking out the status of the Network

To check if the local Klaytn network is working well, first check the status of the docker containers. To do that, execute the following command:

$ ./3.status.sh

 

4. Getting logs

After executing 2.start.sh, it prints logs for the Klaytn network. If you want to print out the logs in another shell, execute the following command:

$ ./4.logs.sh

 

5. Stopping the network

To stop the network to reduce resource utilization of your machine, execute the following command:

$ ./5.stop.sh

 

6. Resuming the network

To resume the stopped network, execute the following command:

$ ./6.resume.sh

 

7. Terminate the network

To terminate all the resources in your machine, execute the following command:

$ ./7.terminate.sh

 

If you are able to run a local node successfully, you can go ahead and develop DApps on the Klaytn network

By this, you complete this workshop successfully!!