Skip to main content
Version: V3

Quick setup

Semaphore provides an official CLI to set up your project with Hardhat. If your NPM version is 5.2 or higher you can use NPX:

npx @semaphore-protocol/[email protected] create my-app

Otherwise, install @semaphore-protocol/cli globally and run the create command:

npm i -g @semaphore-protocol/[email protected]
semaphore create my-app

The semaphore CLI can also be used to get group data from a supported network (e.g semaphore get-groups --network goerli).

To start working on your project, install the dependencies:

cd my-app
npm i


The create command will create a directory called my-app (or whatever name you choose) inside the current folder. That directory will contain the initial project structure, which includes a simple contract, a task to deploy that contract and some tests.

β”œβ”€β”€ contracts
β”‚Β Β  └── Greeter.sol
β”œβ”€β”€ .env.example
β”œβ”€β”€ .gitignore
β”œβ”€β”€ hardhat.config.ts
β”œβ”€β”€ package.json
β”œβ”€β”€ tasks
β”‚Β Β  └── deploy.ts
β”œβ”€β”€ test
β”‚Β Β  └── Greeter.ts
└── tsconfig.json

The Greeter.sol contract creates a Semaphore group, allows users to join that group with their Semaphore identity, and finally allows group members to send an anonymous greeting.



Compile your contracts by running:

npm run compile


Test your contracts by running:

npm test

You can also generate a test coverage report:

npm run test:coverage

Or a test gas report:

npm run test:report-gas


Follow the instructions below to deploy your contracts:

  1. Copy the .env.example file as .env.

    cp .env.example .env
  2. Add your environment variables.


    You should at least set a valid Ethereum URL (e.g. Infura) and a private key with some ethers.

  3. And deploy your contract.

    npm run deploy -- --semaphore <semaphore-address> --group <group-id> --network goerli

    Check the Semaphore contract addresses here.


    The group id is a number.