32 lines
533 B
Solidity
Raw Normal View History

pragma solidity ^0.5.0;
contract DReddit {
struct Post {
uint creationDate;
bytes description;
address owner;
}
Post [] public posts;
2019-01-28 12:35:32 +01:00
event NewPost(
uint indexed postId,
address owner,
bytes description
);
function createPost(bytes memory _description) public {
uint postId = posts.length++;
2019-01-28 12:35:32 +01:00
posts[postId] = Post({
creationDate: block.timestamp,
description: _description,
owner: msg.sender
});
2019-01-28 12:35:32 +01:00
emit NewPost(postId, msg.sender, _description);
}
}