Skip to content

Lesson 10: Getting "Undefined" for the getEntranceFee() function** #5835

Answered by alfaqi
chimneyboy1 asked this question in Q&A
Discussion options

You must be logged in to vote

1- the code is fine, just missed this functionName: instead of function,
and I think it is contractAddress not contractAddresses
like this

  const { runContractFunction: getEntranceFee } = useWeb3Contract({
    abi: abi,
    contractAddress: raffleAddress,
    functionName: "getEntranceFee",
    params: {},
  });

2- you can use useState hook instead of using native variables.

const [entranceFee, setEntranceFee] = useState("");

after changes will be like this

  const entranceFeeFunction = async () => {
    const entranceFee = await getEntranceFee();
    setEntranceFee(entranceFee.toString());
    console.log(`entranceFee ${entranceFee}`);
  };

  useEffect(() => {
    if (isWeb3Enabled) {

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@chimneyboy1
Comment options

Answer selected by chimneyboy1
Comment options

You must be logged in to vote
1 reply
@chimneyboy1
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants