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. |
|---|
You can access any subgraph supported by Semaphore with the following URL: https://api.studio.thegraph.com/query/14377/semaphore-<network-name>/v4.5.0.
Supported networks:
sepoliaethereumoptimismoptimism-sepoliaarbitrumarbitrum-sepoliamaticmatic-amoybase-sepoliabaselinea-sepolialineascroll-sepoliagnosis-chiadognosis
Clone this repository:
git clone https://github.com/semaphore-protocol/semaphore.gitand install the dependencies:
cd semaphore/apps/subgraph && yarnThe 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.
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 testSet 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 upStart a local Hardhat node and deploy the Semaphore contract:
# CWD = /semaphore/packages/contracts
yarn start --hostname 0.0.0.0
yarn deploy --network localhostCreate the subgraph.yaml file for your local network and create/deploy your subgraph:
yarn codegen localhost
yarn create-local
yarn deploy-localOnce 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/semaphore/graphql