# 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
