Skip to content

IpastorSan/beacon-proxy-smart-contracts

Repository files navigation

Simultaneaous Upgrades using Beacon Proxy Pattern

This is the companion repo for the article Is it possible to create upgradeable Minimal Proxy Clone contracts?

It shows how you can apply a Factory Pattern to create multiple copies of a given contract, and upgrade all of that copies simulteneously using the Beacon Proxy pattern.

There is also an implementation using UUPS to show how this pattern is not feasible for simultaneous upgrades because the implementation address is stored in the Proxy storage.

You can see a basic POC of how upgrades work with the Beacon Proxy in the test/BeaconproxyFactory.t.sol file.

Instructions.

Assuming you already have Rust and Foundry installed.

See the Book of Foundry to learn more.

forge install
  1. Compile the project
forge build
  1. Run test suite
forge test

Generate docs based on Natspec on files

forge doc

Check test coverage

forge coverage

Run Foundry formater

forge fmt

Get all functions selectors from a contract

forge inspect <YourContractName> methods

Run Locally

Open Anvil local node

anvil

Load .env variables in .env file->NO spaces between variable name and value, value with quotes. PRIVATE_KEY="blablabla"

source .env

Run on local node

forge script script/DeployBeacon.s.sol:Deploy --fork-url http://localhost:8545  --private-key $PRIVATE_KEY_ANVIL_0 --broadcast 

Deploy to Sepolia

Load .env variables in .env file->NO spaces between variable name and value, value with quotes. PRIVATE_KEY="blablabla"

source .env

Deploy to Sepolia and verify

forge script script/DeployBeacon.s.sol:Deploy --rpc-url $SEPOLIA_KEY  --private-key $PRIVATE_KEY --broadcast --verify --etherscan-api-key $ETHERSCAN_KEY -vvvv

foundry-template

foundry-template

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published