Lesson 4 - Issue in getPrice() and getConversionRate() functions. #6044
Unanswered
Rashmika-Dissanayake
asked this question in
Q&A
Replies: 1 comment
-
Hello @Rashmika-Dissanayake The point is we are doing all those operations to stick to WEI scale. If you try changing it by shrinking zeros you will keep facing wrong calculations in your tests, contracts etc. as in solidity we are using WEI as the basic scale thats the whole point. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, When we write the getPrice() function, Shouldn't we return uint(price / 1e8). There we should get ETH value in terms of USD. In getConversionRate() function It should change to, uint256 ethAmountInUSD = ethPrice * ethAmount. Isn't it more clear to understand?
Note : The way Patrick has done, rhas returmed the ethAmountInUSD correctly. But I think above mentioned solution is more clear and easy. But I would like to know if there's any special reason why patrick did so.
Beta Was this translation helpful? Give feedback.
All reactions