PatrickAlphaC / hardhat-fund-me-fcc

82 stars 183 forks source link

Error : No Contract deployed with name FundMe once run yarn hardhat run scripts/fund.js #63

Closed technqvi closed 2 years ago

technqvi commented 2 years ago

I clone your project and run yarn in order to install all dependency packages. I did the following steps.

  1. npx hardhat deploy

    image
  2. yarn hardhat run scripts/fund.js OR npx hardhat run scripts\fund.js

This is a Given Error Error: No Contract deployed with name FundMe at Object.getContract (D:\BC-World\BC-Dev\WEB3_JS\Patrick-JSLab\patrick_hardhat-fund-me\node_modules\@nomiclabs\hardhat-ethers\src\internal\helpers.ts:447:11) at processTicksAndRejections (node:internal/process/task_queues:96:5) at main (D:\BC-World\BC-Dev\WEB3_JS\Patrick-JSLab\patrick_hardhat-fund-me\scripts\fund.js:5:18)

I imagine that it occure error from https://github.com/wighawag/hardhat-deploy-ethers#installation

PatrickAlphaC commented 2 years ago

Please do not send screenshots but instead send text of the errors.

fund.js only works after you deploy to a local network or testnet.

To fix, do the following:

yarn hardhat node

This will spin up a local node in your terminal.

In a new terminal , then run yarn hardhat run scripts/fund.js and you'll see it work.

Error: No Contract deployed with name FundMe means that no contract has been deployed. This makes sense since you don't have your chain running. When you run yarn hardhat deploy without specifying a network, it'll default to a local hardhat network. Since you don't have a local hardhat network running, it deploys fundMe to a temporary chain, and then deletes it after the script finishes running.