Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update README #16

Merged
merged 3 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading