I have deployed the contract made using solidity locally using hardhat. When I get the contract and make a call to a view function using the contract in React website I get a CALL_EXCEPTION error in the console and also get a error in hardhat node console saying “Warning: Calling an account which is not a contract”.
This is the function I use in React
const GetMessage = async () => {
try {
const {ethereum} = window;
if (ethereum) {
const provider = new ethers.providers.Web3Provider(ethereum);
const signer = provider.getSigner();
const supplyChainContract = new ethers.Contract(
contractAddress,
contractABI,
signer
);
let count = await supplyChainContract.GetCount();
console.log(count.toNumber());
}
else
setMessage("Ethereum Not Found");
} catch (error) {
console.log(error);
return null;
}
};
This is the contract
pragma solidity ^0.8.17;
import "../node_modules/hardhat/console.sol";
contract SupplyChain {
uint256 public count;
function GetCount() public view returns (uint256){
return count + 1;
}
}