Skip to main content
CodeSpeedTest
Languages
Start TypingJump into a test — pick any languageAdaptive TrainingUnlock chars as you master themPractice DrillsFocused sessions targeting weak spotsDaily ChallengesNew coding challenges every dayRace ModeCompete against others in real timeAI OpponentRace against an AI at your WPM levelTournamentsLive coding speed tournamentsArcade GamesZType, Overkill Survival, Glyphica & moreGamificationXP, coins, badges & quests
LeaderboardGlobal rankings for every languageCertificatesEarn verifiable Bronze / Silver / Gold certsActivityDaily streaks & historical analyticsProfileYour stats, badges & achievements
Browse Languages500+ languages with real code examplesBlogTips, guides & deep divesFree ToolsWPM calculator, typing speed report & moreFAQCommon questions answeredGetting StartedNew to CodeSpeedTest?AboutOur story & missionSupportGet help — Pro users get priorityContactGet in touch with the team
Pricing
  1. Home
  2. /
  3. Learn
  4. /
  5. Brownie

Learn Brownie - 10 Code Examples & CST Typing Practice Test

Brownie is an open-source Python-based framework for Ethereum smart contract development, testing, and deployment. It integrates with Ethereum networks and provides a full-featured environment for building decentralized applications (dApps).

View all 10 Brownie code examples →
Brownie Minimal Smart Contract DeploymentBrownie ERC20 Token DeploymentBrownie Smart Contract Interaction ExampleBrownie Event Listening ExampleBrownie Funding Contract ExampleBrownie Multi-Account Transaction ExampleBrownie Upgradeable Contract ExampleBrownie Testing Smart Contracts ExampleBrownie Interaction with ERC721 NFTBrownie Gas Estimation Example

Learn BROWNIE with Real Code Examples

Updated Nov 24, 2025

Explain

Brownie allows developers to write, test, and deploy smart contracts in Python using the Solidity language.

It integrates with Ethereum test networks, mainnet, and local blockchain simulations like Ganache.

Brownie supports automated testing, contract interaction, and scripts for deployment.

Core Features

Solidity smart contract compilation and deployment

Contract ABI and address management

Transaction simulation and gas estimation

Event and state monitoring for contracts

Testing framework with fixtures, assertions, and coverage reports

Basic Concepts Overview

Contract: Solidity code compiled and deployed to Ethereum

Account: wallet used to sign transactions

Transaction: interaction with a smart contract or Ether transfer

Event: blockchain signals emitted by contracts

Network: Ethereum chain (local, testnet, mainnet) where contracts are deployed

Project Structure

contracts/ - Solidity smart contract files

scripts/ - deployment and interaction scripts

tests/ - Python test files using pytest

build/ - compiled contracts and ABI files

reports/ - test coverage and gas usage reports

Building Workflow

Create a new Brownie project: `brownie init`

Write smart contracts in `contracts/` folder

Compile contracts: `brownie compile`

Write tests in `tests/` folder using pytest

Deploy contracts using scripts in `scripts/` folder

Difficulty Use Cases

Beginner: deploy simple contracts to local network

Intermediate: write automated tests with fixtures

Advanced: deploy to testnet/mainnet with scripts

Expert: interact with DeFi protocols programmatically

Enterprise: integrate blockchain contracts with production backends

Comparisons

Brownie vs Hardhat: Python vs JavaScript ecosystem

Brownie vs Truffle: Modern Python features vs legacy JS tooling

Brownie vs Foundry: Brownie uses Python, Foundry uses Rust/Forge

Brownie vs Remix IDE: IDE for rapid prototyping vs full Python workflow

Brownie vs Web3.py: Web3.py is library, Brownie is full framework

Versioning Timeline

2018 - Initial release by Matt Lockyer

2019 - Added advanced testing and deployment scripts

2020 - Improved network management and console features

2022 - Enhanced support for EVM-compatible chains

