Important
The Semaphore subgraph was moved to the main monorepo: subgraph (inside the apps
folder).
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. |
---|
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 |
Clone this repository:
git clone https://github.com/semaphore-protocol/subgraph.git
and install the dependencies:
cd subgraph && yarn
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.
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
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.
After generating the types and subgraph.yaml
file, test your subgraph:
yarn test
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>
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