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

Updates next-hardhat README instructions #46

Merged
merged 12 commits into from
Aug 15, 2023
2 changes: 1 addition & 1 deletion .github/workflows/with_foundry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Install Nargo
uses: noir-lang/[email protected]
with:
toolchain: nightly
toolchain: 0.9.0

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
Expand Down
7 changes: 4 additions & 3 deletions next-hardhat/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,17 @@ yarn-error.log*
*.tsbuildinfo
next-env.d.ts

# contract

# hardhat
cache

# artifacts
typechain-types
proofs

# noir
crs

# other
.vscode
crs
.DS_Store
artifacts
83 changes: 60 additions & 23 deletions next-hardhat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,48 +10,85 @@ It also features multiple files and different entry points by resolving multiple

## Getting Started

1. [Install nargo nightly](https://noir-lang.org/getting_started/nargo_installation#option-1-noirup),
with `noirup -n`.
1. [Install Node.js ≥v18](https://nodejs.org/en) (tested on v18.17.0)

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

3. Install Nargo with the following instructions. We are working on a stable release that is
maintains compatibility across packages and will make it easier to install these packages.

> 1. [Install Nix](https://noir-lang.org/getting_started/nargo_installation#installing-nix)
>
> 2. Install Nargo with
>
> ```bash
> nix profile install github:noir-lang/noir/7d0178987641f5cb8f8e95507c54c3cc367bf7d2
> ```

4. Install dependencies with

```bash
yarn
```

3. Write circuits in `./circuits/src`.
5. Write circuits in `./circuits/src`.

You can read more about writing circuits in Noir on the [Noir docs](https://noir-lang.org/).

4. Create the verifier contract
6. Create the verifier contract

Navigate to the `.circuits/` directory and run `nargo codegen-verifier`
Navigate to the `.circuits/` directory and run

5. Compile your circuit
```bash
nargo codegen-verifier
```

Compile your circuits with `nargo compile`.
7. Compile your circuit

1. Deploy
Compile your circuits with

- Start a local development EVM at <http://localhost:8545>, for example with `npx hardhat node` or
`anvil`.
- Copy `./.env.example` to `./.env` and add keys for alchemy (to act as a node) and the deployer's
private key. Make sure you have funds in this account.
- Run `NETWORK=localhost yarn build` to build the project and deploy contracts to the local
development chain. If the deployment fails, try removing `yarn.lock` and reinstalling dependencies
with `yarn`.
```bash
nargo compile
```

You can choose any other network in `hardhat.config.ts` and deploy there using this `NETWORK`
environment variable. For example, `NETWORK=mumbai yarn build` or `NETWORK=sepolia yarn build`. Feel
free to contribute with other networks in `hardhat.config.ts`
## Testing locally

Once your contracts are deployed and the build is finished, start the web app with `yarn start`.
1. Copy `./.env.example` to a new file `./.env`.

## Testing
2. Start a local development EVM at <http://localhost:8545>, for example with `npx hardhat node` or
`anvil`.

There is a basic [example test file](./test/index.test.ts) that shows the usage of Noir in a
typescript `node.js` environment. You can run the tests with:
3. Run the [example test file](./test/index.test.ts) with

```sh
yarn test
```

The test demonstrates basic usage of Noir in a typescript `node.js` environment.

## Deploy locally (WIP)

1. Copy `./.env.example` to a new file `./.env`.

2. Start a local development EVM at <http://localhost:8545>, for example with `npx hardhat node` or
`anvil`.

3. Run `NETWORK=localhost yarn build` to build the project and deploy contracts to the local
development chain.

If the deployment fails, try removing `yarn.lock` and reinstalling dependencies with `yarn`.

4. Once your contracts are deployed and the build is finished, start the web app with `yarn start`.

## Deploying on other networks

You can choose any other network in `hardhat.config.ts` and deploy there using this `NETWORK`
environment variable. For example, `NETWORK=mumbai yarn build` or `NETWORK=sepolia yarn build`.

Make sure you:

- Update the deployer private keys in `./.env`
- Have funds in the deployer account
- Add keys for alchemy (to act as a node) in `./.env`

Feel free to contribute with other networks in `hardhat.config.ts`
4 changes: 2 additions & 2 deletions next-hardhat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"test": "hardhat compile && vitest"
},
"dependencies": {
"@aztec/bb.js": "^0.3.5",
"@noir-lang/acvm_js": "git+https://github.com/noir-lang/acvm-simulator-wasm.git",
"@aztec/bb.js": "0.3.6",
"@noir-lang/acvm_js": "git+https://git@github.com/noir-lang/acvm-simulator-wasm.git#b9d9ca9dfc5140839f23998d9466307215607c42",
"@nomicfoundation/hardhat-chai-matchers": "^1.0.6",
"@nomicfoundation/hardhat-network-helpers": "^1.0.0",
"@nomicfoundation/hardhat-toolbox": "^2.0.1",
Expand Down
2 changes: 1 addition & 1 deletion next-hardhat/utils/addresses.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"chainId":80001,"verifier":"0x75B9cBF10AeD42676465BE6552648cF02150D300"}
{"chainId":31337,"verifier":"0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0"}
6 changes: 3 additions & 3 deletions next-hardhat/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# yarn lockfile v1


"@aztec/bb.js@^0.3.5":
"@aztec/[email protected].6":
version "0.3.6"
resolved "https://registry.yarnpkg.com/@aztec/bb.js/-/bb.js-0.3.6.tgz#8865d119c0292291aef6f65250b5418d71bf12cb"
integrity sha512-7s/SZ3k5R1wfnVoU6sz9BBxBaI7ubkXPnvsI2KsJso2J2pwbXGxJsfOzn+uol+v3ZPooIa84/+SHk3UaPbMJGw==
Expand Down Expand Up @@ -790,9 +790,9 @@
"@nodelib/fs.scandir" "2.1.5"
fastq "^1.6.0"

"@noir-lang/acvm_js@git+https://github.com/noir-lang/acvm-simulator-wasm.git":
"@noir-lang/acvm_js@git+https://git@github.com/noir-lang/acvm-simulator-wasm.git#b9d9ca9dfc5140839f23998d9466307215607c42":
version "0.0.0-d576736"
resolved "git+https://github.com/noir-lang/acvm-simulator-wasm.git#b9d9ca9dfc5140839f23998d9466307215607c42"
resolved "git+https://git@github.com/noir-lang/acvm-simulator-wasm.git#b9d9ca9dfc5140839f23998d9466307215607c42"

"@nomicfoundation/[email protected]":
version "5.0.1"
Expand Down
2 changes: 1 addition & 1 deletion with-foundry/.env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
ANVIL_RPC=
PRIVATE_KEY=
SEPOLIA_RPC=https://rpc2.sepolia.org
SEPOLIA_RPC=https://rpc2.sepolia.org
Loading