mirror of
https://github.com/semaphore-protocol/semaphore.git
synced 2026-04-28 03:00:41 -04:00
This new package allows devs to fetch on-chain data by using a Semaphore subgraph or the Ethers
library.
BREAKING CHANGE: The code of the old `@semaphore-protocol/subgraph` package has been moved to the
`@semaphore-protocol/data` package.
re #256
Former-commit-id: fc2f648acc
Semaphore data
A library to query Semaphore contracts.
This library allows you to query the Semaphore.sol contract data (i.e. groups) using the Semaphore subgraph or Ethers. It can be used on Node.js and browsers. |
|---|
🛠 Install
npm or yarn
Install the @semaphore-protocol/data package with npm:
npm i @semaphore-protocol/data
or yarn:
yarn add @semaphore-protocol/data
CDN
You can also load it using a script tag using unpkg:
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script src="https://unpkg.com/@semaphore-protocol/data"></script>
or JSDelivr:
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@semaphore-protocol/data"></script>
📜 Usage
# new Subgraph(networkOrSubgraphURL: Network = "goerli" ): Subgraph
import { Subgraph } from "@semaphore-protocol/subgraph"
const subgraph = new Subgraph()
// or:
const subgraph = new Subgraph("arbitrum")
// or:
const subgraph2 = new Subgraph("https://api.studio.thegraph.com/query/14377/<your-subgraph>/<your-version>")
# getGroupIds()
const groups = subgraph.getGroupIds()
# getGroups(options?: GroupOptions)
const groups = subgraph.getGroups()
// or
const groups = subgraph.getGroups({ members: true, verifiedProofs: true })
# getGroup(groupId: string, options?: GroupOptions)
const group = subgraph.getGroup("1")
// or
const { members, verifiedProofs } = subgraph.getGroup("1", { members: true, verifiedProofs: true })