This example uses Next.js as the frontend framework, and Hardhat 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.
-
Install nargo version 0.9.0 with
noirup -v 0.9.0
-
Install dependencies with
yarn
- Write circuits in
./circuits/src
.
You can read more about writing circuits in Noir on the Noir docs.
- Create the verifier contract
Navigate to the .circuits/
directory and run nargo codegen-verifier
- Compile your circuit
Compile your circuits with nargo compile main
.
- Deploy
- Start a local development EVM at http://localhost:8545, for example with
npx hardhat node
. - 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
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
Once your contracts are deployed and the build is finished, start the web app with yarn start
.
There is a basic example test file that shows the usage of Noir in a typescript node.js
environment.
You can run the tests with:
yarn test