-
Hi while I was following the lesson on 17:45:53 I ran into a little issue for some reason the console logs out for the entranceFee //Have a function to enter the lottery
import { useEffect } from "react"
import { useWeb3Contract, useMoralis } from "react-moralis"
import { abi, contractAddresses } from "../constants"
export default function LotteryEntrance() {
const { chainId: chainIdHex, isWeb3Enabled } = useMoralis()
console.log(parseInt(chainIdHex))
const chainId = parseInt(chainIdHex)
const raffleAddress = chainIdHex in contractAddresses ? contractAddresses[chainId][0] : null
// const { runContractFunction: enterRaffle } = useWeb3Contract({
// abi: abi,
// contractAddress: raffleAddress, // specify the networkId
// functionName: "enterRaffle",
// params: {},
// msgValue: {},
// })
const { runContractFunction: getEntranceFee } = useWeb3Contract({
abi: abi,
contractAddress: raffleAddress, // specify the networkId
functionName: "getEntranceFee ",
params: {},
})
useEffect(() => {
if (isWeb3Enabled) {
//try to reed the raffle entranceFee
async function updateUi() {
const entranceFeeFromContract = await getEntranceFee()
console.log(entranceFeeFromContract)
}
updateUi()
}
}, [isWeb3Enabled])
return <div> Hi from lottery entrance</div>
} And this is what the. console logs out:
I have looked for similar questions and found that the issue is in the chainId of metamask |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
ah sorry I haven't seen that further in the lesson there are changes sorry |
Beta Was this translation helpful? Give feedback.
-
I could not fix this error for a long time and figured out that there was no need to It was adding a stringified version of json in my |
Beta Was this translation helpful? Give feedback.
ah sorry I haven't seen that further in the lesson there are changes sorry