2025 - Latest version with improved Python 3.11 compatibility and DeFi/NFT features

Glossary

Brownie: Python-based Ethereum framework

Contract: Solidity code deployed on blockchain

Account: wallet for signing transactions

Transaction: interaction with blockchain

Event: emitted signal from contract

Installation Setup

Install Python 3.7+

Install Brownie via pip: `pip install eth-brownie`

Install Ganache for local Ethereum simulation (optional)

Install node providers like Infura or Alchemy for testnet/mainnet

Verify installation using `brownie --version` and sample project

Environment Setup

Install Python 3.7+

Install Brownie: `pip install eth-brownie`

Install Ganache for local blockchain

Setup Infura/Alchemy for testnet/mainnet

Verify with `brownie --version` and sample deployment

Config Files

brownie-config.yaml - network and project configuration

contracts/ - Solidity smart contracts

scripts/ - Python scripts for deployment and interaction

tests/ - pytest tests for contracts

build/ - compiled contracts and ABI files

Cli Commands

brownie init

brownie compile

brownie test

brownie run scripts/deploy.py

brownie console

Internationalization

Community contributions in multiple regions

Documentation in English, with community translations

Works with Ethereum networks globally

Compatible with international coding standards

Adopted in global DeFi and NFT projects

Accessibility

Cross-platform Python support

Open-source under MIT license

EVM-compatible networks support

Accessible to Python developers

Integrates with standard Python tools and packages

Ui Styling

Brownie console for interactive testing

Jupyter notebooks for deployment experimentation

Visualize contract events using Python plotting

Integrate dashboards for monitoring transactions

Export logs for reporting and auditing

State Management

Track deployed contract addresses

Manage account private keys securely

Log transaction history

Store ABI and build artifacts

Version control scripts and tests

Data Management

Maintain consistent input/output formats for contracts

Batch interactions where possible

Cache blockchain call results if needed

Track events and state changes for debugging

Document contract states and test results

Architecture

Python CLI for project scaffolding, testing, and deployment

Project structure with contracts, scripts, tests, and build directories

Integration with Ethereum JSON-RPC nodes

Plugin system for extensions and network configurations

Event-driven transaction monitoring and logging

Rendering Model

Python CLI for project management

Solidity compilation and deployment pipelines

Network abstraction for local/testnet/mainnet

Script-based automation for interactions

Event-driven monitoring for contract states

Architectural Patterns

Modular project structure (contracts, scripts, tests)

Contract compilation and ABI management

Network and account management layer

Testing layer integrated with pytest

Scripting layer for deployment and interaction automation

Real World Architectures

DeFi smart contract deployment pipelines

NFT minting and marketplace backends

Automated token distribution scripts

Ethereum-based dApp backends

Hybrid systems interacting with multiple EVM chains

Design Principles

Pythonic developer experience

Full-featured smart contract lifecycle management

Automated testing and reproducibility

Integration with multiple Ethereum networks

Focus on developer productivity and workflow efficiency

Scalability Guide

Use scripts for batch deployment

Automate tests for multiple contracts

Deploy to testnet/mainnet using CI/CD pipelines

Integrate with Web3.py for backend scalability

Monitor gas usage and optimize contracts

Migration Guide

Upgrade Brownie via pip

Check Python version compatibility

Update network configurations if needed

Test old scripts with new Brownie version

Ensure deployment reproducibility on different networks

Performance Notes

Local Ganache network is faster than testnet/mainnet

Parallel tests can reduce testing time

Contract deployment may be delayed due to network congestion

Transaction simulation can catch errors before broadcasting

Gas usage reports help optimize contract efficiency

Security Notes

Never expose private keys in scripts

Audit smart contracts before mainnet deployment

Validate external interactions with other contracts

Monitor events for unexpected state changes

Follow best practices for Ethereum development

Monitoring Analytics

Monitor transaction success/failures

Track gas usage across deployments

Log contract events for debugging

Audit deployed contract state

