Skip to content
This repository has been archived by the owner on Jan 11, 2024. It is now read-only.

Latest commit

 

History

History
167 lines (124 loc) · 9.25 KB

README.md

File metadata and controls

167 lines (124 loc) · 9.25 KB

Important

The Semaphore subgraph was moved to the main monorepo: subgraph (inside the apps folder).

Semaphore Subgraph

Github license GitHub Workflow test Linter eslint Code style prettier Repository top language

The Graph is an indexing protocol for querying networks like Ethereum and IPFS. Our subgraphs allow you to get data from the Semaphore.sol smart contract.

Networks

Semaphore version Sepolia Goerli Mumbai Optimism Goerli Arbitrum Goerli Arbitrum One
v2.0 N/A N/A N/A N/A N/A semaphore-protocol/arbitrum
v2.5 N/A semaphore-protocol/goerli N/A N/A N/A N/A
v2.6 N/A semaphore-protocol/goerli-5259d3 N/A N/A N/A semaphore-protocol/arbitrum-86337c
v3.0 - v3.1 N/A semaphore-protocol/goerli-89490c N/A N/A N/A semaphore-protocol/arbitrum-72dca3
>= v3.2 semaphore-sepolia semaphore-goerli semaphore-mumbai semaphore-optimism-goerli semaphore-arbitrum-goerli semaphore-arbitrum

🛠 Install

Clone this repository:

git clone https://github.com/semaphore-protocol/subgraph.git

and install the dependencies:

cd subgraph && yarn

Usage

The subgraph definition consists of a few files:

  • subgraph.template.yaml: a YAML file containing the subgraph manifest,
  • schema.graphql: a GraphQL schema that defines what data is stored for the subgraph, and how to query it via GraphQL,
  • src/semaphore.ts: AssemblyScript code that translates from the event data to the entities defined in the schema.

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

Code generation

Generate AssemblyScript types for the subgraph (required every time the schema changes):

yarn codegen <network>

It also generates a subgraph.yaml file for your specific network.

Testing

After generating the types and subgraph.yaml file, test your subgraph:

yarn test

Deployment

TheGraph Studio

Set the authorization code that links your account on thegraph.com:

yarn auth <access-token>

Deploy the subgraph to the TheGraph Studio:

yarn deploy <subgraph-name>

Local

Start services required for TheGraph node by running:

docker compose -f docker-compose-graph.yml up

Start a local Hardhat node and deploy the Semaphore contract:

# CWD = /semaphore/packages/contracts
yarn start
yarn deploy:semaphore --network localhost

Create the subgraph.yaml file for your local network and create/deploy your subgraph:

yarn codegen localhost
yarn create-local
yarn deploy-local

Once the subgraph is published it will start indexing. You can query the subgraph using the following GraphQL endpoint:

http://127.0.0.1:8000/subgraphs/name/sempahore/graphql