Created
April 12, 2025 17:13
-
-
Save extropyCoder/a1252f1d0eb701cb60d18e333b27a1fd to your computer and use it in GitHub Desktop.
Example Semaphore contract
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //SPDX-License-Identifier: MIT | |
| pragma solidity ^0.8.23; | |
| import "@semaphore-protocol/contracts/interfaces/ISemaphore.sol"; | |
| contract Feedback { | |
| ISemaphore public semaphore; | |
| uint256 public groupId; | |
| constructor(address semaphoreAddress) { | |
| semaphore = ISemaphore(semaphoreAddress); | |
| groupId = semaphore.createGroup(address(this)); | |
| } | |
| function joinGroup(uint256 identityCommitment) external { | |
| semaphore.addMember(groupId, identityCommitment); | |
| } | |
| function sendFeedback( | |
| uint256 merkleTreeDepth, | |
| uint256 merkleTreeRoot, | |
| uint256 nullifier, | |
| uint256 feedback, | |
| uint256[8] calldata points | |
| ) external { | |
| ISemaphore.SemaphoreProof memory proof = ISemaphore.SemaphoreProof( | |
| merkleTreeDepth, | |
| merkleTreeRoot, | |
| nullifier, | |
| feedback, | |
| groupId, | |
| points | |
| ); | |
| semaphore.validateProof(groupId, proof); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment