0

I'm using the Etherscan API to pull transactions logs for specific wallets, but I'm having a hard time trying to format the value correctly.

This is the url I'm working with Transaction Log

One of the transactions has a value of 206933340464 which in the etherscan site it looks like 0.00000020693334 if I use

web3.fromWei(206933340464,'ether')

I get 2.0693334. How can I format this value correctly?, or could it be that etherscan is providing wrong values?.

Cheers.

2
  • 1
    Is that your exact code? When I do web3.fromWei(206933340464, 'ether'), I get "0.000000206933340464".
    – user19510
    Commented Dec 13, 2017 at 16:33
  • Oh wow you're right. Using the Web3.js lib it's actually correct. I forgot to mention I'm using the Web3.py lib. Must be a bug then. Thank you!.
    – webjunkie
    Commented Dec 13, 2017 at 16:38

1 Answer 1

1

web3.py (at least the version I'm running) also gives the correct answer, but if you don't like the scientific notation, you'll have to use a format string:

>>> web3.fromWei(206933340464, 'ether')
Decimal('2.06933340464E-7')
>>> print('{:.14f}'.format(web3.fromWei(206933340464, 'ether')))
0.00000020693334
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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