Files
semaphore/packages/cli-template-contracts-foundry

Semaphore Foundry Template

This project demonstrates a basic Semaphore use case. It comes with a sample contract, a test for that contract and a sample script that deploys that contract.

Prerequisites

This project requires Foundry, and thus a Rust environment, installed in the machine.

Install

Install dependencies

yarn

Usage

Compile contracts

yarn compile

Test contracts

yarn test

You can also generate a test coverage report:

yarn test:coverage

Or a test gas report:

yarn test:gas-report

You can also start a local Anvil node with Semaphore and Feedback contracts deployed on it with:

yarn dev

Code quality and formatting

Run solhint to analyze the code and catch bugs:

yarn lint

Run Prettier to check formatting rules:

yarn prettier

Or to automatically format the code:

yarn prettier:write

Integrating with Semaphore Boilerplate

You can also integrate this project with Semaphore Boilerplate, using this project as the contract end and connecting with Boilerplate front end.

  1. In cli-template-contracts-foundry package directory, run:

    yarn install
    yarn dev
    

    After running yarn dev, notice the output of

    # ...
    # ...
    
    == Return ==
    feedbackAddr: address 0x6f1AFCA8BCA87bF02091AF6187a5002802f9FB31
    semaphoreAddr: address 0xb730ce6CAE3FB706e83E4E00dFA31623966570eB
    semaphoreVerifierAddr: address 0xE2c114f548bEf410eaCe04D0390b61cc963df295
    
    # ...
    # ...
    
  2. Now, with another terminal, clone Semaphore Boilerplate down:

    # Clone Semaphore boilerplate and build dependencies
    git clone https://github.com/semaphore-protocol/boilerplate.git
    cd boilerplate
    yarn install
    
    # Use the sample .env.example
    cp .env.example .env
    
  3. Open the file apps/web-app/.env.development. Modify the values of NEXT_PUBLIC_FEEDBACK_CONTRACT_ADDRESS and NEXT_PUBLIC_SEMAPHORE_CONTRACT_ADDRESS with feedbackAddr and semaphoreAddr values shown in step 1.

  4. Run the Boilerplate front end:

    yarn dev:web-app