The SemaphoreSubgraph class provides an interface to interact with the Semaphore smart contract via subgraph queries. It enables operations such as retrieving lists of group members and validated proofs, as well as checking membership within groups. Each group in Semaphore is represented as a LeanIMT (Lean Incremental Merkle Tree). This class supports interaction through either a SupportedNetwork or a direct URL to the subgraph. The subgraphs themselves are hosted on The Graph protocol, facilitating efficient and decentralized query processing.

Constructors

  • Initializes the SemaphoreSubgraph instance with a supported network or a custom subgraph URL. This allows to interact with the Semaphore smart contract through the specified endpoint.

    Parameters

    • networkOrSubgraphURL: string = defaultNetwork

      Either a supported network identifier or a direct URL to the subgraph.

    Returns SemaphoreSubgraph

Properties

_url: string

Accessors

  • get url(): string
  • Retrieves the URL of the subgraph currently being used by the instance. This URL points to the specific subgraph where Semaphore data is stored.

    Returns string

    The URL of the subgraph.

Methods

  • Fetches detailed information about a specific group by its ID. This method can also retrieve members and validated proofs for the group if requested via options.

    Parameters

    • groupId: string

      The unique identifier of the group.

    • options: Omit<GroupOptions, "filters"> = {}

      Configuration options to specify which details to fetch about the group.

    Returns Promise<GroupResponse>

    A promise that resolves to the details of the specified group.

  • Fetches a list of all group IDs from the subgraph. This method queries the subgraph to retrieve identifiers for all groups managed by the Semaphore smart contract.

    Returns Promise<string[]>

    A promise that resolves to an array of group IDs.

  • Retrieves a list of members from a specific group.

    Parameters

    • groupId: string

      The unique identifier of the group.

    Returns Promise<string[]>

    A promise that resolves to an array of group members' identity commitments.

  • Fetches a list of validated proofs for a specific group.

    Parameters

    • groupId: string

      The unique identifier of the group.

    Returns Promise<any[]>

    A promise that resolves to an array of validated proofs.

  • Retrieves detailed information about groups from the subgraph based on the provided options. This method can filter groups by various parameters and include additional details like members and validated proofs if specified in the options.

    Parameters

    • options: GroupOptions = {}

      Configuration options to filter groups and specify which additional details to fetch.

    Returns Promise<GroupResponse[]>

    A promise that resolves to an array of group details.

  • Determines whether a specific member is part of a group. This method queries the subgraph to check if the provided member's identity commitment exists within the specified group.

    Parameters

    • groupId: string

      The unique identifier of the group.

    • member: string

      The identity commitment of the member to check.

    Returns Promise<boolean>

    A promise that resolves to true if the member is part of the group, otherwise false.