Could Not Detect Network on deploy.js - WSL & Ganache #34
-
const provider = new ethers.providers.JsonRpcProvider(
"HTTP://127.0.0.1:8545"
); Error:
My Ganache UI is running. I assume this has something to do with WSL/Ubuntu .. I've never used the linux side of anything before >.>. I tried setting my Host Name to 0.0.0.0 (All Interfaces) and reflecting that in my script, but there was no change. |
Beta Was this translation helpful? Give feedback.
Replies: 14 comments 112 replies
-
I'm not sure if this would help, but maybe you can try making the |
Beta Was this translation helpful? Give feedback.
-
Because you use WSL but Ganache UI opened is on Windows. You need to install ganache on WSL first then run the ganache server on WSL after that you can deploy on network. Here is the steps.
|
Beta Was this translation helpful? Give feedback.
-
Actually if you're running WSL 2, you can install & run Ganache(GUI) natively. And can simply use it; as it's actually installed on the Linux. Steps to run:
Voila! 🥳 |
Beta Was this translation helpful? Give feedback.
-
No problem! Feel welcome to join the Discord I set up for folks going
through this!
https://discord.gg/CtMVfhuV
…On Fri., Jun. 24, 2022, 6:08 a.m. a14i12, ***@***.***> wrote:
@Equious <https://github.com/Equious> thanks a lot bud i was completely
lost on this!!
—
Reply to this email directly, view it on GitHub
<#34 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ASHIK5BDOTNWRHMKDGA4273VQWQMHANCNFSM5XIPYCGQ>
.
You are receiving this because you were mentioned.Message ID:
<smartcontractkit/full-blockchain-solidity-course-js/repo-discussions/34/comments/3017239
@github.com>
|
Beta Was this translation helpful? Give feedback.
-
Looks like the Link JUST expired today, here's a new one
https://discord.gg/CtMVfhuV
…On Fri., Jun. 24, 2022, 9:05 a.m. mariusdique, ***@***.***> wrote:
Thanks mate but it tells me the invitation is invalid. In my case Itried
with the npm and also the yarn way. But I am not able to see the ganache
version. (ganache: command not found)
—
Reply to this email directly, view it on GitHub
<#34 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ASHIK5EGK6WDACHU5JSHLZDVQXFD3ANCNFSM5XIPYCGQ>
.
You are receiving this because you were mentioned.Message ID:
<smartcontractkit/full-blockchain-solidity-course-js/repo-discussions/34/comments/3018299
@github.com>
|
Beta Was this translation helpful? Give feedback.
-
You have to run ganache as “yarn run ganache” in the terminal.
…On Thu, 14 Jul 2022 at 4:41 AM, Madhav ***@***.***> wrote:
Guys I have tried all the things , i have installed ganache on the windows
in terminal yarn add ganache , but when i am typing ganache --version , it
is showing me command not found , I have also installed ganache on the
desktop as application , but again it when i am deploying wiht node
../deploy.js , it is giving error "Could not detect network"
Any Help please
—
Reply to this email directly, view it on GitHub
<#34 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAI7UCKTMPEXW7HCUS5BVSDVT6D5JANCNFSM5XIPYCGQ>
.
You are receiving this because you commented.Message ID:
<smartcontractkit/full-blockchain-solidity-course-js/repo-discussions/34/comments/3142810
@github.com>
|
Beta Was this translation helpful? Give feedback.
-
If it gets stuck on deploying after changing the hostname in Ganache UI (like this and this), then you have to allow the connection for Ganache in
|
Beta Was this translation helpful? Give feedback.
-
Well, I literally tried each one of these solutions multiple times (over 2+ hours) and was never able to actually run node deploy.js successfully. I imagine it was user error on my part, and I appreciate everyone's attempt at explaining the solution. I'm going to try and keep moving forward with the course. |
Beta Was this translation helpful? Give feedback.
-
Following up, this is what worked for me:
Must be some kind of firewall issue, but I didn't want to debug the networking, and instead just ran a simple command to run ganache in the terminal of VS code. In the top right corner of the terminal section, click the little plus icon to open a new terminal. Then enter the following:
copy the local IP address that's printed at the very bottom: "RPC Listening on 127.0.0.1:4444"
save it, then switch back to the other terminal window that isn't running ganache
Thanks to the other folks in this thread! |
Beta Was this translation helpful? Give feedback.
-
This is what worked for me 👍OPTION 1: If you want to install & run Ganache on your WSL itself👇
OPTION 2: If you want to run Ganache on your Windows ( if you have already installed Ganache on Windows )👇
Thanks a lot to All the people answering & also asking their doubts. ✌ |
Beta Was this translation helpful? Give feedback.
-
thanks very much! it works. |
Beta Was this translation helpful? Give feedback.
-
Thank you so much it worked for me I tried for an hour in UI but rejected the gas limit again and again, CLI worked for me 🎉🧨🎊 |
Beta Was this translation helpful? Give feedback.
-
Just updating to help folks, I've done today with latest ethers and all good: Install Ganache on WSL Run Ganache const ethers = require("ethers")
const fs = require("fs")
async function main() {
const provider = new ethers.JsonRpcProvider("http://127.0.0.1:8545");
const wallet = new ethers.Wallet(`you should change here with one of many available after running run ganache`, provider);
console.log('wallet - - - -', wallet.privateKey);
const abi = fs.readFileSync("./SimpleStorage_sol_SimpleStorage.abi", "utf-8");
const binary = fs.readFileSync("./SimpleStorage_sol_SimpleStorage.bin", "utf-8");
const contractFactory = new ethers.ContractFactory(abi, binary, wallet);
console.log("Deploying, please wait...")
const contract = await contractFactory.deploy();
console.log('contract - - -', contract);
}
main()
.then(() => process.exit(0))
.catch(error => {
console.error(error);
process.exit(1);
}) |
Beta Was this translation helpful? Give feedback.
-
If you are late on the course, the problem for me was ethers version and the ganache problem. Following the tutorial above to run ganache from vscode directly and installing ethers 5.7.0 should solve de problem
|
Beta Was this translation helpful? Give feedback.
This is what worked for me 👍
OPTION 1: If you want to install & run Ganache on your WSL itself👇
Install Ganache on WSL
yarn add ganache
Run Ganache
yarn run ganache
Copy the RPC URL (127.0.0.1:8545) from the bottom of the terminal screen that says RPC listening on 127.0.0.1:8545
& paste it in the ethers.js JsonRpcProvider( ) function parameter.
Also copy any Private key on scrolling up the Terminal Screen & paste it in the ethers.js Wallet( ) function parameter.
Now let this terminal run in the background, since we want our Ganache server to be running.
So open a new terminal & run the deploy.js file by running the below command:
node deploy.js
OPTION 2: If you want to run Ga…