-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCertificate.sol
51 lines (37 loc) · 1.18 KB
/
Certificate.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
pragma solidity >=0.4.22 <0.7.0;
contract Certificate {
address public owner;
string public name;
uint256 public date;
bool public locked;
struct Participant {
string name;
string org;
}
mapping(address => Participant) public participants;
constructor(string memory _name, uint256 _date) public {
owner = msg.sender;
name = _name;
date = _date;
locked = false;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
function addParticipant(
string memory _name,
string memory _org) public onlyOwner returns( address) {
require(locked == false, "must not locked");
address uniqueId = address(bytes20(keccak256(abi.encodePacked(msg.sender,now))));
participants[uniqueId] = Participant(_name, _org);
return uniqueId;
}
function getParticipant(address _id) public view returns(string memory, string memory) {
Participant memory temp = participants[_id];
return (temp.name, temp.org);
}
function finish() public onlyOwner {
locked = true;
}
}