The SemaphoreEthers class provides a high-level interface to interact with the Semaphore smart contract using the ethers.js library. It encapsulates all necessary functionalities to connect to Ethereum networks, manage contract instances, and perform operations such as retrieving group information or checking group memberships. This class simplifies the interaction with the Ethereum blockchain by abstracting the details of network connections and contract interactions.

Constructors

  • Constructs a new SemaphoreEthers instance, initializing it with a network or a custom Ethereum node URL, and optional configuration settings for the ethers provider and contract.

    Parameters

    • networkOrEthereumURL: string = defaultNetwork

      The Ethereum network name or a custom JSON-RPC URL to connect to.

    • options: EthersOptions = {}

      Configuration options for the ethers provider and the Semaphore contract.

    Returns SemaphoreEthers

Properties

_contract: Contract
_network: string
_options: EthersOptions

Accessors

  • get contract(): Contract
  • Retrieves the ethers Contract instance used to interact with the Semaphore contract.

    Returns Contract

    The Contract instance.

  • get network(): string
  • Retrieves the Ethereum network or custom URL currently used by this instance.

    Returns string

    The network or URL as a string.

Methods

  • Retrieves detailed information about a specific group by its ID. This method queries the Semaphore contract to get the group's admin, Merkle tree root, depth, and size.

    Parameters

    • groupId: string

      The unique identifier of the group.

    Returns Promise<GroupResponse>

    A promise that resolves to a GroupResponse object.

  • Fetches the list of group IDs from the Semaphore contract by querying the "GroupCreated" events.

    Returns Promise<string[]>

    A promise that resolves to an array of group IDs as strings.

  • Fetches a list of members from a specific group. This method queries the Semaphore contract for events related to member additions and updates, and constructs the list of current group members.

    Parameters

    • groupId: string

      The unique identifier of the group.

    Returns Promise<string[]>

    A promise that resolves to an array of member identity commitments as strings.

  • Retrieves a list of validated proofs for a specific group. This method queries the Semaphore contract for "ProofValidated" events and returns details about each proof.

    Parameters

    • groupId: string

      The unique identifier of the group.

    Returns Promise<any>

    A promise that resolves to an array of validated proofs.

  • Checks whether a specific member is part of a group. This method queries the Semaphore contract to determine if the provided identity commitment is a member of 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.