-
Notifications
You must be signed in to change notification settings - Fork 0
/
texter.sol
32 lines (25 loc) · 938 Bytes
/
texter.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
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.8;
contract chatext {
struct Post {
string Title;
string Body;
}
struct Reply {
address replyAuthor;
string Body;
}
Post[] public posts; // easy way to get latest posts => highest index | map uint => [post+author][]; need posters addresses to be known
mapping(address => uint[]) public postsId;
mapping(uint => Reply[]) public replies;
// mapping(uint => mapping(address => Post[])) public replies; // know replyAuthor before call
function saveText (string memory _text) public {
posts.push(Post("Some Title",_text));
postsId[msg.sender].push(posts.length);
}
function reply (uint _postId, string memory _reply) public {
replies[_postId].push(Reply(msg.sender, _reply));
// replies[_postId][msg.sender].push(Post("Some Reply", _reply));
// sort by block
}
}