From 393b39d973a08c5ee695fa910715dc9ff918860c Mon Sep 17 00:00:00 2001 From: Pascal Precht Date: Mon, 28 Jan 2019 12:34:51 +0100 Subject: [PATCH] step 1: introduce DReddit Smart Contract and createPost() method --- contracts/DReddit.sol | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 contracts/DReddit.sol diff --git a/contracts/DReddit.sol b/contracts/DReddit.sol new file mode 100644 index 0000000..0da55e4 --- /dev/null +++ b/contracts/DReddit.sol @@ -0,0 +1,22 @@ +pragma solidity ^0.5.0; + +contract DReddit { + + struct Post { + uint creationDate; + bytes description; + address owner; + } + + Post [] public posts; + + function createPost(bytes memory _description) public { + uint postId = posts.length++; + posts[postId] = Post({ + creationDate: block.timestamp, + description: _description, + owner: msg.sender + }); + } +} +