Skip to content

Lesson 3 - confused by all the zeros #1629

Answered by cromewar
alkali333 asked this question in Q&A
Discussion options

You must be logged in to vote

Hello @alkali333
The reason Patrick made the code like this is just for standard reasons, you don't have to it as an obligation and the explanation is the following:
Most of ERC20 Tokens has a standard of 18 decimals, which is based on the WEI, GWEI and ETH conversion. so with that in mind:
uint256 minimumUSD = 50 * 10 ** 18; is just to fill up the standard.
return uint256(answer * 10000000000); the answer returns a 8 digit value, so the multiplication is again just to get 18.
return (ethPrice * ethAmount) / 1000000000000000000 this is because eth price already have all the decimals so you don't want to have 36 decimals, just 18.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by cromewar
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants