From c849fa74ca1d30d6da43932de36554c339ab2814 Mon Sep 17 00:00:00 2001 From: 7xAquarius <98767505+7xAquarius@users.noreply.github.com> Date: Thu, 17 Feb 2022 02:38:10 +0100 Subject: [PATCH] Add Lesson 6 rounding issue --- chronological-issues-from-video.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/chronological-issues-from-video.md b/chronological-issues-from-video.md index 7440ac3..c95c973 100644 --- a/chronological-issues-from-video.md +++ b/chronological-issues-from-video.md @@ -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.