I am trying to integrate web3.js but getting this error. Attaching the screenshots of my JS code
<script>
window.ethereum.enable( );
const provider = new ethers.providers.Web3Provider(web3.currentprovider, "goerli");
const MoodContractAddress = "0x65B1174cDBb463e0F9132c09aaEDc63b02986D7D";
const MoodContractABI = [
{
"inputs": [
{
"internalType": "string",
"name": "_mood",
"type": "string"
}
],
"name": "setMood",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "getMood",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
}
]
let MoodContract;
let signer;
provider.send("eth_requestAccounts", []).then(() => {
provider.listAccount().then(function(accounts) {
signer = provider.getsigner(accounts[0]);
MoodContract = new ethers.Contract(MoodContractAddress, MoodContractABI, signer);
});
});
async function getMood(){
var getMoodPromise = MoodContract.getMood();
var Mood = await getMoodPromise;
console.log(Mood);
}
async function setMood(){
var mood= getElementById("mood").value;
var setMoodPromise = MoodContract.setMood(mood);
await setMoodPromise;
}
</script>
I was expecting that the get mood and set mood buttons would work, but they did not work and instead I am getting this error.