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
Docker: Install docker and make sure the docker is running
Jq: Install Jq and check the version using
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
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
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:
4. Getting logs
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:
5. Stopping the network
To stop the network to reduce resource utilization of your machine, execute the following command:
6. Resuming the network
To resume the stopped network, execute the following command:
7. Terminate the network
To terminate all the resources in your machine, execute the following command:
Note: All the transactions and blocks you made will be lost.