mirror of
https://github.com/embarklabs/dreddit-tutorial.git
synced 2025-02-17 11:16:24 +00:00
step 1: introduce DReddit Smart Contract and createPost() method
This commit is contained in:
parent
766b48c4e7
commit
393b39d973
22
contracts/DReddit.sol
Normal file
22
contracts/DReddit.sol
Normal 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
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user