Visualize testing and deployment metrics

Code Quality

Follow Python coding standards

Document contract interactions

Maintain test coverage for contracts

Use version control for scripts and contracts

Validate deployments on local/test networks before mainnet

Practical Examples

Deploy a simple ERC20 token to local Ganache network

Write unit tests for contract functions using pytest

Interact with deployed contract via Brownie console

Estimate gas costs for different transactions

Deploy NFT contract to Ethereum testnet using scripts

Troubleshooting

Check network configurations (Infura/Alchemy endpoints)

Ensure correct Solidity compiler version

Validate account private keys and balances

Debug failing tests using `brownie console`

Monitor gas estimation errors for transactions

Testing Guide

Write unit tests for contract functions

Use fixtures to setup accounts and preconditions

Test edge cases and error handling

Monitor events emitted during transactions

Check gas usage and optimize for efficiency

Deployment Options

Deploy to local Ganache blockchain

Deploy to Ethereum testnets via Infura/Alchemy

Deploy to Ethereum mainnet with funded account

Use scripts to automate multi-contract deployment

Integrate deployment into CI/CD pipelines

Tools Ecosystem

Ganache for local Ethereum blockchain

Infura/Alchemy for node access

Solidity compiler (solc)

pytest for automated testing

Web3.py for advanced contract interaction

Integrations

Ethereum networks: Mainnet, Ropsten, Rinkeby, Goerli

DeFi protocols like Uniswap or Aave

NFT standards like ERC721/ERC1155

Python backends for automated interaction

Brownie console for manual contract management

Productivity Tips

Use Brownie console for quick contract tests

Write reusable deployment scripts

Leverage pytest fixtures for automated tests

Batch transactions where possible

Use Ganache for fast local testing before testnet deployment

Challenges

Debugging failed transactions

Handling asynchronous blockchain events

Gas optimization for complex contracts

Testing edge cases in contract logic

Interacting with external DeFi protocols securely

Learning Path

Learn Solidity basics for smart contracts

Understand Ethereum accounts, transactions, and gas

Practice Brownie CLI and project workflow

Write automated tests with pytest

Deploy and interact with contracts on testnet/mainnet

Skill Improvement Plan

Week 1: Brownie project setup and local Ganache testing

Week 2: Write and test simple ERC20/ERC721 contracts

Week 3: Learn deployment scripts and network configurations

Week 4: Integrate with Python backend scripts

Week 5: Deploy complex dApps and optimize contracts

Interview Questions

What is Brownie and what is it used for?

How do you deploy a smart contract using Brownie?

Explain testing smart contracts with Brownie and pytest

How do you interact with a deployed contract programmatically?

Compare Brownie with other Ethereum development frameworks

Cheat Sheet

brownie init = create project

brownie compile = compile contracts

brownie test = run automated tests

brownie run script.py = run deployment script

brownie console = interactive contract console

Books

Mastering Ethereum Smart Contracts with Brownie

Hands-On Blockchain Development with Python

Python for Ethereum: Brownie Projects

Smart Contract Testing and Deployment with Brownie

DeFi Development with Python and Brownie

Tutorials

Brownie official tutorials

Deploy ERC20/ERC721 with Brownie guides

Python scripts for contract interactions

Automated testing with pytest and Brownie

Ganache local blockchain examples

Official Docs

https://eth-brownie.readthedocs.io/

https://github.com/eth-brownie/brownie

Community Links

Brownie GitHub repository

Brownie Discord server

Ethereum StackExchange

Python blockchain developer forums

DeFi/NFT developer communities

Community Support

Brownie GitHub repository

Brownie Discord server

Ethereum StackExchange

Python blockchain developer forums

DeFi/NFT developer communities

Monetization

Develop DeFi applications

Launch NFT marketplaces

Provide smart contract development services

Offer consulting for blockchain deployment

Create Python automation scripts for Ethereum

Future Roadmap

