-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsmartcontract.sol
More file actions
38 lines (30 loc) · 919 Bytes
/
Copy pathsmartcontract.sol
File metadata and controls
38 lines (30 loc) · 919 Bytes
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
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
/**
* @title MessageStorage
* @dev Post & get twitter-like statuses.
*/
contract MessageStorage {
event MessagePosted(address indexed author, string message);
address public owner;
mapping (address => string) private messages;
constructor () {
owner = msg.sender;
}
/**
* @dev Post twitter-like status in behalf of the caller.
* @param message Status message.
*/
function postStatus(string memory message) public {
require(bytes(message).length <= 1024);
messages[msg.sender] = message;
emit MessagePosted(msg.sender, message);
}
/**
* @dev Get status by author's address.
* @return message - Status message.
*/
function getStatus(address author) public view returns (string memory message) {
return messages[author];
}
}