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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | project_structure: build: build contracts: contracts interfaces: interfaces reports: reports scripts: scripts tests: tests networks: default: development 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: null live: gas_limit: auto gas_buffer: 1.1 gas_price: auto max_fee: null priority_fee: null reverting_tx_gas_limit: false default_contract_owner: false compiler: evm_version: null solc: version: null optimizer: enabled: true runs: 200 remappings: null vyper: version: null console: show_colors: true color_style: monokai auto_suggest: true completions: true editing_mode: emacs reports: exclude_paths: null exclude_contracts: null only_include_project: true hypothesis: deadline: null max_examples: 50 report_multiple_bugs: False stateful_step_count: 10 phases: explicit: true reuse: true generate: true target: true shrink: true autofetch_sources: false dependencies: null dev_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’
-
-
compiler.
vyper
¶ Settings specific to the Vyper compiler.
-
version
The version of vyper 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 vyper versions>=0.1.0-beta.16
.default value:
null
-
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