Skip to content

Rahber-1/DeFi-Stablecoin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

71 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Decentralized Stablecoin Deployment with Foundry

Overview

This project implements a Decentralized Stablecoin (DSC) system using Solidity and Foundry. It includes smart contracts for the stablecoin itself, an engine to manage its issuance and collateralization, and deployment scripts for different networks.

Project Structure

├── src/
│   ├── DecentralizedStableCoin.sol  # Stablecoin contract
│   ├── DSCEngine.sol                # Engine managing collateral and issuance
│
├── test/
│   ├── mocks/
│   │   ├── MockV3Aggregator.sol     # Mock price feed for local testing
│
├── script/
│   ├── DeployDSC.s.sol              # Deployment script
│   ├── HelperConfig.s.sol           # Configuration for different networks
│
├── foundry.toml                     # Foundry configuration file
└── README.md                         # Project documentation

Smart Contracts

1. DecentralizedStableCoin.sol

  • Implements an ERC20-based stablecoin.
  • Ownership is transferred to DSCEngine for decentralized control.

2. DSCEngine.sol

  • Manages the issuance and redemption of the stablecoin.
  • Ensures stability through over-collateralization using ETH and BTC.

Deployment Scripts

DeployDSC.s.sol

  • Fetches network-specific configurations from HelperConfig.
  • Deploys DecentralizedStableCoin and DSCEngine.
  • Transfers ownership of DSC to DSCEngine.

HelperConfig.s.sol

  • Defines configurations for Sepolia and Anvil networks.
  • Uses real price feeds on Sepolia and mocks for local testing.
  • Reads environment variables for private keys when deploying to Sepolia.

Setup & Deployment

Prerequisites

Installation

git clone  https://github.com/Rahber-1/DeFi-Stablecoin.git
cd DeFi-Stablecoin
forge install  # Install dependencies

Running Tests

forge test

Local Deployment (Anvil)

anvil &  # Start Anvil (local Ethereum testnet)
forge script script/DeployDSC.s.sol:DeployDSC --fork-url http://127.0.0.1:8545 --broadcast

Testnet Deployment (Sepolia)

  1. Set your .env file:
    PRIVATE_KEY=<your_private_key>
  2. Deploy:
    forge script script/DeployDSC.s.sol:DeployDSC --rpc-url <sepolia_rpc_url> --broadcast

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