Skip to content

brownie-mix/upgrades-mix

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Upgrades Mix


OpenZeppelin Proxy logo


This repo shows users how to use the Transparent Proxy pattern for upgrading smart contracts. It uses most of the code from openzeppelin's repo, and adds brownie scripts on top.

Prerequisites

Please install or have installed the following:

Installation

  1. Install Brownie, if you haven't already. Here is a simple way to install brownie.
pip install eth-brownie

Or, if that doesn't work, via pipx

pip install --user pipx
pipx ensurepath
# restart your terminal
pipx install eth-brownie
  1. For local testing install ganache-cli Skip if you only want to use testnets
npm install -g ganache-cli

or

yarn add global ganache-cli
  1. Download the mix and install dependancies.
brownie bake upgrades-mix
cd upgrades

Or, you can clone from source:

git clone https://github.com/PatrickAlphaC/upgrades-mix
cd upgrades-mix

Environment Variables

If you want to be able to deploy to testnets or work with mainnet-fork, do the following.

  1. Set your WEB3_INFURA_PROJECT_ID, and PRIVATE_KEY environment variables.

You can get a WEB3_INFURA_PROJECT_ID by getting a free trial of Infura. At the moment, it does need to be infura with brownie. If you get lost, you can follow this guide to getting a project key. You can find your PRIVATE_KEY from your ethereum wallet like metamask.

You'll also need testnet Sepolia ETH and LINK. You can get LINK and ETH into your wallet by using the sepolia faucets located here and the link token faucet here. If you're new to this, watch this video.

You can add your environment variables to the .env file:

export WEB3_INFURA_PROJECT_ID=<PROJECT_ID>
export PRIVATE_KEY=<PRIVATE_KEY>

AND THEN RUN source .env TO ACTIVATE THE ENV VARIABLES (You'll need to do this everytime you open a new terminal, or learn how to set them easier).

DO NOT SEND YOUR PRIVATE KEY WITH FUNDS IN IT ONTO GITHUB

Otherwise, you can build, test, and deploy on your local environment.

Useage

Scripts

brownie run scripts/01_deploy_box.py
brownie run scripts/02_upgrade_box.py

This will:

  1. Deploy a Box implementation contract
  2. Deploy a ProxyAdmin contract to be the admin of the proxy
  3. Deploy a TransparentUpgradeableProxy to be the proxy for the implementations

Then, the upgrade script will:

  1. Deploy a new Box implementation BoxV2
  2. Upgrade the proxy to point to the new implementation contract, essentially upgrading your infrastructure.
  3. Then it will call a function only BoxV2 can call

Test

brownie test

Linting

pip install black
pip install autoflake
autoflake --in-place --remove-unused-variables -r .
black .

Resources

To get started with Brownie:

Any questions? Join our Discord

License

This project is licensed under the MIT license.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Solidity 55.0%
  • Python 43.5%
  • Shell 1.5%