Blockchain Ethereum Developer Brownie Guide
1. Ethereum Brownie
Brownie
Brownie is a Python-based development and testing framework for smart contracts targeting the Ethereum Virtual Machine.
Features
- Full support for Solidity and Vyper
- Contract testing via pytest, including trace-based coverage evaluation
- Property-based and stateful testing via hypothesis
- Powerful debugging tools, including python-style tracebacks and custom error strings
- Built-in console for quick project interaction
- Support for ethPM packages
Install
python3 -m pip install --user pipx
python3 -m pipx ensurepathpipx install eth-brownie$ brownie
Brownie - Python development framework for Ethereum
Usage: brownie <command> [<args>...] [options <args>]
brownie networks list
Ethereum
├─Mainnet (Infura): mainnet
├─Ropsten (Infura): ropsten
├─Rinkeby (Infura): rinkeby
├─Goerli (Infura): goerli
└─Kovan (Infura): kovan
Ethereum Classic
├─Mainnet: etc
└─Kotti: kotti
Arbitrum
└─Mainnet: arbitrum-main
Avalanche
├─Mainnet: avax-main
└─Testnet: avax-test
Binance Smart Chain
├─Testnet: bsc-test
└─Mainnet: bsc-main
Fantom Opera
├─Testnet: ftm-test
└─Mainnet: ftm-main
Harmony
└─Mainnet (Shard 0): harmony-main
Polygon
├─Mainnet (Infura): polygon-main
└─Mumbai Testnet (Infura): polygon-test
XDai
├─Mainnet: xdai-main
└─Testnet: xdai-test
Development
├─Ganache-CLI: development
├─Geth Dev: geth-dev
├─Hardhat: hardhat
├─Hardhat (Mainnet Fork): hardhat-fork
├─Ganache-CLI (Mainnet Fork): mainnet-fork
├─Ganache-CLI (BSC-Mainnet Fork): bsc-main-fork
├─Ganache-CLI (FTM-Mainnet Fork): ftm-main-fork
├─Ganache-CLI (Polygon-Mainnet Fork): polygon-main-fork
├─Ganache-CLI (XDai-Mainnet Fork): xdai-main-fork
└─Ganache-CLI (Avax-Mainnet Fork): avax-main-fork
❯ brownie pm install OpenZeppelin/openzeppelin-contracts@4.0.0
Brownie v1.17.2 — Python development framework for Ethereum
- 47MiB [00:02, 552kiB/s]
Downloading from https://solc-bin.ethereum.org/linux-amd64/solc-linux-amd64-v0.8.10+commit.fc410830
TokenERC20.sol
- brownie init
- pip install eth-brownie
- https://eips.ethereum.org/EIPS/eip-20
- Create /contract/TokenERC20.sol
- brownie compile
- ganache-cli
- Create /scripts/1_deploy_token.py
- brownie run scripts/1_deploy_token.py
EasyToken.sol
Open Zeppeling Git Hub ERC20
// contracts/GLDToken.sol // SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract GLDToken is ERC20 {
constructor(uint256 initialSupply) public ERC20("Gold", "GLD") { _mint(msg.sender, initialSupply); } }
- brownie compile
- brownie-config.yaml
- brownie compile
- brownie run scripts/2_deploy_ez_token.py
- brownie run scripts/1_deploy_token.py — network rinkeby