zkkit init

Initialize a new zkkit project with the required structure and configuration

Description

The init command scaffolds a new zkkit project structure with directories for circuits, inputs, and outputs. It also creates a sample Circom circuit and input file to get you started.

What it creates: This is a convenience command that sets up the folder structure and sample files. No external tools are called - it simply creates directories and writes starter files.

Usage

bash
zkkit init [project-name]

Examples

Initialize a new project in the current directory:

bash
zkkit init

Initialize a new project with a specific name:

bash
zkkit init my-zk-project

What Gets Created

  • circuits/ - Directory for your circuit files
  • build/ - Directory for compiled circuits
  • zkkit.config.json - Project configuration file
  • package.json - Node.js dependencies

Implementation

View how this command works under the hood:

src/commands/init.js

import fs from "fs-extra";

export default async function init() {
  await fs.ensureDir("circuits");
  await fs.ensureDir("inputs");
  await fs.ensureDir("outputs");

  await fs.writeJson("inputs/inputs.json", { a: 3, b: 11 });
  await fs.writeFile("circuits/schema.circom", `
// your circuit here

pragma circom 2.0.0;

template SumProduct(){
    // Inputs
    signal input a;
    signal input b;

    // Outputs
    signal output sum;
    signal output product;

    // Constraints 
    sum <== a + b;
    product <== a * b;
}

component main = SumProduct();
  `);
  
  console.log("✔ Project initialized");
}

What it does:

  • Creates three essential directories using fs.ensureDir()
  • Generates a default inputs.json with sample values (a=3, b=11)
  • Creates a template Circom circuit file with a simple SumProduct example
  • Outputs a success message when complete