0

I don't want to load the web3 library, I do however want to convert Either to Wei, does anyone have a JavaScript function to share.

I don't mind loading a smaller library

  • Web3 is the most popular for this sort of thing, but you can try ethereum-units instead – Elena Dimitrova Oct 24 '17 at 7:46
  • One ether is 1e18 wei. HOWEVER you will need the JavaScript big number library to be able to use numbers this large without rounding errors. – Alex Oct 24 '17 at 16:40
1

Accourding to this table:

  • Wei = 10^0 Wei
  • Ada = 10^3 Wei
  • Babbage = 10^6 Wei
  • Shannon = 10^9 Wei
  • Szabo = 10^12 Wei
  • Finney = 10^15 Wei
  • Ether = 10^18 Wei

1 Ether is 1^18 = 1000000000000000000 Wei.

1 Wei is 0.000000000000000001 Ether.

1

Just multiply the number of ether by 10e18. Done and done!

  • Is there is difference in performance of manually multiplying and using the web3 method ? – Kannan Ravindran Oct 24 '17 at 16:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.