Skip to content

Rahber-1/Upgradeable_Contracts_Project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🛠️ Upgradable Smart Contract with ERC1967 Proxy

📌 Overview

This project demonstrates how to deploy and upgrade a Solidity smart contract using the ERC1967 Proxy pattern. It includes:

  • BasicContractV1: Initial contract version
  • BasicContractV2: Upgraded contract version
  • ERC1967 Proxy: Used for contract upgradability
  • Foundry Tests: Ensures deployment and upgrade functionality

📂 Project Structure

├── src/
│ ├── BasicContractV1.sol
│ ├── BasicContractV2.sol

├── script/
│ ├── DeployBasicContractV1.s.sol
│ ├── DeployUpgrade.s.sol

├── test/
│ ├── DeployAndUpgradeTest.t.sol

├── foundry.toml
├── README.md

🚀 Installation & Setup

1️⃣ Clone the Repository

git clone https://github.com/Rahber-1/Upgradeable_Contracts_Project.git cd Ugradeable_Contracts_Project

2️⃣ Install Foundry

curl -L https://foundry.paradigm.xyz | bash
foundryup

3️⃣ Install Dependencies

forge install

4️⃣ Compile the Contracts

forge build

5️⃣ Run Tests

forge test -vv

📜 Smart Contract Explanation

1️⃣ BasicContractV1 (Initial Contract)

  • Implements the core logic
  • Uses OpenZeppelin’s OwnableUpgradeable
  • Function: initialize() for initializing state

2️⃣ BasicContractV2 (Upgraded Version)

  • Extends BasicContractV1
  • Introduces additional functionality

3️⃣ ERC1967 Proxy

  • Used to delegate calls to implementation contracts
  • Enables upgradability without changing the contract address

📜 Deployment & Upgrade

Deploy V1 Contract

forge script script/DeployBasicContractV1.s.sol --rpc-url YOUR_RPC_URL --broadcast

Upgrade to V2

forge script script/DeployUpgrade.s.sol --rpc-url YOUR_RPC_URL --broadcast

🧪 Running Tests

Test Coverage Includes:
✔️ Deployment of V1 contract
✔️ Ensures correct contract version
✔️ Upgrade to V2 and validation

Run all tests:
forge test -vv

📜 License

This project is MIT licensed.

Upgradeable_Contracts_Project

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published