> For the complete documentation index, see [llms.txt](https://docs.krnl.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.krnl.xyz/krnl-cli/overview.md).

# Overview

## **KRNL CLI Overview**

**KRNL CLI** is a command-line tool for developing, compiling, and deploying smart contracts using the KRNL Protocol. It simplifies project setup, manages Foundry installation, and provides commands for verification attestors.

#### Key Features

* Project initialization with Foundry setup
* Smart contract compilation with auto-detected directories
* Deployment via Forge scripts with network detection and optional verification
* Attestor creation for verification and proof workflows

#### Installation

Install globally using npm:

```bash
npm install -g @krnl-dev/krnl-cli
```

#### Quick Start

```bash
# Initialize a new KRNL project
krnl init --name my-project

# Compile contracts
krnl compile

# Deploy to a network
krnl deploy --network sepolia
```

***

## **KRNL CLI Commands**

#### `krnl init` – Initialize a project

Creates a new KRNL project with the default template. Sets up Foundry, installs dependencies, and generates `.env`.

**Options:**

| Flag                        | Description     | Default   |
| --------------------------- | --------------- | --------- |
| `-t, --template <template>` | Template to use | `default` |
| `-n, --name <name>`         | Project name    | —         |

**Example:**

```bash
krnl init --name my-krnl-project
cd my-krnl-project
```

***

#### `krnl compile` – Compile contracts

Compiles smart contracts with auto-detection of source and output directories.

**Options:**

| Flag                       | Description                    |
| -------------------------- | ------------------------------ |
| `-c, --contracts <path>`   | Contracts directory (optional) |
| `-o, --output <path>`      | Output directory (optional)    |
| `-p, --project-dir <path>` | Project root (optional)        |

**Example:**

```bash
krnl compile
krnl compile -c ./src -o ./out
```

***

#### `krnl deploy` – Deploy contracts

Deploys contracts using Foundry scripts. Auto-detects network from `.env` and `foundry.toml`. Supports optional verification.

**Options:**

| Flag                        | Description                                                         | Default               |
| --------------------------- | ------------------------------------------------------------------- | --------------------- |
| `-n, --network <network>`   | Deployment network                                                  | `localhost`           |
| `--script <pathOrTarget>`   | Forge script path                                                   | `script/Deploy.s.sol` |
| `--verify`                  | Verify contract on explorer. requires `--contract`                  | —                     |
| `--verify-all`              | Verify all the contract being deployed using the script on explorer | —                     |
| `--contract <name>`         | Contract name to verify (required with `--verify` and `--script`)   | —                     |
| `--constructor-args <args>` | Constructor arguments for verification (if needed)                  | —                     |

**Example:**

```bash
# Deploy using default script to sepolia
krnl deploy --network sepolia

# Deploy with verification of a specific contract
krnl deploy --network sepolia --verify --contract RealEstateInvestment

# Deploy with verification of all contracts in script
krnl deploy --network sepolia --verify --verify-all

# Use custom script with specific contract target
krnl deploy --network sepolia --script "script/Deploy.s.sol:DeployRealEstateScript" --verify --contract RealEstateInvestment

# Use custom script and verify all the contracts
krnl deploy --network sepolia --script "script/Deploy.s.sol:DeployRealEstateScript" --verify-all

# Deploy to localhost (requires Anvil running)
krnl deploy --network localhost
```

***

## **KRNL CLI: Create Attestor**

#### `krnl create-attestor` – Generate a verification attestor

Creates a Docker-based attestor for contract verification. Attestors are required to submit proof-enabled actions on KRNL Protocol workflows.

**Usage:**

```bash
krnl create-attestor
```

This command executes the included `create-attestor-standalone.sh` script.

**Notes:**

* Requires Docker installed and running
* Automatically sets up the attestor environment for standalone usage
* Can be used in CI/CD pipelines for automated attestor generation


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.krnl.xyz/krnl-cli/overview.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
