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.
Assuming you already have Rust and Foundry installed.
See the Book of Foundry to learn more.
forge install
- Compile the project
forge build
- Run test suite
forge test
forge doc
forge coverage
forge fmt
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