Error: could not detect network (event="noNetwork", code=NETWORK_ERROR, version=providers/5.6.8) {
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
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
Thank you this works
I am still getting this error after doing ganache app and open settings => server => Hostname and change it from All Interfaces to WSL
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); });
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
Thank you this works
Please close this if it is solved.
use:
const fs=require("fs-extra");
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.