Lesson 10 : TypeError: Cannot read properties of undefined (reading 'toString') #5894
Replies: 5 comments 5 replies
-
First after deploy the contract, make sure your backend is running (if you're using localhost, but you don't need if you'll use testnet). |
Beta Was this translation helpful? Give feedback.
-
@MrPositive0709 I ran into the same issue then I noticed I wasn't connected to hardhat-localhost. Make sure your Metamask is connected to hardhat-localhost and your hardhat node is running. It should work properly |
Beta Was this translation helpful? Give feedback.
-
First make the async function updateUI() {
const entranceFeeFromCall = (await getEntranceFee()).toString()
const numPlayersFromCall = (await getPlayersNumber()).toString()
const recentWinnerFromCall = await getRecentWinner()
setEntranceFee(entranceFeeFromCall)
setNumberOfPlayers(numPlayersFromCall)
setRecentWinner(recentWinnerFromCall)
}
useEffect(() => {
if (isWeb3Enabled) {
updateUI()
}
}, [isWeb3Enabled]) |
Beta Was this translation helpful? Give feedback.
-
Hii @MrPositive0709 , don't worry async function updateAbi(){ |
Beta Was this translation helpful? Give feedback.
-
Hello everyone |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I ran into this bug :

this is LotteryEntrance.js file :
`//have a function to enter the lottery
import { useWeb3Contract } from "react-moralis"
import { abi, contractAddresses } from "../constants/index"
import { useMoralis } from "react-moralis"
import { useEffect, useState } from "react"
import { ethers } from "ethers"
export default function LotteryEntrance() {
const { chainId: chainIdHex, isWeb3Enabled } = useMoralis()
const chainId = parseInt(chainIdHex)
const raffleAddress = chainId in contractAddresses ? contractAddresses[chainId][0] : null
let [entranceFee, setEntranceFee] = useState("0")
}
`
Beta Was this translation helpful? Give feedback.
All reactions