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.

Revisions

  1. extropyCoder created this gist Apr 12, 2025.
    39 changes: 39 additions & 0 deletions Feedback.sol
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,39 @@
    //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);
    }
    }