-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
51 additions
and
0 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
...ration/pi_network/features/decentralized-governance-and-community/CommunityEngagement.sol
This file contains 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
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; | ||
} | ||
} |