---
title: "Comment by vrunishkajo on \"Write Your First DAPP in 10mins\" | Hashnode"
description: "Let me be a bore a little more ;) solidity ^0.8.10 posts [postCount] = Post(postCount, _content, 0 , msg.sender); to posts [postCount] = Post(postCount, _conten"
url: "https://hashnode.com/posts/write-your-first-dapp-in-10mins/6189dbc6ce9e5f6dfd785c23/comment/61a2c3d1d51d1f4e7e1c68c4"
---

[Discussion](https://hashnode.com/posts/write-your-first-dapp-in-10mins/6189dbc6ce9e5f6dfd785c23)

Comment [Write Your First DAPP in 10mins](https://hashnode.com/posts/write-your-first-dapp-in-10mins/6189dbc6ce9e5f6dfd785c23)

[vrunishkajo](https://hashnode.com/@vrunishkajo)

[Nov 27, 2021](https://hashnode.com/posts/write-your-first-dapp-in-10mins/6189dbc6ce9e5f6dfd785c23/comment/61a2c3d1d51d1f4e7e1c68c4)

Let me be a bore a little more ;) `solidity ^0.8.10`

```
posts[postCount] = Post(postCount, _content, 0, msg.sender);
```

to

```
posts[postCount] = Post(postCount, _content, 0, payable(msg.sender));
```

---

```
emit PostCreated(postCount, _content, 0, msg.sender);
```

to

```
emit PostCreated(postCount, _content, 0, payable(msg.sender));
```

---

```
address(_author).transfer(msg.value);
```

to

```
_author.transfer(msg.value);
```

---

Possible reentrancy vulnerabilities. Avoid state changes after transfer. I think you can do this:

```
     function tipPost(uint _id) public payable {

        //Ensure the id is not invalid
        require(_id > 0 && _id <= postCount, "Valid id required");

        //fetch post
         Post memory _post = posts[_id];
         address payable _author = _post.author; //fetch the author
         address(_author).transfer(msg.value); //transfer Ether to the author

        //We increment the tip amount
        _post.tipAmount += msg.value;

        posts[_id] = _post;

        // let's trigger a post tipped event
        emit PostTipped(_id, _post.content, _post.tipAmount, _author );

     }
```

to

```
function tipPost(uint256 _id) public payable {
    require(_id > 0 && _id <= postCount, "Valid id required");

    posts[_id].tipAmount += msg.value;
    posts[_id].author.transfer(msg.value);

    emit PostTipped(_id, posts[_id].content, posts[_id].tipAmount, posts[_id].author);
  }
```

[Emmanuel Ugwuoke](https://hashnode.com/@ScribbleTons)

[Nov 28, 2021](https://hashnode.com/posts/write-your-first-dapp-in-10mins/6189dbc6ce9e5f6dfd785c23/comment/61a2c3d1d51d1f4e7e1c68c4#reply-61a343f5d51d1f4e7e1c6d13)

I am grateful for you corrections so far. I like the refactored tipPost method, it is clean and direct. My next post on web3 project will sure be better with your corrections. Thanks man.
