You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 that Web3Utils.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:
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
web3-utils 1.2.1
The text was updated successfully, but these errors were encountered:
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: