step 1: introduce DReddit Smart Contract and createPost() method

This commit is contained in:
Pascal Precht 2019-01-28 12:34:51 +01:00
parent 766b48c4e7
commit 393b39d973
No known key found for this signature in database
GPG Key ID: 0EE28D8D6FD85D7D
1 changed files with 22 additions and 0 deletions

22
contracts/DReddit.sol Normal file
View File

@ -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
});
}
}