full-blockchain-solidity-course-js icon indicating copy to clipboard operation
full-blockchain-solidity-course-js copied to clipboard

Error: could not detect network (event="noNetwork", code=NETWORK_ERROR, version=providers/5.6.8) {

Open mmuaaz opened this issue 3 years ago • 6 comments

Lesson

Lesson 5

Could you please leave a link to the timestamp in the video where this error occurs? (You can right click a video and "copy video URL at current time")

(https://youtu.be/gyMwXuJrbJQ?t=25651)

Operating System

Windows

Describe the bug

Lesson 5: Ganache & Networks Timestamp: 07:07:31 : https://youtu.be/gyMwXuJrbJQ?t=25651

at this point when I run command $node deploy.js while running GANACHE, I get an error:

Error: could not detect network (event="noNetwork", code=NETWORK_ERROR, version=providers/5.6.8)
{
  reason: 'could not detect network',
  code: 'NETWORK_ERROR',
  event: 'noNetwork'
  }

Apparently Visual studio code is not communicating with Ganache RPC network and we are getting this error. I had been trying so many things and searching what mistake did I make and rewriting and all that then I found a thread in the Github repo Discussions, which resolves the problem.

(Link: https://github.com/smartcontractkit/full-blockchain-solidity-course-js/discussions/1089).

I also contributed to the thread as there are further problem with it. So, as I am here to learn I wanted to know the details of whats going on, may be some guy with knowledge be able to tell and help us learn thanks

mmuaaz avatar Jul 25 '22 12:07 mmuaaz

I had the same issue and fix it like this: go to your ganache app and open settings => server => Hostname and change it from All Interfaces to WSL it worked for me hope the same for you

Alcapone59 avatar Jul 27 '22 18:07 Alcapone59

Thank you this works

mmuaaz avatar Aug 05 '22 16:08 mmuaaz

I am still getting this error after doing ganache app and open settings => server => Hostname and change it from All Interfaces to WSL

kuldeep-1509 avatar Aug 14 '22 14:08 kuldeep-1509

this is my code const ethers=require("ethers"); const fs=require("fs"); async function main(){ //compile them in our code //compile them separa tely //rpc url http://127.0.0.1:7545 const provider=new ethers.providers.JsonRpcProvider("http://0.0.0.0:7545"); const wallet=new ethers.Wallet("2f68fdcb9d9fbcfc2ea6dcb8e9cea45d73524e63f3e43e9a15524ac3f3cf81e4",provider); const abi=fs.readFileSync("./simplestorage_sol_SimpleStorage.abi","utf8"); const binary=fs.readFileSync("./simplestorage_sol_SimpleStorage.bin","utf8"); const contractFactory=new ethers.ContractFactory(abi,binary,wallet); console.log("Deploying, please wait..."); const contract=await contractFactory.deploy();

console.log(contract);

} main() .then(()=>process.exit(0)) .catch((error)=>{ console.error(error); process.exit(1); });

kuldeep-1509 avatar Aug 14 '22 14:08 kuldeep-1509

my error got fixed like this go to your ganache app and open settings => server => Hostname and change it from All Interfaces to Ethernet I was using internet through ethernet that's why I was getting error

kuldeep-1509 avatar Aug 20 '22 04:08 kuldeep-1509

Thank you this works

Please close this if it is solved.

anannyenaik avatar Sep 15 '22 04:09 anannyenaik

use:

const fs=require("fs-extra");

uditrajawat avatar Oct 12 '22 11:10 uditrajawat

I had the same issue and fix it like this: go to your ganache app and open settings => server => Hostname and change it from All Interfaces to WSL it worked for me hope the same for you

This worked for me.

peibo0318 avatar Mar 25 '23 13:03 peibo0318