I need to use a web3.utils.soliditySha3 function in my javascript but web3.utils gives:

Cannot read property 'soliditySha3' of undefined

My script can't use .require as well. I tried:

<script src="https://cdn.jsdelivr.net/gh/ethereum/[email protected]/dist/web3.min.js"></script>

to no avail. Please help.


1 Answer 1


On web3.js v0.x, you have:

On web3.js v1.x, you have:

You will therefore need to upgrade from v0.x to v1.x.

  • Sorry but how do i do that? i thought that my imported script is already v1+ Apr 18, 2020 at 18:46
  • @bishopqpalzm: Change 1.0.0-beta.34 to 1.2.6 I suppose. Apr 18, 2020 at 18:48
  • error in loading web3.min.js: require is not defined. I'm using a Python Flask server instead of npm. Apr 18, 2020 at 18:53
  • @bishopqpalzm: I'm not familiar with how things work on the front-end side, but your problem is an older version of web3 which does not support soliditySha3 (and doesn't even have the utils module). So you probably want to post a separate question on how to import web3.js v1.2.x on front-end. If you do so, then please consider accepting this answer (if you feel that it has answered your question). Apr 18, 2020 at 18:56

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.