Skip to content

Instantly share code, notes, and snippets.

@extropyCoder
Created April 12, 2025 17:13
Show Gist options
  • Select an option

  • Save extropyCoder/a1252f1d0eb701cb60d18e333b27a1fd to your computer and use it in GitHub Desktop.

Select an option

Save extropyCoder/a1252f1d0eb701cb60d18e333b27a1fd to your computer and use it in GitHub Desktop.
Example Semaphore contract
//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