Skip to content

Commit

Permalink
Merge pull request #61 from noir-lang/zpedro/vite_hardhat
Browse files Browse the repository at this point in the history
feat: moving from next to vite
  • Loading branch information
signorecello authored Dec 7, 2023
2 parents ea37bd4 + 9ef86ba commit 0b662cd
Show file tree
Hide file tree
Showing 37 changed files with 3,152 additions and 595 deletions.
Binary file removed .DS_Store
Binary file not shown.
15 changes: 6 additions & 9 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
FROM alpine:3.18.5 as noir
RUN apk add curl bash git tar gzip libc++-dev
RUN mkdir -p root/.nargo/bin
RUN curl -# -L https://github.com/noir-lang/noir/releases/latest/download/nargo-x86_64-unknown-linux-musl.tar.gz | tar -xzC root/.nargo/bin

FROM alpine:3.18.5
COPY --from=noir /root/.nargo /root/.nargo
ENV NARGO_HOME="/root/.nargo/bin"
ENV PATH="$NARGO_HOME:$PATH"
FROM --platform=linux/amd64 node:lts-bookworm-slim
SHELL ["/bin/bash", "-c"]
RUN apt update && apt install -y curl bash git tar gzip libc++-dev
RUN curl -L https://raw.githubusercontent.com/noir-lang/noirup/main/install | bash
ENV PATH="/root/.nargo/bin:$PATH"
RUN noirup
ENTRYPOINT ["nargo"]
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@

node_modules
package-lock.json
package.json
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Use templates as a starting point for your project.

- Next.js + Hardhat: [`./next-hardhat`](./next-hardhat)
- Foundry: [`./with-foundry`](./with-foundry)
- Vite + Hardhat: [`./vite-hardhat`](./vite-hardhat)

## Example Projects

Expand Down
45 changes: 44 additions & 1 deletion next-hardhat/circuits/target/noirstarter.json
Original file line number Diff line number Diff line change
@@ -1 +1,44 @@
{"hash":11749626988244162825,"backend":"acvm-backend-barretenberg","abi":{"parameters":[{"name":"x","type":{"kind":"field"},"visibility":"private"},{"name":"y","type":{"kind":"field"},"visibility":"public"}],"param_witnesses":{"x":[1],"y":[2]},"return_type":null,"return_witnesses":[]},"bytecode":"H4sIAAAAAAAA/7VTQQ6EIAwsKh73LS0FKbf9ypLF/z/BxGBClJtlLiUcpjPTdgUAC0/MtX5rxXcg03Axbt6X6Aox/dClLAF9yJuQUJDwd8JcxEtMOUVM5LnQHhLvlWxS5Jr1PJ5cppOlUc5SU3Ord+m8p85OrAM8wa3PPcdP50+1+YghLQN4Legt/yjfVn9G2FA+NL/NwYL+QZlGZ3tEFw56E7wBeQUAAA=="}
{
"noir_version": "0.18.0+1de0e6d0acb18f3164a3b1fbc1be6438ef16be39",
"hash": 16035314490478570843,
"backend": "acvm-backend-barretenberg",
"abi": {
"parameters": [
{
"name": "x",
"type": {
"kind": "field"
},
"visibility": "private"
},
{
"name": "y",
"type": {
"kind": "field"
},
"visibility": "public"
},
{
"name": "z",
"type": {
"kind": "field"
},
"visibility": "public"
}
],
"param_witnesses": {
"x": [
1
],
"y": [
2
],
"z": [
3
]
},
"return_type": null,
"return_witnesses": []
},
"bytecode": "H4sIAAAAAAAA/+1U0Q6DIAysOpnsYd/SCmh526/MDP//EzYylxD1zTbZkl1CSngo1zs4CwAX2KJZ6m2pDgfv09gncnTHPk4c0IdpYGIKHB49O5fY8xinOGIk7xLNIboZ36iKXngMVAvyOsnxwqxZtaNltdISj4EkOZd829c6Lft65y0YhVlgdc9av+vOmejlGua0Cn0NyD16rbmNvEdYtNxwPqqDUeIpHZ61oE+NIK8z/F54SnIu+XbwD08RczqFvha+Ozzz3FbeI9XwtCD/kXL9fJ5cG9jiCSvxgUKyCgAA"
}
39 changes: 0 additions & 39 deletions next-hardhat/next.config.js

