A simple Next.js/Hardhat privacy application with Semaphore.
The code can be divided into contracts, frontend and backend.
- Greeters.sol contains the root of an offchain Merkle tree to represent the greeters (tree leaves), i.e. the identity commitments generated using the first 3 Ethereum accounts of the Hardhat testing wallet. It also contains a simple function to allow greeters to greet, only once and only if they create a valid Semaphore proof.
- The frontend code allows greeters to create a Semaphore identity with a signed Metamask message (using one of the first 3 Hardhat accounts) and a valid zero-knowledge proof.
- The backend code is an API that sends a
greet
transaction signed by the contract owner with the zero-knowledge proof of a greeter.
Clone this repository and install the dependencies:
git clone https://github.com/cedoor/semaphore-boilerplate.git
cd semaphore-boilerplate
yarn
yarn compile
yarn test
yarn dev
yarn deploy --network localhost
You can open the web app on http://localhost:3000.
You can find the mnemonic phrase here.
You must use one of the first 3 Hardhat accounts.