Web3js Error – Handling “web3.toWei is Not a Function”

web3js

Using Web3 version 1.0 and getting the following error:

web3.toWei is not a function

Best Answer

At Web3 version 1.0, utility functions like toWei and many others have been moved to the web3.utils.

To check all utility functions refer to:

https://web3js.readthedocs.io/en/1.0/web3-utils.html