Skip to content

Commit

Permalink
Add Lesson 6 rounding issue
Browse files Browse the repository at this point in the history
  • Loading branch information
7xAquarius authored Feb 17, 2022
1 parent c2826e1 commit c849fa7
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions chronological-issues-from-video.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ Whenever the terms Network ID and Chain ID are used without distinction, it shou
```


## Lesson 6
- [5:44:00](https://youtu.be/M576WGiDBdQ?t=20640)
- In the video, the getEntranceFee() function returns `(minimumUSD * precision) / price`
- Integer divisions are rounded towards 0 in Solidity, so this function will almost always return an amount worth slightly less than our minimum price. It makes it unusable with the fund() function because the transaction will revert everytime.
- To fix it we can round up the result
- getEntranceFee() function should return `((minimumUSD * precision) / price) + 1`
- This fix has been [merged](https://github.com/PatrickAlphaC/brownie_fund_me/pull/32/files) and you can read more explanation about the issue [here](https://github.com/PatrickAlphaC/brownie_fund_me/issues/10#issuecomment-1041602057)

## Lesson 7
- [8:06:54ish](https://youtu.be/M576WGiDBdQ?t=29214)
- In the video, we use events exclusivly to test our contracts, however, we could have also used `tx.return_value` to get the return value of a function.
Expand Down

0 comments on commit c849fa7

Please sign in to comment.