Enhanced support for EVM-compatible blockchains

Improved testing and deployment automation

Better integration with DeFi/NFT protocols

Enhanced Python 3.11 and 3.12 support

Expanded community plugins and templates

When Not To Use

If team prefers JavaScript/TypeScript ecosystem

For non-Ethereum blockchains (e.g., Solana, Polkadot)

Rapid prototyping with Remix may be faster

When minimal dependency scripts are sufficient

Small scripts without full deployment/testing framework needs

Final Summary

Brownie is a Python framework for Ethereum smart contract development, testing, and deployment.

Supports Solidity contracts, automated testing with pytest, and network interaction.

Enables Python developers to build, test, and deploy decentralized applications efficiently.

Integrates with Ganache, Infura, and other Ethereum networks for full workflow.

Ideal for DeFi, NFT, and general Ethereum-based dApp development.

Faq

Is Brownie free?

Yes - open-source under MIT license.

Which blockchain does Brownie support?

Ethereum and Ethereum-compatible networks (EVM chains).

Can I deploy NFTs with Brownie?

Yes - ERC721/ERC1155 contracts are fully supported.

Does Brownie support automated testing?

Yes - integrated with Python pytest.

Can Brownie interact with DeFi protocols?

Yes - using scripts and Web3.py for advanced interactions.

Code Sample Descriptions

1

Brownie Minimal Smart Contract Deployment

# contracts/Counter.sol
pragma solidity ^0.8.0;

contract Counter {
    uint256 public count = 0;
    function increment() public { count += 1; }
}

# deploy.py
from brownie import Counter, accounts

def main():
    acct = accounts[0]
    counter = Counter.deploy({'from': acct})
    counter.increment({'from': acct})
    print('Counter value:', counter.count())

A minimal example showing how to deploy and interact with a simple Solidity smart contract using Brownie.

Let’s Try →
2

Brownie ERC20 Token Deployment

# contracts/MyToken.sol
pragma solidity ^0.8.0;

import '@openzeppelin/contracts/token/ERC20/ERC20.sol';

contract MyToken is ERC20 {
    constructor(uint256 initialSupply) ERC20('MyToken','MTK') {
        _mint(msg.sender, initialSupply);
    }
}

# deploy.py
from brownie import MyToken, accounts

def main():
    acct = accounts[0]
    token = MyToken.deploy(1000*10**18, {'from': acct})
    print('Token deployed at:', token.address)

Deploy a simple ERC20 token using Brownie.

Let’s Try →
3

Brownie Smart Contract Interaction Example

from brownie import Contract, accounts

def main():
    acct = accounts[0]
    counter = Contract('0xYourDeployedAddress')
    counter.increment({'from': acct})
    print('Counter value:', counter.count())

Interact with an already deployed contract using Brownie.

Let’s Try →
4

Brownie Event Listening Example

from brownie import Counter, accounts

def main():
    acct = accounts[0]
    counter = Counter[-1]  # Last deployed instance

    tx = counter.increment({'from': acct})
    for event in tx.events:
        print('Event emitted:', event)

Listen to events emitted by a smart contract using Brownie.

Let’s Try →
5

Brownie Funding Contract Example

# contracts/FundMe.sol
pragma solidity ^0.8.0;

contract FundMe {
    uint256 public balance = 0;
    function fund() public payable { balance += msg.value; }
}

# deploy.py
from brownie import FundMe, accounts

def main():
    acct = accounts[0]
    fund_me = FundMe.deploy({'from': acct})
    fund_me.fund({'from': acct, 'value': 1000000000000000000})  # 1 ETH
    print('Contract balance:', fund_me.balance())

Deploy and fund a smart contract with Ether using Brownie.

Let’s Try →
6

Brownie Multi-Account Transaction Example

from brownie import accounts

def main():
    sender = accounts[0]
    receiver = accounts[1]
    sender.transfer(receiver, '1 ether')
    print('Transferred 1 ETH from sender to receiver')