This file was deleted.

43 changes: 0 additions & 43 deletions next-hardhat/package.json

This file was deleted.

10 changes: 0 additions & 10 deletions next-hardhat/pages/_app.js

This file was deleted.

15 changes: 0 additions & 15 deletions next-hardhat/pages/api/readCircuitFile.ts

This file was deleted.

6 changes: 0 additions & 6 deletions next-hardhat/pages/index.tsx

This file was deleted.

1 change: 0 additions & 1 deletion next-hardhat/utils/addresses.json

This file was deleted.

57 changes: 0 additions & 57 deletions next-hardhat/utils/ethers.tsx

This file was deleted.

File renamed without changes.
5 changes: 4 additions & 1 deletion next-hardhat/.gitignore → vite-hardhat/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,7 @@ crs
.vscode
.DS_Store
artifacts
.yarn/
.yarn/

circuits/target
dist
File renamed without changes.
File renamed without changes.
File renamed without changes.
39 changes: 13 additions & 26 deletions next-hardhat/README.md → vite-hardhat/README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,28 @@
# Noir with Next and Hardhat
# Noir with Vite and Hardhat

[![Netlify Status](https://api.netlify.com/api/v1/badges/e4bd1ebc-6be1-4ed2-8be8-18f70382ae22/deploy-status)](https://app.netlify.com/sites/noir-next-hardhat/deploys)
[![Netlify Status](https://api.netlify.com/api/v1/badges/e4bd1ebc-6be1-4ed2-8be8-18f70382ae22/deploy-status)](https://app.netlify.com/sites/noir-vite-hardhat/deploys)

This example uses [Next.js](https://nextjs.org/) as the frontend framework, and
This example uses [Vite](https://vite.dev/) as the frontend framework, and
[Hardhat](https://hardhat.org/) to deploy and test.

It also features multiple files and different entry points by resolving multiple files and using the
`entry_point` parameter to the `compile` function.

## Getting Started

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

2. Install [Node.js ≥v18](https://nodejs.org/en) (tested on v18.17.0)
2. Install [Node.js >20.10 (latest LTS)](https://nodejs.org/en) (tested on v18.17.0)

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

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

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

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

If you had a lower version of `nargo` installed previously and are running into errors when
compiling, you may need to uninstall it, instructions
[here](https://noir-lang.org/getting_started/nargo_installation#uninstalling-nargo).

5. Install dependencies with

```bash
Expand All @@ -53,21 +46,15 @@ compiling, you may need to uninstall it, instructions
nargo codegen-verifier
```

9. Compile your Noir program with

```bash
nargo compile
```

10. Navigate back into the _next-hardhat_ directory with
9. Navigate back into the vite-hardhat_ directory with

```bash
cd ..
```

## Test locally

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

2. Start a local development EVM at <http://localhost:8545> with

Expand All @@ -91,7 +78,7 @@ The test demonstrates basic usage of Noir in a TypeScript Node.js environment.

## Deploy locally

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

2. Start a local development EVM at <http://localhost:8545> with

Expand All @@ -114,10 +101,10 @@ The test demonstrates basic usage of Noir in a TypeScript Node.js environment.
> **Note:** 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
4. Once your contracts are deployed and the build is finished, you can preview the built website with

```bash
yarn start
yarn preview
```

## Deploy on networks
Expand All @@ -129,8 +116,8 @@ For example, `NETWORK=mumbai yarn build` or `NETWORK=sepolia yarn build`.

Make sure you:

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

Feel free to contribute with other networks in `hardhat.config.ts`
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
name = "noirstarter"
type = "bin"
authors = [""]
compiler_version = "0.11.0"
compiler_version = "0.19.4"

[dependencies]
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
x = "1"
y = "2"
z = "3"
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
y = "0x0000000000000000000000000000000000000000000000000000000000000002"
z = "0x0000000000000000000000000000000000000000000000000000000000000003"
Loading

0 comments on commit 0b662cd

Please sign in to comment.