Im using local hardhat node for deploying my contracts and using Thirdweb writeContract to execute a registerUser function from my smart contract, I've added the contract address, ABI, clientid and network as Localhost with chain id 1337. Howeover when I execute function s from my frontend, it says the function registerUser does not exist.
Also from thirdweb's dashboard I've setup the local network with correct rpc 127.0.01:8545
this is the part of code where error is taking place on the onclick event of the button, how what is the issue here.
import React, { useEffect } from "react"; import { useEnhancedVotingDAO } from './ContractInteraction'; import { useAddress, useContractWrite } from "@thirdweb-dev/react"; const Homepage = () => { const address = useAddress(); const contractAddress = process.env.REACT_APP_ADDRESS; // const contractAddress = "0x5FbDB2315678afecb367f032d93F642f64180aa3"; const { contract, useWriteRegisterUser, useWriteRegisterPolitician, // useWriteRegisterAdmin } = useEnhancedVotingDAO(contractAddress); useEffect(() => { console.log("Wallet address ", address); console.log("Contract address is ", contractAddress); console.log("Contract from Interaction is ", contract); }, [address]); const { mutateAsync: registerUser } = useWriteRegisterUser("0x5FbDB2315678afecb367f032d93F642f64180aa3", "registerUser"); // const { mutateAsync: registerUser } = () => useContractWrite(contract, "registerUser"); const handleRegisterUser = async () => { try { console.log("Registering user with address: ", address); await registerUser({ args: [] }); alert("Successfully registered as a voter!"); } catch (error) { console.error("Error registering user:", error); alert(error); } }; Smart Contract function
function registerUser() public { require(projectVotes[0][msg.sender].weight == 0, "User already registered"); _userCounter++; projectVotes[0][msg.sender].weight = 1; // Use project 0 as a dummy project for user registration } 