Files
semaphore/packages/cli-template-contracts-foundry/README.md
Jimmy Chu 4cc6980b55 Add CLI Foundry Template (cont.) (#905)
* Semaphore identity example code bug fix

* Receive suggestion for consistency

* chore: forge init

* forge install: forge-std

v1.9.2

* Foundry CLI First Draft

* modules

* forge install: semaphore

v4.0.3

* forge install: zk-kit.solidity

* forge install: poseidon-solidity

v0.0.5

* forge install: openzeppelin-contracts

v5.0.2

* modules

* forge install: semaphore

v4.0.3

* forge install: zk-kit.solidity

* forge install: poseidon-solidity

v0.0.5

* forge install: openzeppelin-contracts

v5.0.2

* modules

* forge install: semaphore

v4.0.3

* forge install: zk-kit.solidity

* forge install: poseidon-solidity

v0.0.5

* forge install: openzeppelin-contracts

v5.0.2

* modules

* forge install: semaphore

v4.0.3

* forge install: zk-kit.solidity

* forge install: poseidon-solidity

v0.0.5

* forge install: openzeppelin-contracts

v5.0.2

* modules

* forge install: semaphore

v4.0.3

* forge install: zk-kit.solidity

* forge install: poseidon-solidity

v0.0.5

* forge install: openzeppelin-contracts

v5.0.2

* modules

* forge install: semaphore

v4.0.3

* forge install: zk-kit.solidity

* forge install: poseidon-solidity

v0.0.5

* forge install: openzeppelin-contracts

v5.0.2

* forge install: forge-std

v1.9.2

* modules

* forge install: semaphore

v4.0.3

* forge install: zk-kit.solidity

* forge install: poseidon-solidity

v0.0.5

* forge install: openzeppelin-contracts

v5.0.2

* modules

* forge install: semaphore

v4.0.3

* forge install: zk-kit.solidity

* forge install: poseidon-solidity

v0.0.5

* forge install: openzeppelin-contracts

v5.0.2

* forge install: forge-std

v1.9.2

* modules

* forge install: semaphore

v4.0.3

* forge install: zk-kit.solidity

* forge install: poseidon-solidity

v0.0.5

* forge install: openzeppelin-contracts

v5.0.2

* forge install: forge-std

v1.9.2

* modules

* forge install: semaphore

v4.0.3

* forge install: zk-kit.solidity

* forge install: poseidon-solidity

v0.0.5

* forge install: openzeppelin-contracts

v5.0.2

* modules

* forge install: semaphore

v4.0.3

* forge install: zk-kit.solidity

* forge install: poseidon-solidity

v0.0.5

* forge install: openzeppelin-contracts

v5.0.2

* forge install: forge-std

v1.9.2

* modules

* forge install: semaphore

v4.0.3

* forge install: zk-kit.solidity

* forge install: poseidon-solidity

v0.0.5

* forge install: openzeppelin-contracts

v5.0.2

* forge install: forge-std

v1.9.2

* change test name

* modify declaration of semaphore and verifier

* Modify Test Function Name

* Add Test Chain Target

* forge std install

* refactor(cli-template-contracts-foundry): change default Anvil address and private key

* chore(cli-template-contracts-foundry): add comments

* refactor(cli-template-contracts-foundry): add Semaphore & SemaphoreVerifier addresses for test chain

* chore(cli-template-contracts-foundry): add forge coverage for Makefile

* chore(cli-template-contracts-foundry): add env.example

* docs(cli-template-contracts-foundry): add command instructions

* updated

* forge build works

* Fixed for linting

* chore(cli-template-contracts-foundry): make the lint, prettier, and lint-staged pass

* chore(cli-template-contracts-foundry): replace Makefile(removed) with package.json

* chore(cli-template-contracts-foundry): passing the ci test

* updated test

* feat(cli-template-contracts-foundry): complete cli-template-contracts-foundry

re #854, #185

* Update dependencies

* Add explanation on `yarn dev`

* fix(cli-template-contracts-foundry): fix `yarn dev` command and add docs on integrate w/ boilerplate

* Added yarnrc

* updated version

* Added Foundry in template option

---------

Co-authored-by: weipooppys93030 <55434365+weipooppys93030@users.noreply.github.com>
Co-authored-by: timou0911 <x0928048316@gmail.com>
Co-authored-by: csiejimmyliu <91661606+csiejimmyliu@users.noreply.github.com>
2024-12-17 14:48:36 +01:00

2.4 KiB

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