@solarity/zktype
TypeScript icon, indicating that this package has built-in type declarations

0.3.1 • Public • Published

npm License: MIT

ZKType - TypeScript bindings for Circom circuits

ZKType simplifies and makes user-friendly the process of working with Circom circuits.

  • Generate a zkit wrapper for given circuits.
  • Ensure that all inputs and proofs are correctly formatted.

Installation

To install the package, run:

npm install --save-dev @solarity/zktype

Usage

[!IMPORTANT] ZKType is not meant to be used directly as its fitness relies heavily on the environment, e.g., on Circom compilation artifacts management. Consider using hardhat-zkit, which is a complete, developer-friendly package.

CircuitTypesGenerator

CircuitTypesGenerator is an entry point for generating TypeScript bindings for a given circuit.

To create a CircuitTypesGenerator object, it is necessary to pass a config:

ZKTypeConfig = {
  basePath: string;
  projectRoot: string;
  circuitsASTPaths: string[];
  outputTypesDir?: string;
};

This config contains all the information required to generate TypeScript bindings for given circuits.

  • basePath - Path to the root directory of the project where circuits are stored.
  • projectRoot - Absolute path to the root directory of the project.
  • circuitsArtifactsPaths - Array of paths to the circuits' Artifact files.
  • outputTypesDir - Path to the directory where the generated types will be stored.
    • Optional. Default: generated-types/circuits.

generateTypes()

Generates TypeScript bindings for the given circuits, based on the provided config.

const generator = new CircuitTypesGenerator(config);
await generator.generateTypes();

Also, this function generates the hardhat.d.ts file, where you can find all of the possible objects that can be retrieved by the function below.

getCircuitObject(circuitName: string): Promise

Returns the constructible object for the given circuit.

const generator = new CircuitTypesGenerator(config);
await generator.generateTypes();
const circuitObject = await generator.getCircuitObject("MyCircuit");

After the circuitObject is retrieved, check out the zkit documentation to see how to work with it.

To ensure that the object can be imported, check the hardhat.d.ts file.

Dependents (1)

Package Sidebar

Install

npm i @solarity/zktype

Weekly Downloads

35

Version

0.3.1

License

MIT

Unpacked Size

112 kB

Total Files

76

Last publish

Collaborators

  • hrom_h
  • arvolear