I am kinda new to Ethereum and Web3 so I am trying to implement the Ethereum: Building Blockchain Decentralized Apps (DApps) tutorial. I have already installed web3 and web3-utils.
npm view web3 version
1.0.0-beta.48
My code is :
<script src="web3.min.js"></script>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<script>
//checking the version of web3
if ((typeof window.ethereum !== 'undefined') || (typeof window.web3 !== 'undefined')){
web3 = new Web3(web3.currentProvider);
} else{
web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
}
var version = web3.version.api;
console.log("Using web3 version: " + version);
//Form function
$('#contract-form').submit(function(event){
event.preventDefault();
var fromAddress = $('#fromAddress').val();
//checking if the address of the uploader's is valid
if(web3.utils.isAddress(fromAddress) != true) {
alert('You did not enter a valid ethereum address.');
return;
}
});
</script>
I get the error
TypeError: web3.utils is undefined[Learn More
I actually upgraded my web3 version to 1.0.0 in case this question's solution worked in my problem but nothing changed. Any help would be valuable , thanks.