mirror of
https://github.com/embarklabs/dreddit-tutorial.git
synced 2025-02-23 05:58:09 +00:00
32 lines
533 B
Solidity
32 lines
533 B
Solidity
pragma solidity ^0.5.0;
|
|
|
|
contract DReddit {
|
|
|
|
struct Post {
|
|
uint creationDate;
|
|
bytes description;
|
|
address owner;
|
|
}
|
|
|
|
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);
|
|
}
|
|
}
|
|
|