step 2: add NewPost event

This commit is contained in:
Pascal Precht 2019-01-28 12:35:32 +01:00
parent 393b39d973
commit 7de9fa3898
No known key found for this signature in database
GPG Key ID: 0EE28D8D6FD85D7D
1 changed files with 9 additions and 0 deletions

View File

@ -10,13 +10,22 @@ contract DReddit {
Post [] public posts;
event NewPost(
uint indexed postId,
address owner,
bytes description
);
function createPost(bytes memory _description) public {
uint postId = posts.length++;
posts[postId] = Post({
creationDate: block.timestamp,
description: _description,
owner: msg.sender
});
emit NewPost(postId, msg.sender, _description);
}
}