step 1: introduce DReddit Smart Contract and createPost() method
This commit is contained in:
parent
766b48c4e7
commit
393b39d973
|
@ -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
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue