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.
-
In
cli-template-contracts-foundrypackage directory, run:yarn install yarn devAfter running
yarn dev, notice the output of# ... # ... == Return == feedbackAddr: address 0x6f1AFCA8BCA87bF02091AF6187a5002802f9FB31 semaphoreAddr: address 0xb730ce6CAE3FB706e83E4E00dFA31623966570eB semaphoreVerifierAddr: address 0xE2c114f548bEf410eaCe04D0390b61cc963df295 # ... # ... -
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 -
Open the file
apps/web-app/.env.development. Modify the values ofNEXT_PUBLIC_FEEDBACK_CONTRACT_ADDRESSandNEXT_PUBLIC_SEMAPHORE_CONTRACT_ADDRESSwith feedbackAddr and semaphoreAddr values shown in step 1. -
Run the Boilerplate front end:
yarn dev:web-app