-
Notifications
You must be signed in to change notification settings - Fork 2
/
membership.sol
37 lines (30 loc) · 1.07 KB
/
membership.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
contract MembershipSystem {
// Mapping from user addresses to their membership info
mapping (address => Membership) public memberships;
// Struct to store membership info
struct Membership {
bool active;
uint[] perks;
}
// Function to join the membership system
function join() public {
require(!memberships[msg.sender].active, "Member has already joined.");
// Set the member's membership info
memberships[msg.sender] = Membership({
active: true,
perks: new uint[](0)
});
}
// Function to add a perk to a member's membership
function addPerk(address member, uint perk) public {
require(memberships[member].active, "Member is not active.");
// Add the perk to the member's perks
memberships[member].perks.push(perk);
}
// Function to get the perks of a member's membership
function getPerks(address member) public view returns (uint[]) {
return memberships[member].perks;
}
}