vplasencia / semaphore-hardhat-nextjs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Semaphore icon. Semaphore Boilerplate

Github license GitHub Workflow style Linter eslint Code style prettier

The repository is divided into three components: web app, contracts and subgraph. The app allows users to create their own Semaphore identity, join a group with their usernames and then send their feedback anonymously (currently on Goerli).

๐Ÿ›  Install

Use this repository as a Github template.

Clone your repository:

git clone https://github.com/<your-username>/<your-repo>.git

and install the dependencies:

cd <your-repo> && yarn

๐Ÿ“œ Usage

Copy the .env.example file as .env:

cp .env.example .env

and add your environment variables.

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

Deploy the contract

  1. Go to the apps/contracts directory and deploy your contract:
yarn deploy --semaphore <semaphore-address> --group <group-id> --network goerli
  1. Update your .env file with your new contract address and group id.

  2. Change the address (with the new contract address) and startBlock (with the block number of the transaction where the contract was created) in the apps/subgraph/subgraph.yaml file.

  3. Copy your contract artifacts from apps/contracts/build/contracts/contracts folder to apps/subgraph/contract-artifacts and apps/web-app/contract-artifacts folders manually. Or run yarn copy:contract-artifacts in the project root to do it automatically.

  4. Deploy the subgraph again.

Note
Check the Semaphore contract addresses here.

Warning
The group id is a number!

Deploy the subgraph

  1. Go to the apps/subgraph directory and update the subgraph.yaml file by setting your contract address.
  2. Authenticate the account with your access token:
yarn auth <access-token>
  1. Deploy your subgraph:
yarn deploy <account-name/subgraph-name>

Start the app

You can start your app locally or you can easily deploy it to Vercel or AWS Amplify.

yarn start

Code quality and formatting

Run ESLint 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

About

License:MIT License


Languages

Language:TypeScript 94.4%Language:Solidity 3.0%Language:JavaScript 2.3%Language:Shell 0.4%