1

I know you can add a network to brownie by using a command:

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

or for example:

brownie networks add development ganache-local host=http://127.0.0.1:7545 cmd=ganache

In both cases, I get a network named ganache-local that is connected to my ganache GUI and therefore I can deploy my smart contracts and do testing there.

However, what I want, is to know how to add network into brownie-confing.yaml file and have it work all the same. (As I am well used to doing that inside truffle-config.js)

I tried it in a few ways, but nothing worked so far. Here is my brownie-config.yaml. Hopefully, someone can tell me what I am doing wrong. (I am trying to add a network named local that has the same parameters as the ganache-local from the commands listed above.

networks:
  local: # the default network that brownie connects to
    host: "127.0.0.1"
    port: 7545
    chainid: 5777
    network_id: "*"
    cmd: ganache

compiler:
  solc:
    remappings:
      - "@openzeppelin=OpenZeppelin/[email protected]"

Whenever I try running: brownie run deploy.py --network local

I get an error: KeyError: 'local'

3 Answers 3

1

The solution is to add your network configuration inside .brownie/network-config.yaml NOT inside brownie-confing.yaml

Unlike truffle, where network configurations are inside truffle-config.js Brownie holds them inside network-config.yaml

I managed to set up new network just by adding this to the end of the network-config.yaml

 - name: Ganache-GUI
    chainid: 5777
    id: ganache-local
    host: http://localhost:7545

Simple as that.

1
1
  • This is how I added sepolia.
brownie networks add Ethereum sepolia host="https://rpc.sepolia.org/" chainid=11155111
  • Local testing
brownie networks add Ethereum local host=http://127.0.0.1:8545 chainid=1337
0

See my answer here, I also had issues adding Sepolia to brownie but now it works: https://ethereum.stackexchange.com/a/149826/97043

1
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review May 5 at 13:47

Your Answer

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

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