-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
Web3Utils toHex/soliditySha3: Accept Buffer as input or throw error #3021
Labels
Comments
akhil2015
added a commit
to akhil2015/web3.js
that referenced
this issue
Sep 25, 2019
nivida
added a commit
that referenced
this issue
Oct 14, 2019
This was referenced Mar 31, 2020
nachomazzara
pushed a commit
to nachomazzara/web3.js
that referenced
this issue
Jun 4, 2020
* fixed Web3Utils toHex for Buffer input web3#3021 * updated toHex funcDoc and CHANGELOG.md * used toString instead of bytesToHex * updated packages/web3-utils/src/utils.js Co-Authored-By: Samuel Furter <nivida@users.noreply.github.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Description
I just ran into the issue when using
Web3Utils.soliditySha3
. I was passing a Buffer as input instead of a String and then the resulting hash was different to the one inside the smart contract. The reason being thatWeb3Utils.toHex
apparently doesn't accept a Buffer as input. However, it didn't throw an error / give a warning or anything.For anyone reading this, I fixed it by passing a string:
Alternatively, you could use https://github.com/ethereumjs/ethereumjs-util/blob/master/docs/README.md#const-buffertohex.
Expected behavior
Calling
Web3Utils.soliditySha3
/Web3Utils.toHex
with Buffer as input should either work as expected or throw an error or at least give a warning.Web3Utils.toHex
with a Buffer as input currently returns a very strange, very long result.Versions
The text was updated successfully, but these errors were encountered: