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.
├── 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
- Implements an ERC20-based stablecoin.
- Ownership is transferred to
DSCEnginefor decentralized control.
- Manages the issuance and redemption of the stablecoin.
- Ensures stability through over-collateralization using ETH and BTC.
- Fetches network-specific configurations from
HelperConfig. - Deploys
DecentralizedStableCoinandDSCEngine. - Transfers ownership of DSC to
DSCEngine.
- 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.
git clone https://github.com/Rahber-1/DeFi-Stablecoin.git
cd DeFi-Stablecoin
forge install # Install dependenciesforge testanvil & # Start Anvil (local Ethereum testnet)
forge script script/DeployDSC.s.sol:DeployDSC --fork-url http://127.0.0.1:8545 --broadcast- Set your
.envfile:PRIVATE_KEY=<your_private_key>
- Deploy:
forge script script/DeployDSC.s.sol:DeployDSC --rpc-url <sepolia_rpc_url> --broadcast
This project is licensed under the MIT License.