Files
semaphore/packages/data
cedoor c8d472a286 feat(data): create new data package
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
2023-03-06 17:43:42 +00:00
..
2023-03-06 17:43:42 +00:00
2023-03-06 17:43:42 +00:00
2023-03-06 17:43:42 +00:00

Semaphore data

A library to query Semaphore contracts.

Github license NPM version Downloads Linter eslint Code style prettier

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 })