0

npx hardhat run scripts/deploy.js --network localhost is not working. It says

TypeError: Cannot read properties of undefined (reading 'JsonRpcProvider')

My deploy script

const hre = require("hardhat");

async function main() {
  const ChatApp = await hre.ethers.getContractFactory("ChatApp");
  const chatApp = await ChatApp.deploy();
  await chatApp.deployed();
  console.log(`Contract Address: ${ChatApp.address}`);
}

main()
  .catch((error) => { 
    console error(error);
    process.exitCode = 1;
  });
1

1 Answer 1

2

Try downgrading "ethers" to version 5.4 in your package.json, then delete your node_modules folder and finally run "npm install" again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.