Brownie doesn't automatically attach to local ganache when I have Ganache open in the background. It is stuck with ganache-cli

Viewed 1908

Brownie doesn't automatically attach to local ganache when I have Ganache open in the background. It is stuck with ganache-cli (1st image) (2nd image is what I am looking for). Can someone help?

What I am stuck with

What im looking for

4 Answers

Check that the port numbers are the same between GUI and CLI. I was able to fix by going into Ganache (GUI) settings -> server and reset the port to 8545. Save and restart. Brownie should attach next time you run your deploy script.

The other solution is adding your local Ganache GUI account to the brownie networks list. To do that first you need to gather your host and chainid:

brownie networks add {network_class} {your_network_name} host={your_host} chainid={your_chaid}

Here, you have to change values between {}. For instance:

brownie networks add Ethereum ganache-local host=http://0.0.0.0:8545 chainid=1337

This command creates a new local network named 'ganache-local' on host 'http://0.0.0.0:8545' with '1337' chainid value in Ethereum class

To use this network on brownie commands, you need to set network flag to you network name. For instance I've created a network with the name of 'ganache-local' I can use this network like:

brownie run scripts/deploy.py --network ganache-local

With this way, you also can track your deployments on this network in deployments folder.

It seems to be attached to the Ganache that you are running, as its stated there. Ganache GUI opens up the instance of ganache-cli

I met the same problem. After I switch the port number from 7545 to 8545 in Ganache setting (the top right corner)---->Server---->Port Number. The problem was just solved. Brownie can attach to local Ganache by '127.0.0.1:8545'.

Hope this helps

Related