The Configuration File
You can modify Brownie’s default behaviours by creating an optional configuration file.
The configuration file must be saved as brownie-config.yaml
. If saved in the root directory of a project it will be loaded whenever that project is active. If saved in your home path, it will always be loaded.
All configuration fields are optional. You can copy from the examples below and modify the settings as required.
Configuration values can also be set using environment variables, as well as by specifying the dotenv top-level key.
Default Configuration
The following example shows all configuration settings and their default values:
1project_structure:
2 build: build
3 contracts: contracts
4 interfaces: interfaces
5 reports: reports
6 scripts: scripts
7 tests: tests
8
9networks:
10 default: development
11 development:
12 gas_limit: max
13 gas_buffer: 1
14 gas_price: 0
15 max_fee: null
16 priority_fee: null
17 reverting_tx_gas_limit: max
18 default_contract_owner: true
19 cmd_settings: null
20 live:
21 gas_limit: auto
22 gas_buffer: 1.1
23 gas_price: null
24 max_fee: null
25 priority_fee: auto
26 reverting_tx_gas_limit: false
27 default_contract_owner: false
28
29compiler:
30 evm_version: null
31 solc:
32 version: null
33 optimizer:
34 enabled: true
35 runs: 200
36 remappings: null
37 vyper:
38 version: null
39
40console:
41 show_colors: true
42 color_style: monokai
43 auto_suggest: true
44 completions: true
45 editing_mode: emacs
46
47reports:
48 exclude_paths: null
49 exclude_contracts: null
50 only_include_project: true
51
52hypothesis:
53 deadline: null
54 max_examples: 50
55 report_multiple_bugs: False
56 stateful_step_count: 10
57 phases:
58 explicit: true
59 reuse: true
60 generate: true
61 target: true
62 shrink: true
63
64autofetch_sources: false
65dependencies: null
66dev_deployment_artifacts: false
Variable Expansion
Brownie supports POSIX-style variable expansion for environment variables.
networks:
default: ${DEFAULT_NETWORK}
You can also provide defaults.
networks:
default: ${DEFAULT_NETWORK:-mainnet}
Settings
Project Structure
Project subdirectory names. Include these fields if you wish to modify the default structure of your project.
- project_structure.build
Project subdirectory that stores data such as compiler artifacts and unit test results.
default value:
build
- project_structure.contracts
Project subdirectory that stores contract source files.
default value:
contracts
- project_structure.interfaces
Project subdirectory that stores interface source files and ABIs.
default value:
interfaces
- project_structure.reports
Project subdirectory that stores JSON report files.
default value:
reports
- project_structure.scripts
Project subdirectory that stores scripts for deployment and interaction.
default value:
scripts
- project_structure.tests
Project subdirectory that stores unit tests.
default value:
tests
Networks
- default
The default network that Brownie connects. If a different network is required, you can override this setting with the
--network
flag in the command line.default value:
development
- networks.development
This setting is only available for development networks.
- cmd_settings
Additional commandline parameters, which are passed into Ganache as commandline arguments. These settings will update the network specific settings defined in network management whenever the project with this configuration file is active.
The following example shows all commandline settings with their default value.
fork
,disable_cache
andunlock
have no default values.network_id
andtime
will default to the current timestamp or time respectively. See adding a development network for more details on the arguments.
networks: development: gas_limit: max gas_buffer: 1 gas_price: 0 max_fee: null priority_fee: null reverting_tx_gas_limit: max default_contract_owner: true cmd_settings: port: 8545 gas_limit: 6721975 accounts: 10 chain_id: 1337 network_id: 1588949648 evm_version: istanbul fork: null disable_cache: null mnemonic: brownie block_time: 0 default_balance: 100 time: 2020-05-08T14:54:08+0000 unlock: null
- networks.live
Default settings for development and live environments.
- gas_limit
The default gas limit for all transactions. If set to
auto
the gas limit is determined usingweb3.eth.estimate_gas
. If set tomax
, the block gas limit is used.development default:
max
live default:
auto
- gas_buffer
A modifier applied to
web3.eth.estimate_gas
when determining gas price automatically.development default:
1
live default:
1.1
- gas_price
The default gas price for all transactions. If set to
auto
the gas price is determined usingweb3.eth.gas_price
.development default:
0
live default:
auto
- max_fee
The default max fee per gas for all transactions. If set to
null
, transactions will default to legacy-style (usinggas_price
).default:
null
- priority_fee
The default max priority fee per gas for all transactions. If set to
null
, transactions will default to legacy-style (usinggas_price
).default:
null
- default_contract_owner
If
false
, deployed contracts will not remember the account that they were created by. Every transaction will require afrom
kwarg.
- reverting_tx_gas_limit
The gas limit to use when a transaction would revert. If set to
false
, transactions that would revert will instead raise aVirtualMachineError
.development default:
max
live default:
false
Compiler
Compiler settings. See compiler settings for more information.
- evm_version
The EVM version to compile for. If
null
the most recent one is used. Possible values arebyzantium
,constantinople
,petersburg
,istanbul
,atlantis
andagharta
.default value:
null
- compiler.solc
Settings specific to the Solidity compiler.
- version
The version of solc to use. Should be given as a string in the format
0.x.x
. If set tonull
, the version is set based on the contract pragma. Brownie supports solc versions>=0.4.22
.default value:
null
- viaIR
Enable solc compilation pipeline to go through the Yul Intermediate Representation to generate IR-based EVM bytecode. See the Solidity documentation for breaking changes.
default value:
false
- optimizer
Optimizer settings to be passed to the Solidity compiler. Values given here are passed into the compiler with no reformatting. See the Solidity documentation for a list of possible values.
- remappings
Optional field used to supply path remappings.
remappings: - zeppelin=/usr/local/lib/open-zeppelin/contracts/ - github.com/ethereum/dapp-bin/=/usr/local/lib/dapp-bin/
- use_latest_patch
Optional boolean or array contract list to use the latest patch semver compiler version. E.g. the if the contract has pragma version 0.4.16 and the latest available patch for 0.4 is 0.4.22 it will use this instead for compilations.
Enable for all contracts: .. code-block:: yaml
- compiler:
- solc:
use_latest_patch: true
Enable for only specific contracts: .. code-block:: yaml
- compiler:
- solc:
- use_latest_patch:
‘0x514910771AF9Ca656af840dff83E8264EcF986CA’
Console
- show_colors
Enable or disable colorful output.
default value:
true
- color_style
Set the Pygments color style used within the console and throughout Brownie.
You can view a gallery of popular styles here.
default value:
monokai
- auto_suggest
Enable or disable type hints for contract function inputs.
default value:
true
- completions
Enable or disable autocompletion.
default value:
true
- editing_mode
Choose between
emacs
andvi
console editing modes.default value:
emacs
Reports
Settings related to reports such as coverage data and gas profiles.
- exclude_paths
Paths or glob patterns of source files to be excluded from report data.
default value:
null
reports: exclude_paths: - contracts/mocks/**/*.* - contracts/SafeMath.sol
- exclude_contracts
Contract names to be excluded from report data.
default value:
null
reports: exclude_contracts: - SafeMath - Owned
- only_include_project
If
false
, reports also include contracts imported from outside the active project (such as those compiled viacompile_source
).default value:
true
Hypothesis
Default settings for property-based and stateful test execution. See the Hypothesis settings documentation for a complete list of available settings.
hypothesis:
deadline: null
max_examples: 50
report_multiple_bugs: False
stateful_step_count: 10
deadline: null
phases:
explicit: true
reuse: true
generate: true
target: true
shrink: true
Other Settings
- autofetch_sources
If enabled, Brownie will always attempt to fetch source code for unknown addresses using
Contract.from_explorer
.default value:
false
- dependencies
A list of packages that a project depends on. Brownie will attempt to install all listed dependencies prior to compiling the project.
dependencies: - aragon/aragonOS@4.0.0 - defi.snakecharmers.eth/compound@1.1.0
See the Brownie Package Manager to learn more about package dependencies.
- dev_deployment_artifacts
If enabled, Brownie will save deployment artifacts for contracts deployed on development networks and will include the “dev” network on the deployment map.
This is useful if another application, such as a front end framework, needs access to deployment artifacts while you are on a development network.
default value:
false
- dotenv
If present, Brownie will load the .env file, resolving the file relative to the project root. Will fail loudly if .env file is missing.
dotenv: .env