Skip to content

Commit

Permalink
Create CommunityEngagement.sol
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH authored Aug 28, 2024
1 parent 0d6390f commit 844c615
Showing 1 changed file with 51 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
pragma solidity ^0.8.0;

import "./Governance.sol";

contract CommunityEngagement {
using Governance for address;

// Mapping of community members
mapping (address => CommunityMember) public communityMembers;

// Struct to represent a community member
struct CommunityMember {
address member;
uint256 reputation;
uint256 contribution;
}

// Event emitted when a new community member joins
event NewCommunityMember(address indexed member);

// Event emitted when a community member contributes to the network
event ContributeToNetwork(address indexed member, uint256 contribution);

// Function to join the community
function joinCommunity() public {
CommunityMember storage member = communityMembers[msg.sender];
member.member = msg.sender;
member.reputation = 0;
member.contribution = 0;
emit NewCommunityMember(msg.sender);
}

// Function to contribute to the network
function contributeToNetwork(uint256 _contribution) public {
CommunityMember storage member = communityMembers[msg.sender];
member.contribution += _contribution;
emit ContributeToNetwork(msg.sender, _contribution);
}

// Function to get a community member's reputation
function getReputation(address _member) public view returns (uint256) {
CommunityMember storage member = communityMembers[_member];
return member.reputation;
}

// Function to get a community member's contribution
function getContribution(address _member) public view returns (uint256) {
CommunityMember storage member = communityMembers[_member];
return member.contribution;
}
}

0 comments on commit 844c615

Please sign in to comment.