This is a project built with Foundry. This project is meant to be a stablecoin where users can deposit WETH and WBTC in exchange for a token that will be pegged to the USD. The main Contract is called DSCEngine.sol and it severves as the execution protocol of this project. Included is the DecentralizedStableCoin, which is a burnable ERC20 Token.
This system is designed to be as minimal as possible and have the Token maintain a peg of 1 Token == 1 US$
This stablecoin has the properties:
- Exogenous collateral
- US Dollar pegging
- Stabilization Algorithm
This system should always be over collateralized. At no point should the value of all collateral <= US$ backed value of all DSC
- Relative Stability, pegging to USD
- Chainlink Price Feed
- Function to exchange ETH & BTC -> USD
- Stability Mechanism: Algorithmic
- Users can only mint with enough collateral (coded)
- Collateral: Exogenous (Crypto)
- wETH
- wBTC
- Solidity (Programming Language)
- Foundry (Smart Contract Development Tool)
- Chainlink-Pricefeeds (Price Oracle)
- Openzeppelin (Smart Contract Library)
$ forge build
$ forge test
Run local tests on Sepolia by forking
$ forge test --fork-url $SEPOLIA_RPC_URL
$ forge fmt
$ forge snapshot
Anvil is Foundrys local dev blockchain
$ anvil
- Setup environment variables You'll want to set your SEPOLIA_RPC_URL and PRIVATE_KEY as environment variables. You can add them to a .env file, similar to what you see in .env.example.
- PRIVATE_KEY: The private key of your account (like from metamask). NOTE: FOR DEVELOPMENT, PLEASE USE A KEY THAT DOESN'T HAVE ANY REAL FUNDS ASSOCIATED WITH IT.You can learn how to export it here.
- SEPOLIA_RPC_URL: This is url of the sepolia testnet node you're working with. You can get setup with one for free from Alchemy. Optionally, add your ETHERSCAN_API_KEY if you want to verify your contract on Etherscan.
-
Get testnet ETH Head over to faucets.chain.link and get some testnet ETH. You should see the ETH show up in your metamask.
-
Deploy
$ forge script script/DeployDSC.s.sol --rpc-url $SEPOLIA_RPC_URL --private-key $PRIVATE_KEY
$ cast <subcommand>
If you found this useful, feel free to follow me or contact me!