Skip to content

Latest commit

 

History

History
 
 

vite-hardhat

Noir with Vite and Hardhat

Netlify Status

This example uses Vite as the frontend framework, and Hardhat to deploy and test.

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!

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

  1. Install yarn (tested on yarn v1.22.19)

  2. Install Node.js >20.10 (latest LTS) (tested on v18.17.0)

  3. Install noirup with

    curl -L https://raw.githubusercontent.com/noir-lang/noirup/main/install | bash
  4. Install Nargo with

    noirup
  5. Install dependencies with

    yarn
  6. Generate the verifier contract

    yarn prep

Test locally

  1. Start a local development EVM at http://localhost:8545 with

    npx hardhat node

    or if foundry is preferred, with

    anvil
  2. Run the example test file with

    yarn test

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

Deploy locally

  1. Start a local development EVM at http://localhost:8545 with

    npx hardhat node

    or if foundry is preferred, with

    anvil
  2. Build the project and deploy contracts to the local development chain with

    yarn build
  3. Once your contracts are deployed and the build is finished, you can preview the built website with

    yarn preview

On-chain verification

The app will verify your proof locally. If you have a wallet, it will prompt you to connect to the relevant network and use it for on-chain verification.

Deploy on testnets

For convenience, we added two configurations for deployment on various testnets. You can find them in hardhat.config.cts.

To deploy on these testnets, rename .env.example to .env and add your own alchemy keys for these networks.

Then, prepend your commands with your desired network in a NETWORK environment variable. For example, to deploy on sepolia:

NETWORK=sepolia yarn build`

Feel free to add more networks, just make sure you:

  • Add deployer private keys and alchemy API keys in .env
  • Have funds in these accounts
  • Add a configuration in hardhat.config.cts