In Lesson 4: fund-me-fcc (library Q&A) #5640
-
in the File PriceConverter.sol , function getPrice():
in return statement : why
in FunMe.sol, for MINIMUM_USD:
need explanation! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
@KarthickSakthi This is all because solidity does not work with decimal numbers. So this logic is for correct math. Price return by price feed contains 8 decimals, i.e if the price is 1840 then the value will be Now for comparing the value so we can identify whether the user has deposited the correct amount or not we do all this math; first, we declared the minimum price for the deposit Now both values are in the 18 decimal system, we can now do the conversion. |
Beta Was this translation helpful? Give feedback.
@KarthickSakthi This is all because solidity does not work with decimal numbers. So this logic is for correct math.
Price return by price feed contains 8 decimals, i.e if the price is 1840 then the value will be
184000000000
, now as we know solidity's smallest unit iswei
which contains 18 decimals, i.e 1 ether will be equal to1000000000000000000
. So we added 10 more decimals to 8 decimals so the price will be in the 18 decimal system.Now for comparing the value so we can identify whether the user has deposited the correct amount or not we do all this math;
first, we declared the minimum price for the deposit
MINIMUM_USD = 50 * 10 ** 18; 50 *
which is 50, so what value will be in wei? …