Skip to main content

Quick start for Kadena developers

Welcome to the Kadena development Quick start guide. Follow these simplified instructions to set up your development environment with a local blockchain and developer tools, then write your first contract using the Pact smart contract programming language.

Before you begin

Before you begin, verify your computer meets the following basic requirements and has the following tools installed:

  • Access to the internet, an interactive terminal shell, and a web browser.

  • Git version control program. You can verify that git is installed by running git --version on your computer.

  • Node.js, version 18 or higher. You can verify that node.js is installed by running node --version on your computer.

  • npm, the command-line interface for the node package manager. You can verify that npm is installed by running npm --version on your computer.

  • Docker, version x or higher. You can verify that docker is installed by running docker --version on your computer.

If you have everything you need, you can set up your development environment and deploy your first contract with a few basic steps.

Install Pact

The Pact smart contract programming language is specifically designed for writing smart contracts to run safely and efficiently on the Kadena blockchain network. Follow the appropriate instructions for your operating system to install Pact.

For more information about installing Pact, see Installation and setup.

Set up a local network

The Kadena development network allows you to run a standalone local blockchain node to simulate network operations and to test your smart contracts locally before deploying to a test or production network.

To set up the local network, open a terminal shell on your computer then run the following commands to get the development network Docker image and start the network in a Docker container:

git clone https://github.com/kadena-io/devnet
cd devnet
npm install
docker run --rm --interactive --tty --publish 8080:8080 --volume kadena_devnet:/data --name devnet kadena/devnet

For more information about starting the Kadena development network in a Docker container, see Set up the local network.

Install the Kadena command-line interface

The Kadena command-line interface (kadena-cli) provides direct access to the Kadena blockchain and commands to create, test, deploy, and manage applications for the Kadena network. You can use the Kadena command-line interface interactively or in scripts and automated workflows.

To install and configure the kadena-cli program, open a terminal shell on your computer then run the following commands:

npm install --global @kadena/kadena-cli
kadena config init

The kadena config init command creates the .kadena configuration folder location in your current working directory and adds default network settings to a networks subfolder, then prompts you to create a wallet. Wallets are an important part of interacting with any blockchain, so you can create one now as part of your initial configuration steps. Follow the prompts displayed to continue setting up your local development environment with a development wallet and an account.

For more information about getting started with kadena-cli commands, see Develop with kadena-cli. For command-line reference information, see kadena-cli command reference.

Write your first smart contract

You can now write and execute a simple greeting smart contract using the Pact smart contract programming language and the Pact interactive interpreter.

  1. Open a terminal shell on your computer.

  2. Start the Pact interpreter that you installed in the first step by running the following command:

    pact
  3. Copy and paste the following simple greeting module code, then press return:

    (module greeting GOVERNANCE
    (defcap GOVERNANCE () true)
    (defun say-hello(name:string)
    (format "Hello, {}! ~ from Kadena" [name])
    )
    )

    You should see the module loaded with output similar to the following:

    "Loaded module greeting, hash f1yyXqj5HstOni1QdZmuagUJXbu72VmYiwXua7Vp4-0"
  4. Call the say-hello function with a string similar to the following:

    (say-hello "Pistolas")

    The function returns a greeting similar to the following:

    "Hello, Pistolas! ~ from Kadena"

    If you want to deploy this contract on the local development network, copy the module code to a file with the .pact file extension—for example, create a greeting.pact file—then create a transaction to deploy the module as described in Deploy smart contracts.

    You can exit the Pact interpreter by pressing control-d on the keyboard.

Next steps

Congratulations! In this Quick start, you learned the basics of how to set up a development environment with the Pact programming language, a local development network, and the Kadena developer command-line interface. You also got a first look at how to write and execute a simple Pact contract in the interactive interpreter. You can learn more about these topics in Smart contracts documentation.

Here are some suggested next steps: