From 7de9fa38981882a8f77ec85ead2246efc31232fe Mon Sep 17 00:00:00 2001 From: Pascal Precht Date: Mon, 28 Jan 2019 12:35:32 +0100 Subject: [PATCH] step 2: add NewPost event --- contracts/DReddit.sol | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/contracts/DReddit.sol b/contracts/DReddit.sol index 0da55e4..5e252d1 100644 --- a/contracts/DReddit.sol +++ b/contracts/DReddit.sol @@ -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); } }