Content pfp
Content
@
0 reply
0 recast
2 reactions

greg pfp
greg
@gregfromstl
What do you think each of the following functions do? toTokens fromWei toDecimals formatUnits
3 replies
0 recast
4 reactions

Greg pfp
Greg
@greg
i feel like these would all be wrappers around formatUnits in some way or another, like how viem has formatEther() which is really just formatUnits() internally. And parseUnits/parseEther for the opposite direction
1 reply
0 recast
0 reaction

jon pfp
jon
@sweetleaf.eth
converting units toTokens - convert underlying value to number of tokens fromWei - input(amount wei) -> expectedValue toDecimals - convert value to format with certain # decimals formatUnits - input (amount, decimals) -> human readable value
1 reply
0 recast
1 reaction

Manu pfp
Manu
@mmatila
toTokens: not sure tbh fromWei: takes two args, the amount of wei and the target format eg. gwei toDecimals: takes two args, an integer value and the decimal precision to convert it to formatUnits: takes three args, the "target" unit eg. ether, the amount and the "starting" unit eg. wei that's what my intuition said :p
0 reply
0 recast
0 reaction