1

I ran two command lines of web3 and it returned an error

> length ='0000000000000000000000000000000000000000000000000000000000000002'
0000000000000000000000000000000000000000000000000000000000000002

> d0Slot = web3.utils.sha3(length, {encoding: 'hex'})

str.slice is not a function
2
  • 1
    From web3.utils, I conclude that you're using web3.js v1.x. If that is indeed the case, then use soliditySha3 instead of sha3. Commented Sep 10, 2019 at 7:21
  • It works, thanks man! @goodvibration
    – Ender
    Commented Sep 10, 2019 at 7:25

1 Answer 1

1

Turning a comment into an answer:

From the "web3.utils" part in your code, I conclude that you are using web3.js v1.x.

If that is indeed the case, then use web3.utils.soliditySha3 instead of web3.utils.sha3.

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.