56 lines
1.7 KiB
Solidity
56 lines
1.7 KiB
Solidity
// SPDX-License-Identifier: MIT
|
|
pragma solidity ^0.8.20;
|
|
|
|
struct FeedbackRecord {
|
|
string feedbackHash; // Hash of the full feedback data stored on IPFS
|
|
string issueId; // Unique identifier for the issue or legislation
|
|
bytes zkpProof; // ZKP proof for identity verification
|
|
uint256 timestamp; // Timestamp of submission
|
|
address submitter; // Address of the submitter (optional)
|
|
}
|
|
|
|
contract FeedbackStorage {
|
|
// Array to store all feedback records
|
|
FeedbackRecord[] public feedbackRecords;
|
|
|
|
// Event to emit when feedback is submitted (for off-chain indexing)
|
|
event FeedbackSubmitted(
|
|
uint256 indexed id,
|
|
string feedbackHash,
|
|
string issueId,
|
|
bytes zkpProof,
|
|
uint256 timestamp,
|
|
address submitter
|
|
);
|
|
|
|
// Function to submit feedback
|
|
function submitFeedback(
|
|
string memory feedbackHash,
|
|
string memory issueId,
|
|
bytes memory zkpProof
|
|
) public {
|
|
|
|
feedbackRecords.push(FeedbackRecord({
|
|
feedbackHash: feedbackHash,
|
|
issueId: issueId,
|
|
zkpProof: zkpProof,
|
|
timestamp: block.timestamp,
|
|
submitter: msg.sender
|
|
}));
|
|
|
|
// Emit event for tracking and indexing
|
|
emit FeedbackSubmitted(
|
|
feedbackRecords.length - 1,
|
|
feedbackHash,
|
|
issueId,
|
|
zkpProof,
|
|
block.timestamp,
|
|
msg.sender
|
|
);
|
|
}
|
|
|
|
// Function to get the total number of feedback records (optional utility)
|
|
function getFeedbackCount() public view returns (uint256) {
|
|
return feedbackRecords.length;
|
|
}
|
|
} |