Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected behaviour using web3.utils.toHex function #2775

Closed
PendicGordan opened this issue May 3, 2019 · 1 comment
Closed

Unexpected behaviour using web3.utils.toHex function #2775

PendicGordan opened this issue May 3, 2019 · 1 comment

Comments

@PendicGordan
Copy link

Hi, I'm using toHex function from [email protected] "utils" and facing strange behaviour regarding where this function is executed. When the function is running in localhost, everything is working as expected, hex value is right because I am getting the right number out of it, but the problem occurs when DApp is deployed in production, more specifically on Amazon's S3 Bucket. There I am getting completely different hex value, which is not correct. So I will post here statement which I tested in Chrome's console, both in localhost and production environment and respectfully their results(both in hex and decimal number). Not sure if it's a web3 bug, but I'm just trying to figure out what happens here. I'll be thankful for any feedback.

Expected behavior

To get the same result both in localhost and production when web3.utils.toHex.

For the code provided down below:

Localhost:
0xf0503bbcf59aa40000 ---> Integer value: 4.433e+21

Production:
0xf0503bbcf59aa40000 ---> Integer value: 4.433e+21

Actual behavior

Getting different results in localhost and production.

For code provided down below:

Localhost:
0xf0503bbcf59aa40000 ---> Integer value: 4.433e+21

Production:
0x2266303530336262636635396161343030303022 ---> 1.9638456170702058e+47

Steps to reproduce the behavior

1. Running the statement in Chrome's console

```js
  
    web3.utils.toHex(web3.utils.toBN(4433).mul(web3.utils.toBN(10).pow(web3.utils.toBN(18))))

```

Versions

@nivida
Copy link
Contributor

nivida commented May 3, 2019

Thanks for opening this issue! But I will close this issue because there are already several similar open issues with the bug or enhancement label. The current discussion about the BigInt handling in Web3.js is here.

Edit:

Btw.: The latest version is beta.54.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants