{"id":8142,"library":"eth-brownie","title":"Brownie","description":"Brownie is a Python-based development and testing framework for smart contracts targeting the Ethereum Virtual Machine (EVM). It simplifies the process of deploying, testing, and interacting with Solidity and Vyper smart contracts. The library is actively maintained with regular updates, including development releases leading to minor version bumps, typically focusing on performance, compiler support, and ecosystem compatibility.","status":"active","version":"1.21.0","language":"en","source_language":"en","source_url":"https://github.com/eth-brownie/brownie","tags":["ethereum","smart-contracts","web3","testing","development","solidity","vyper"],"install":[{"cmd":"pip install eth-brownie","lang":"bash","label":"Install stable version"},{"cmd":"pip install --pre eth-brownie","lang":"bash","label":"Install pre-release version (e.g., 1.22.0.devX)"}],"dependencies":[],"imports":[{"note":"Used to load the current Brownie project.","symbol":"project","correct":"from brownie import project"},{"note":"For connecting to and managing blockchain networks.","symbol":"network","correct":"from brownie import network"},{"note":"Provides access to local or connected blockchain accounts.","symbol":"accounts","correct":"from brownie import accounts"},{"note":"A factory for interacting with deployed contracts or abstract interfaces.","symbol":"Contract","correct":"from brownie import Contract"},{"note":"Compiled contracts are automatically exposed as top-level objects via the brownie import, assuming a project is loaded.","wrong":"from contracts.SimpleStorage import SimpleStorage","symbol":"SimpleStorage","correct":"from brownie import SimpleStorage"}],"quickstart":{"code":"# 1. First, set up a Brownie project and a simple contract:\n# $ brownie init simple_project\n# $ cd simple_project\n# $ mkdir contracts\n# $ echo '// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\ncontract SimpleStorage {\\n    uint256 public number;\\n    function store(uint256 _number) public { number = _number; }\\n    function retrieve() public view returns (uint256) { return number; }\\n}' > contracts/SimpleStorage.sol\n# $ mkdir scripts\n\n# 2. Then, create scripts/deploy_and_interact.py with the following content:\n\nfrom brownie import SimpleStorage, accounts, network\n\ndef main():\n    # Connect to a local development network (e.g., Ganache, Hardhat)\n    # If not already connected, Brownie will attempt to launch a local 'ganache-cli' fork\n    if not network.is_connected():\n        network.connect('development')\n\n    print(f\"Active network: {network.show_active()}\")\n\n    # Get the first available account for deployment\n    deployer = accounts[0]\n    print(f\"Deploying from account: {deployer.address}\")\n\n    # Deploy the SimpleStorage contract\n    print(\"Deploying SimpleStorage...\")\n    simple_storage = SimpleStorage.deploy({\"from\": deployer})\n    print(f\"SimpleStorage deployed at: {simple_storage.address}\")\n\n    # Interact with the contract\n    initial_value = simple_storage.retrieve()\n    print(f\"Initial stored value: {initial_value}\")\n\n    new_value = 777\n    print(f\"Storing new value: {new_value}\")\n    tx = simple_storage.store(new_value, {\"from\": deployer})\n    tx.wait(1) # Wait for the transaction to be mined\n\n    updated_value = simple_storage.retrieve()\n    print(f\"Updated stored value: {updated_value}\")\n\n# 3. Finally, run the script from your project root:\n# $ brownie run scripts/deploy_and_interact.py --network development","lang":"python","description":"This quickstart demonstrates how to create a Brownie project, define a simple Solidity contract, deploy it to a local development network, and interact with its functions. It assumes a local blockchain (like Ganache or Hardhat) is running or can be launched by Brownie. Run `brownie init` and create the `SimpleStorage.sol` file as described in the comments before executing the Python script."},"warnings":[{"fix":"Review `web3.py` v7 migration guide for middleware. Update Brownie middleware integration logic when upgrading to v1.22.0 stable.","message":"Upcoming `web3.py` v7 upgrade in Brownie v1.22.x will break custom middleware integrations. If you use custom `web3.py` middleware, expect changes.","severity":"breaking","affected_versions":">=1.22.0 (pre-releases show this change)"},{"fix":"Consolidate your Etherscan API keys into a single `ETHERSCAN_TOKEN` environment variable. Refer to Brownie documentation for details on environment variables.","message":"The Etherscan API key handling changed in v1.21.0. Instead of network-specific environment variables (e.g., `ETHERSCAN_TOKEN_MAINNET`), a single `ETHERSCAN_TOKEN` variable is now used for all networks.","severity":"breaking","affected_versions":">=1.21.0"},{"fix":"Ensure you are using a compatible Python version (e.g., Python 3.10 or 3.11). Using Python 3.9 or 3.12+ will likely lead to installation or runtime errors.","message":"Brownie has strict Python version requirements. Version 1.21.0 requires Python >=3.10 and <4.","severity":"gotcha","affected_versions":"All versions >=1.21.0"},{"fix":"Manually install `solc` using `brownie solc install <version>` (e.g., `brownie solc install 0.8.0`). Ensure `py-solc-x` is up-to-date or compatible with your OS. For some systems, manual `solc` installation via system package managers might be required.","message":"Solidity compiler (solc) installation issues are common, especially when `py-solc-x` encounters download errors or requires a specific version not available on your system.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Install the required solc version using `brownie solc install <version>` (e.g., `brownie solc install 0.8.0`). Check your project's `pragma` statements for the exact version needed.","cause":"Brownie cannot find a suitable Solidity compiler (solc) version for your contracts.","error":"ValueError: No compatible Solc version installed."},{"fix":"Connect to a network using `network.connect('development')` for a local test chain, or `network.connect('mainnet')` for a live network, before any blockchain interaction.","cause":"Attempting to deploy or interact with contracts without an active blockchain network connection.","error":"ValueError: Network not connected. Please connect to a network prior to interacting with contracts."},{"fix":"Deployment is done via the contract factory obtained from `brownie import` or `project.load()`. Correct usage is `SimpleStorage.deploy({'from': accounts[0]})` where `SimpleStorage` is the imported contract factory.","cause":"Trying to deploy a contract using an *instance* of a compiled contract (e.g., `SimpleStorage().deploy()`) instead of the contract factory itself.","error":"AttributeError: 'BrownieContract' object has no attribute 'deploy'"},{"fix":"Ensure contract calls are made using `contract.method(arg1, arg2, {'from': account})` for transactions, or `contract.method(arg1, arg2).call()` for view/pure functions without transaction context. Avoid `contract.method[args]`.","cause":"Often occurs when attempting to call a contract method with arguments using incorrect Python syntax, treating the method as if it were a dictionary or list.","error":"TypeError: 'function' object is not subscriptable"}]}