CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-eth-brownie

A Python framework for Ethereum smart contract deployment, testing and interaction.

Pending
Overview
Eval results
Files

cli.mddocs/

Command Line Interface

Brownie provides a comprehensive command-line interface for project management, contract compilation, testing, deployment, and debugging. The CLI offers both powerful automation capabilities and interactive development tools.

Capabilities

Project Management Commands

Core commands for creating, initializing, and managing brownie projects with template support.

brownie init [project_name] [options]
    # Initialize new brownie project in current or specified directory
    # Options:
    #   --force     Overwrite existing files
    # Example: brownie init my-defi-project

brownie bake [template_name] [options]  
    # Create project from brownie-mix template
    # Options:
    #   --force     Overwrite existing files
    # Example: brownie bake token

brownie pm [command] [package] [options]
    # Package manager for brownie dependencies
    # Commands:
    #   install     Install package dependency
    #   uninstall   Remove package dependency
    #   list        List installed packages
    # Example: brownie pm install OpenZeppelin/openzeppelin-contracts@4.3.0

Compilation Commands

Contract compilation with support for multiple Solidity and Vyper versions plus optimization settings.

brownie compile [options]
    # Compile project contracts
    # Options:
    #   --all           Recompile all contracts
    #   --size          Display contract sizes
    #   --optimizer     Enable compiler optimizer
    #   --runs N        Optimizer runs setting
    #   --solc VERSION  Specific Solidity version
    #   --vyper VERSION Specific Vyper version
    # Example: brownie compile --optimizer --runs 200

Console and Interactive Commands

Interactive development environment with Python console and web-based GUI.

brownie console [options]
    # Launch interactive Python console with brownie environment
    # Options:
    #   --network NAME  Connect to specific network
    #   --tb            Show full tracebacks on error
    # Example: brownie console --network mainnet

brownie gui [options]
    # Launch web-based GUI for contract interaction
    # Options:
    #   --host HOST     GUI host address (default: localhost)
    #   --port PORT     GUI port number (default: random)
    #   --no-browser    Don't auto-open browser
    # Example: brownie gui --host 0.0.0.0 --port 8080

Testing Commands

Comprehensive testing framework with coverage analysis and property-based testing.

brownie test [path] [options]
    # Run project test suite with pytest integration
    # Options:
    #   --network NAME      Test network (default: development)
    #   --coverage          Generate coverage report
    #   --gas               Show gas usage analysis
    #   --update-snapshots  Update test snapshots
    #   --stateful          Run stateful tests
    #   --interactive       Interactive debugger on failure
    #   -v, --verbose       Verbose output
    #   -s                  Show print statements
    #   -x                  Stop on first failure
    # Example: brownie test tests/test_token.py --coverage --gas

Script Execution Commands

Execute project automation scripts with argument passing and method selection.

brownie run [script] [method] [args] [options]
    # Execute project script with optional method and arguments
    # Options:
    #   --network NAME  Target network for execution
    #   --interactive   Interactive debugger on error
    # Examples:
    #   brownie run scripts/deploy.py --network mainnet
    #   brownie run scripts/manage.py transfer 1000 --network development

Account Management Commands

Local account management with import, export, and password protection.

brownie accounts [command] [options]
    # Manage local accounts
    # Commands:
    #   list                List all accounts
    #   new NAME            Generate new account
    #   import NAME         Import account from private key
    #   export NAME         Export account private key
    #   delete NAME         Remove account
    #   unlock NAME         Unlock account for session
    #   password NAME       Change account password
    # Options:
    #   --password PASS     Account password
    #   --force             Skip confirmation prompts  
    # Examples:
    #   brownie accounts new deployer
    #   brownie accounts import mainnet-deployer

Network Management Commands

Network configuration and connection management for different blockchain environments.

brownie networks [command] [options]
    # Manage network configurations
    # Commands:
    #   list                List available networks
    #   add [environment] [id] [host] [options]  # Add new network
    #   modify [id] [options]                    # Modify network settings
    #   delete [id]                              # Remove network
    #   set-default [id]                         # Set default network
    # Network options:
    #   --host URL          RPC endpoint URL
    #   --chainid ID        Chain ID number
    #   --gas-limit N       Default gas limit
    #   --gas-price N       Default gas price
    # Examples:
    #   brownie networks list
    #   brownie networks add Ethereum mainnet-fork http://localhost:8545 --chainid 1

Usage Examples

Project Setup Workflow

# Create new project from template
brownie bake token my-token-project
cd my-token-project

# Install dependencies
brownie pm install OpenZeppelin/openzeppelin-contracts@4.3.0

# Compile contracts
brownie compile --optimizer

# Run tests with coverage
brownie test --coverage --gas

# Deploy to testnet
brownie run scripts/deploy.py --network goerli

Development Workflow

# Start interactive development
brownie console --network development

# In another terminal, run tests continuously
brownie test --watch

# Deploy and test interactively
brownie gui --network development

Account Management Workflow

# Create deployment account
brownie accounts new mainnet-deployer

# Import existing account
brownie accounts import backup-account

# List all accounts
brownie accounts list

# Use specific account in script
brownie run scripts/deploy.py --network mainnet --account mainnet-deployer

Network Configuration Examples

# Add local development network
brownie networks add Development local http://localhost:8545 --chainid 1337

# Add mainnet fork for testing  
brownie networks add Ethereum mainnet-fork http://localhost:8545 --chainid 1 --gas-price 20000000000

# Add custom testnet
brownie networks add Ethereum custom-testnet https://rpc.custom-testnet.io --chainid 12345

Testing and Debugging

# Run specific test file with verbose output
brownie test tests/test_token.py -v -s

# Run single test function
brownie test tests/test_token.py::test_transfer -s

# Generate coverage report and open in browser
brownie test --coverage
brownie gui --coverage

# Run tests with interactive debugger
brownie test --interactive

# Run stateful property-based tests
brownie test --stateful

Advanced Usage

# Compile specific contract
brownie compile contracts/Token.sol

# Force recompilation of all contracts
brownie compile --all --force

# Run script with specific method
brownie run scripts/manage.py mint_tokens 1000000

# Execute with gas profiling
brownie test --gas --network mainnet-fork

# Interactive console with custom network
brownie console --network http://localhost:7545

Global Options

Options available for all brownie commands:

# Global flags (available for all commands):
--help, -h          Show command help
--verbose, -v       Verbose output  
--tb                Show full Python tracebacks
--quiet, -q         Suppress console output
--color / --no-color Control colored output

Environment Variables

Environment variables that affect brownie CLI behavior:

BROWNIE_CONFIG_FILE     # Custom config file path
BROWNIE_DATA_FOLDER     # Custom data directory
BROWNIE_LIB            # Library installation mode
WEB3_INFURA_PROJECT_ID # Infura project ID
ETHERSCAN_TOKEN        # Etherscan API token

Integration with Other Tools

CI/CD Integration

# Example GitHub Actions workflow
- name: Run Brownie Tests
  run: |
    brownie test --network development --coverage
    brownie gui --coverage --no-browser

Docker Integration

# Run brownie in Docker container
docker run -v $(pwd):/project -w /project eth-brownie/brownie:latest test

# Interactive console in Docker
docker run -it -v $(pwd):/project -w /project eth-brownie/brownie:latest console

Type Definitions

# Command return codes
0    # Success
1    # General error
2    # Configuration error  
3    # Network connection error
4    # Compilation error
5    # Test failure

Install with Tessl CLI

npx tessl i tessl/pypi-eth-brownie@1.21.1

docs

accounts.md

cli.md

contracts.md

conversion-testing.md

index.md

network.md

project.md

tile.json