5

i have a smartcontract developed with brownie. I want to deploy it to ganache. If i run my deployment script brownie run scripts/deploy.py, brownie deploys the smartcontract with ganache-cli. But i want to deploy it to the desktop version of ganache so i can use it in a more convenient manner. I can have a look at my networks with brownie networks list and i can see different networks like Ethereum mainnet, Ropsten etc. and the Development networks:

Development
  ├─Ganache-CLI: development
  ├─Geth Dev: geth-dev
  ├─Hardhat: hardhat
  ├─Hardhat (Mainnet Fork): hardhat-fork
  ├─Ganache-CLI (Mainnet Fork): mainnet-fork
  ├─Ganache-CLI (BSC-Mainnet Fork): bsc-main-fork
  ├─Ganache-CLI (FTM-Mainnet Fork): ftm-main-fork
  ├─Ganache-CLI (Polygon-Mainnet Fork): polygon-main-fork
  └─Ganache-CLI (XDai-Mainnet Fork): xdai-main-fork

since using the brownie run scripts/deploy.py without the --network option deploys it to the development network, i guess something has to be configured so it is not using the Ganache-CLI. I cannot find a way to deploy it to my ganache desktop. I have seen in a tutorial, that brownie usally automatically connects to ganache desktop via RPC-Client, if its running. But on my computer it is not working.

2 Answers 2

8

okay. I found the solution. I can add a local network in my network list with :

brownie networks add Ethereum ganache-local host=http://127.0.0.1:7545 chainid=5777

where ganache-local is a name i choose and where host + chainid is from the running Ganache-desktop version. After running that command you can see a Success message:

SUCCESS: A new network 'ganache-local' has been added
  └─ganache-local
    ├─id: ganache-local
    ├─chainid: 5777
    └─host: HTTP://127.0.0.1:7545

if you run now brownie networks list, under the Ethereum section you will see the new ganache-local

Ethereum
  ├─Mainnet (Infura): mainnet
  ├─Ropsten (Infura): ropsten
  ├─Rinkeby (Infura): rinkeby
  ├─Goerli (Infura): goerli
  ├─Kovan (Infura): kovan
  └─ganache-local: ganache-local

now i can run brownie run scripts/deploy.py --network ganache-local and deploy to ganache-desktop

you can delete the network with brownie networks delete ganache-local

1

The problem is your Brownie is looking for a server in the localhost port 8545 (a legacy config). The Ganache Desktop app, by default runs it in the 7545. If you change the port to 8545 it should be able to pick it up automatically and not run an instance of ganache-cli instead.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.