Skip to content

Commit 95c845c

Browse files
authored
Stable coin example (#113)
* Stablecoin tutorial
1 parent 3fa6a66 commit 95c845c

File tree

6 files changed

+1275
-0
lines changed

6 files changed

+1275
-0
lines changed

stablecoin-project/README.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Reserve-Backed Stablecoin Project
2+
3+
This repository contains a practical implementation of a reserve-backed stablecoin built with Foundry, designed to accompany a YouTube tutorial video.
4+
5+
🎬 **[Watch the full tutorial on YouTube](https://youtube.com/chainlink)**
6+
7+
## Project Overview
8+
9+
This stablecoin demonstrates key concepts of a reserve-backed cryptocurrency:
10+
11+
- **ERC20 Token**: Implements a standard ERC20 token with additional functionality
12+
- **Reserve Backing**: The stablecoin is fully backed by reserves verified through a DataFeed (mocked in this example)
13+
- **Minting Controls**: Only mint tokens when sufficient reserves exist
14+
- **Access Control**: Role-based permissions for administrative actions
15+
- **Safety Features**: Includes pause/unpause functionality and other safety measures
16+
17+
## Prerequisites
18+
19+
- [Foundry](https://getfoundry.sh/) installed on your machine
20+
- Basic understanding of Solidity and ERC20 tokens
21+
- Familiarity with smart contract development
22+
23+
## Project Structure
24+
25+
- `src/StableCoin.sol`: The main stablecoin implementation
26+
- `src/SmartDataMock.sol`: Mock price feed for testing
27+
- `test/StableCoin.t.sol`: Comprehensive test suite
28+
- `script/StableCoinInteraction.s.sol`: Deployment and interaction script
29+
30+
## Getting Started
31+
32+
### Installation
33+
34+
```shell
35+
# Clone the repository
36+
git clone https://github.com/yourusername/stablecoin-project.git
37+
cd stablecoin-project
38+
39+
# Install dependencies
40+
forge install
41+
```
42+
43+
### Build
44+
45+
```shell
46+
forge build
47+
```
48+
49+
### Test
50+
51+
```shell
52+
forge test
53+
```
54+
55+
### Run Scripts
56+
57+
```shell
58+
# In a seperate window
59+
anvil
60+
# Run the interaction script on local network
61+
forge script script/StableCoinInteraction.s.sol --rpc-url http://127.0.0.1:8545 --broadcast
62+
```
63+
64+
## Disclaimer
65+
66+
This code is for educational purposes only and has not been audited. Do not use in production without proper security reviews and audits.
67+
68+
## License
69+
70+
This project is licensed under the MIT License - see the LICENSE file for details.

stablecoin-project/foundry.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[profile.default]
2+
src = "src"
3+
out = "out"
4+
libs = ["lib"]
5+
remappings = ["@openzeppelin/=lib/openzeppelin-contracts/"]
6+
7+
# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options

0 commit comments

Comments
 (0)