Converting USD to WEI and back to USD & ETH

  1. What is the best practice to take a user input value in USD / ETH convert it to WEI (to submit it) and then pull it back from DB in ETH / USD (when working with Ganache)?

  2. Am I still going to work with WEI if Iā€™m on the Mainnet server and not working with Ganache?

You can use Moralis.Units:

https://docs.moralis.io/moralis-dapp/tools/moralis-units
https://docs.moralis.io/moralis-dapp/cloud-code/cloud-functions#units

@cryptokid Please update the link. This goes to 404.

1 Like