Web3.js – How to Import Web3 Utils in Front-End JavaScript

javascriptweb3js

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/web3.js@1.0.0-beta.34/dist/web3.min.js"></script>

to no avail. Please help.

Best Answer

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.

Related Topic