Send transactions between multiple accounts in Brownie.

Let’s Try →
7

Brownie Upgradeable Contract Example

# contracts/LogicV1.sol
pragma solidity ^0.8.0;

contract LogicV1 {
    uint public x;
    function setX(uint _x) public { x = _x; }
}

# deploy.py
from brownie import LogicV1, accounts

def main():
    acct = accounts[0]
    logic = LogicV1.deploy({'from': acct})
    logic.setX(42, {'from': acct})
    print('Value set in proxy logic:', logic.x())

Deploy an upgradeable proxy contract using Brownie.

Let’s Try →
8

Brownie Testing Smart Contracts Example

import pytest
from brownie import Counter, accounts

def test_increment():
    acct = accounts[0]
    counter = Counter.deploy({'from': acct})
    counter.increment({'from': acct})
    assert counter.count() == 1

Writing tests for a Solidity smart contract using Brownie.

Let’s Try →
9

Brownie Interaction with ERC721 NFT

# contracts/MyNFT.sol
pragma solidity ^0.8.0;

import '@openzeppelin/contracts/token/ERC721/ERC721.sol';

contract MyNFT is ERC721 {
    constructor() ERC721('MyNFT','MNFT') {}
    function mint(address to, uint256 tokenId) public { _mint(to, tokenId); }
}

# deploy.py
from brownie import MyNFT, accounts

def main():
    acct = accounts[0]
    nft = MyNFT.deploy({'from': acct})
    nft.mint(acct, 1, {'from': acct})
    print('Minted NFT ID 1 to account:', acct)

Deploy and interact with an ERC721 NFT smart contract using Brownie.

Let’s Try →
10

Brownie Gas Estimation Example

from brownie import Counter, accounts

def main():
    acct = accounts[0]
    counter = Counter.deploy({'from': acct})
    gas_estimate = counter.increment.estimate_gas({'from': acct})
    print('Estimated gas for increment():', gas_estimate)

Estimate gas usage for a smart contract function using Brownie.

Let’s Try →

Frequently Asked Questions about Brownie

What is Brownie?

Brownie is an open-source Python-based framework for Ethereum smart contract development, testing, and deployment. It integrates with Ethereum networks and provides a full-featured environment for building decentralized applications (dApps).

What are the primary use cases for Brownie?

Writing Ethereum smart contracts in Solidity. Testing contracts using Python-based frameworks. Deploying contracts to Ethereum testnets or mainnet. Automating interaction with deployed contracts. Integrating blockchain contracts with Python backend scripts

What are the strengths of Brownie?

Pythonic workflow makes blockchain development more accessible. Strong testing ecosystem with pytest. Easy deployment to multiple Ethereum networks. Good documentation and community support. Supports both local and remote Ethereum nodes

What are the limitations of Brownie?

Limited support for non-Ethereum blockchains. Primarily focused on Python developers. Requires familiarity with Solidity for contract writing. Complex DeFi protocols may require advanced configurations. Smaller ecosystem compared to JavaScript frameworks like Hardhat or Truffle

How can I practice Brownie typing speed?

CodeSpeedTest offers 10+ real Brownie code examples for typing practice. You can measure your WPM, track accuracy, and improve your coding speed with guided exercises.

Learn Other Programming Languages

CReactPythonC++RustTypeScriptKotlinPHPJavaC#RubyMqlCqlN1qlCypherGremlinPartiqlHaskellElixirFsharpView all languages →
CodeSpeedTest

Improve your coding speed, code accuracy, and programming syntax WPM with practice sessions across 500+ programming languages.

Quick Links

HomeAboutFeaturesGetting StartedLanguages

Legal & Support

Pro ⚡ PricingContactPrivacy PolicyTerms of Service

Connect

CodeSpeedTest on GitHubCodeSpeedTest on TwitterEmail CodeSpeedTest

© 2026 CodeSpeedTest. All rights reserved.