Skip to content

Commit

Permalink
Update README (#16)
Browse files Browse the repository at this point in the history
* Updated README

* Updated versions

* Updated config example
  • Loading branch information
KyrylR authored Nov 4, 2024
1 parent 9735c9c commit 144dee8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
23 changes: 14 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,20 @@ To create a `CircuitTypesGenerator` object, it is necessary to pass a config:

```typescript
ZKTypeConfig = {
basePath: string;
projectRoot: string;
circuitsASTPaths: string[];
outputTypesDir?: string;
};
basePath: "circuits",
projectRoot: process.cwd(),
circuitsArtifactsPaths: [
"circuits/auth/Matrix_artifacts.json",
],
outputTypesDir: "generated-types/circuits",
}
```

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.
- `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`.

Expand All @@ -53,18 +55,21 @@ 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.
Also, this function generates the `hardhat.d.ts` file, where you can find all the possible objects that can be retrieved by the function below.

#### getCircuitObject(circuitName: string): Promise<any>
#### getCircuitObject(circuitName: string, protocolType?: string): Promise<any>

Returns the constructible object for the given circuit.

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

The package supports generation of circuits by the `groth16` and `plonk` protocols at the same time.
In this case, you will have to specify the protocol type when retrieving the object.

After the `circuitObject` is retrieved, check out the [zkit](https://github.com/dl-solarity/zkit) documentation to see how to work with it.

To ensure that the object can be imported, check the `hardhat.d.ts` file.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@solarity/zktype",
"version": "0.4.0-rc.1",
"version": "0.4.0",
"description": "Unleash TypeScript bindings for Circom circuits",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down

0 comments on commit 144dee8

Please sign in to comment.