Skip to content

Commit

Permalink
Merge pull request #70 from noir-lang/zpedro/cb_preparation
Browse files Browse the repository at this point in the history
updating READMEs for circuit breaker
  • Loading branch information
signorecello authored Feb 4, 2024
2 parents 7cab5e0 + ec4c8fd commit 9dfc45b
Show file tree
Hide file tree
Showing 7 changed files with 550 additions and 37 deletions.
2 changes: 0 additions & 2 deletions .github/scripts/latest.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
const { writeFileSync } = require('fs');

const GITHUB_PAGES = 3;

async function main() {
Expand Down
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@ This is a reference repo to help you get started with writing zero-knowledge cir

Each project is an example you can use as template. Feel free to mix them in order to find the best combination of technology that suits your needs.

## Templates
## Getting started

Use templates as a starting point for your project.
If you have [node](https://nodejs.org/en/download) installed, just open a terminal and run:

```bash
npx create-noir
```

### Templates

- Foundry: [`./with-foundry`](./with-foundry)
- Vite + Hardhat: [`./vite-hardhat`](./vite-hardhat)
Expand Down
39 changes: 39 additions & 0 deletions npx.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env node
import { Command } from 'commander';
import select from '@inquirer/select';
import input from '@inquirer/input';
const program = new Command();
import tiged from 'tiged';

program.action(async () => {
const appType = await select({
message: 'Please choose an option:',
choices: [
{ value: 'vite-hardhat', name: 'Browser App using Vite' },
{ value: 'with-foundry', name: 'Solidity App using Foundry' },
],
});

console.log(`You chose: ${appType}`);

const appName = await input({
message: 'Your app name:',
default: 'my-noir-app',
});

const emitter = tiged(`noir-lang/noir-starter/${appType}`, {
disableCache: true,
force: true,
verbose: true,
});

emitter.on('info', info => {
console.log(info.message);
});

emitter.clone(`./${appName}`).then(() => {
console.log('done');
});
});

program.parse();
15 changes: 15 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "create-noir",
"version": "0.1.1",
"type": "module",
"description": "This is a reference repo to help you get started with writing zero-knowledge circuits with [Noir](https://noir-lang.org/).",
"bin": "npx.js",
"author": "",
"license": "ISC",
"dependencies": {
"@inquirer/input": "^1.2.16",
"@inquirer/select": "^1.3.3",
"commander": "^11.1.0",
"tiged": "^2.12.6"
}
}
42 changes: 19 additions & 23 deletions vite-hardhat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ This example uses [Vite](https://vite.dev/) as the frontend framework, and

## Getting Started

Want to get started in a pinch? Start your project in a free Github Codespace!

[![Start your project in a free Github Codespace!](https://github.com/codespaces/badge.svg)](https://codespaces.new/noir-lang/noir-starter/tree/main)

In the meantime, follow these simple steps to work on your own machine:

1. Install [yarn](https://yarnpkg.com/) (tested on yarn v1.22.19)

2. Install [Node.js >20.10 (latest LTS)](https://nodejs.org/en) (tested on v18.17.0)
Expand All @@ -17,10 +23,10 @@ This example uses [Vite](https://vite.dev/) as the frontend framework, and
curl -L https://raw.githubusercontent.com/noir-lang/noirup/main/install | bash
```

4. Install Nargo v0.19.4 with
4. Install Nargo with

```bash
noirup -v 0.19.4
noirup
```

5. Install dependencies with
Expand All @@ -29,30 +35,20 @@ This example uses [Vite](https://vite.dev/) as the frontend framework, and
yarn
```

6. Navigate to the circuits directory with

```bash
cd circuits
```

7. Write your Noir program in `./circuits/src`.

> **Note:** You can read more about writing Noir programs in the
> [Noir docs](https://noir-lang.org/).
## Generate verifier contract

8. Generate the verifier contract with
### Contract

```bash
nargo codegen-verifier
```
The deployment assumes a verifier contract has been generated by nargo. In order to do this, run:

9. Navigate back into the vite-hardhat_ directory with
```bash
cd circuits
nargo codegen-verifier
```

```bash
cd ..
```
A file named `plonk_vk.sol` should appear in the `circuits/contracts/with_foundry` folder.

## Test locally
### Test locally

1. Copy `vite-hardhat/.env.example` to a new file `vite-hardhat/.env`.

Expand All @@ -76,7 +72,7 @@ This example uses [Vite](https://vite.dev/) as the frontend framework, and

The test demonstrates basic usage of Noir in a TypeScript Node.js environment.

## Deploy locally
### Deploy locally

1. Copy `vite-hardhat/.env.example` to a new file `vite-hardhat/.env`.

Expand Down Expand Up @@ -107,7 +103,7 @@ The test demonstrates basic usage of Noir in a TypeScript Node.js environment.
yarn preview
```

## Deploy on networks
### Deploy on networks

You can choose any other network in `hardhat.config.ts` and deploy there using this `NETWORK`
environment variable.
Expand Down
30 changes: 20 additions & 10 deletions with-foundry/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,35 @@ This example uses Foundry to deploy and test a verifier.

## Getting Started

### Install nargo
Want to get started in a pinch? Start your project in a free Github Codespace!

Follow the [Noir Docs](https://noir-lang.org/getting_started/nargo_installation) to install nargo.
For this template, ensure you're using Noir version 0.11.0 You can install with `noirup -v 0.11.0`.
[![Start your project in a free Github Codespace!](https://github.com/codespaces/badge.svg)](https://codespaces.new/noir-lang/noir-starter)

### Install foundryup
In the meantime, follow these simple steps to work on your own machine:

run
Install [noirup](https://noir-lang.org/getting_started/nargo_installation/#option-1-noirup) with

1. Install [noirup](https://noir-lang.org/getting_started/nargo_installation/#option-1-noirup):

```bash
curl -L https://raw.githubusercontent.com/noir-lang/noirup/main/install | bash
```

2. Install Nargo:

```bash
noirup
```

3. Install foundryup and follow the instructions on screen. You should then have all the foundry tools like `forge`, `cast`, `anvil` and `chisel`.

```bash
curl -L https://foundry.paradigm.xyz | bash
```

and follow the instructions on screen. You should then have all the foundry tools like `forge`,
`cast`, `anvil` and `chisel`.

### Generate verifier contract and proof
## Generate verifier contract and proof

#### Contract
### Contract

The deployment assumes a verifier contract has been generated by nargo. In order to do this, run:

Expand Down
Loading

0 comments on commit 9dfc45b

Please sign in to comment.