Skip to main content
Version: V2

Contracts

Semaphore includes three types of contracts:

info

To use Semaphore contracts and interfaces in your project, install the @semaphore-protocol/contracts NPM package.

Base contracts​

Semaphore provides the following base contracts:

These contracts are closely related to the protocol. You can inherit them in your contract or you can use Semaphore.sol, which inherits them for you. See our deployed contracts to find the addresses for your network.

info

While some dApps may use on-chain groups, others may prefer to use off-chain groups, saving only their tree roots in the contract.

Extension contracts​

  • SemaphoreVoting.sol: voting contract that contains the essential functions to create polls, add voters, and anonymously cast votes.
  • SemaphoreWhistleblowing.sol: whistleblowing contract that contains the essential functions to create entities (for example: non-profit organizations), add whistleblowers, and anonymously publish leaks.

These contracts extend the protocol to provide application logic for specific use-cases. More extensions will be added in the future.

Verifiers​

To verify Semaphore proofs, the SemaphoreCore.sol contract requires the address of a deployed verifier contract. You can choose to manually deploy the verifier you prefer or you can use one of our deployed verifiers.

Each verifier name indicates the tree depth that it can verify. For example, given a Semaphore proof generated with a tree depth 20:

  • The Verifier20.sol contract can verify the proof.
  • The group used for the proof can have a maximum 2^20=1048576 members.