Skip to main content

Command Palette

Search for a command to run...

Blockchain Ethereum Developer Brownie Guide

Published
3 min read
Blockchain Ethereum Developer Brownie Guide

1. Ethereum Brownie

[ETH Brownie Explained - What is Brownie? " Moralis - The Ultimate Web3 Development Platform
Do you want to know what Brownie is in the context of Ethereum, and how to use it with Moralis? If so, read on!moralis.io](https://moralis.io/eth-brownie-explained-what-is-brownie/ "https://moralis.io/eth-brownie-explained-what-is-brownie/")

Brownie

Brownie is a Python-based development and testing framework for smart contracts targeting the Ethereum Virtual Machine.

[GitHub - eth-brownie/brownie: A Python-based development and testing framework for smart contracts…
Brownie is a Python-based development and testing framework for smart contracts targeting the Ethereum Virtual Machine…github.com](https://github.com/eth-brownie/brownie "https://github.com/eth-brownie/brownie")

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

[Installing Brownie - Brownie 1.17.2 documentation
The recommended way to install Brownie is via pipx. Pipx is a tool to help you install and run end-user applications…eth-brownie.readthedocs.io](https://eth-brownie.readthedocs.io/en/stable/install.html "https://eth-brownie.readthedocs.io/en/stable/install.html")

python3 -m pip install --user pipx
python3 -m pipx ensurepath

pipx install eth-brownie

$ brownie
Brownie - Python development framework for Ethereum

Usage: brownie [...] [options ]

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

  1. 47MiB [00:02, 552kiB/s]
    Downloading from https://solc-bin.ethereum.org/linux-amd64/solc-linux-amd64-v0.8.10+commit.fc410830

TokenERC20.sol

  1. brownie init
  2. pip install eth-brownie
  3. https://eips.ethereum.org/EIPS/eip-20
  4. Create /contract/TokenERC20.sol
  5. brownie compile
  6. ganache-cli
  7. Create /scripts/1_deploy_token.py
  8. brownie run scripts/1_deploy_token.py

EasyToken.sol

Open Zeppeling Git Hub ERC20

[ERC20 - OpenZeppelin Docs
Often, you'll want to be able to divide your tokens into arbitrary amounts: say, if you own 5 GLD, you may want to send…docs.openzeppelin.com](https://docs.openzeppelin.com/contracts/3.x/erc20 "https://docs.openzeppelin.com/contracts/3.x/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); } }

  1. brownie compile
  2. brownie-config.yaml
  3. brownie compile
  4. brownie run scripts/2_deploy_ez_token.py
  5. brownie run scripts/1_deploy_token.py — network rinkeby

ERC20 Standard

— -

React Wallet App

[React App
Edit descriptionegf9m.csb.app](https://egf9m.csb.app/ "https://egf9m.csb.app/")

Github Code

[GitHub - abdulmalik97/moralis-react-authentication
This project was bootstrapped with Create React App. In the project directory, you can run: Runs the app in the…github.com](https://github.com/abdulmalik97/moralis-react-authentication "https://github.com/abdulmalik97/moralis-react-authentication")