Hardhat – Fix Warning: Calling an Account Which is Not a Contract

hardhat

I deployed the contract on hardhat also deployed a few other chains like ganache, goerli. Whenever I deploy I save the deployment address to a file and later when I call functions I use that address.
For hardhat, although I could deploy successfully, when I call it I am getting "WARNING: Calling an account which is not a contract" this warning on the hardhat node logs.

I know there is another question and the user was suggested to correct the address, I mean he was using Mainnet address instead of hardhat address. In my case I am already using the correct address to call the contract. I am not sure why I am getting this. By the way, I have been using this code(both deployment and client) and previously I wasn't getting this error, and could see logs and event emissions from the smart contract function. Currently, I also do not get the relevant codes such as gas used etc. for the deployment.

I checked everything many times. Can someone help me to fix this please?

I am suspecting that I might be starting a new instance of the hardhat when I run the application_client in a new terminal but I do not want it. I am using the network parameter as below..

npx hardhat run --network hardhat .\scripts\frontend\application_frontend.ts

Many thanks in advance..
Ferda

Best Answer

you should deploy the contract with

npx hardhat run scripts/deploy.ts --network localhost

not

npx hardhat run scripts/deploy.ts --network hardhat
Related Topic