Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
179 changes: 85 additions & 94 deletions week-06/dev/README.md
Original file line number Diff line number Diff line change
@@ -1,120 +1,111 @@
# Week 6: 최종 프로젝트 - 나만의 dApp
# MilestoneFunding - 마일스톤 크라우드펀딩 dApp

6주간 배운 내용을 총동원하여 나만의 dApp을 만들어보세요!
> 후원자 투표로 자금을 단계별 릴리즈하는 크라우드펀딩 플랫폼

## 개요
## 프로젝트 소개

**자유 주제**로 dApp을 개발합니다. 컨트랙트부터 프론트엔드까지 직접 구현하고, Sepolia 테스트넷에 배포합니다.
기존 크라우드펀딩의 가장 큰 문제는 "돈 받고 안 만듦"입니다. MilestoneFunding은 펀딩 금액을 한 번에 주지 않고, **마일스톤마다 후원자 투표를 통과해야 다음 자금이 풀리는** 구조로 이 문제를 해결합니다.

**목표:**
- 스마트 컨트랙트 설계 및 구현
- Foundry로 테스트 작성
- wagmi + RainbowKit으로 프론트엔드 연동
- Sepolia 배포 및 검증
### 핵심 플로우
1. 크리에이터가 프로젝트 생성 (목표 금액 + 마일스톤 설정)
2. 후원자들이 ETH로 후원 (크리에이터는 자기 프로젝트에 후원 불가)
3. 크리에이터가 마일스톤 완료 신청
4. 후원자들이 찬성/반대 투표 (기여금 비례 가중치)
5. 과반 찬성 → 해당 비율 자금 릴리즈 / 과반 반대 → 남은 자금 환불

## 체크리스트
## 기술 스택

**반드시 [CHECKLIST.md](./CHECKLIST.md)의 모든 필수 항목을 충족해야 합니다.**
| 구분 | 기술 |
|------|------|
| Smart Contract | Solidity 0.8.26, Foundry |
| Frontend | Next.js 16, TypeScript, Tailwind CSS |
| Web3 | wagmi v2, viem, RainbowKit |
| Network | Sepolia Testnet |

주요 항목:
- Smart Contract: Solidity 0.8.26+, 상태 변수, public 함수, 이벤트, 테스트 5개+
- Frontend: Next.js, wagmi, RainbowKit, 컨트랙트 연동, 에러 처리
- Deployment: Sepolia 배포, 컨트랙트 주소 README 기재
## 배포 정보

## 아이디어 예시
| 항목 | 값 |
|------|-----|
| Network | Sepolia |
| Factory | `0x63c5ED29c8BF61277542acB5f79672505382062d` |
| Etherscan | https://sepolia.etherscan.io/address/0x63c5ED29c8BF61277542acB5f79672505382062d |

아이디어가 떠오르지 않는다면 아래 예시를 참고하세요:
## 설치 및 실행

### 1. 간단한 투표 시스템
- 후보자 등록
- 투표하기 (1인 1표)
- 결과 조회
### 컨트랙트 테스트

```solidity
// 핵심 기능
mapping(address => bool) public hasVoted;
mapping(uint256 => uint256) public votes;
function vote(uint256 candidateId) external { ... }
```bash
forge test --match-path week-06/dev/test/MilestoneFunding.t.sol -vv
```

### 2. 기부/펀딩 컨트랙트
- 목표 금액 설정
- ETH 기부하기
- 목표 달성 시 수령
### 프론트엔드 실행

```solidity
// 핵심 기능
uint256 public goal;
function donate() external payable { ... }
function withdraw() external { ... }
```bash
cd week-06/dev/frontend
npm install
npm run dev
```

### 3. 메시지 저장소
- 메시지 작성 (on-chain)
- 메시지 목록 조회
- 작성자별 필터링
`http://localhost:3000` 에서 확인

```solidity
// 핵심 기능
struct Message { address author; string content; uint256 timestamp; }
Message[] public messages;
function post(string calldata content) external { ... }
```

### 4. 간단한 NFT 민팅
- ERC721 기본 구현
- 민팅 기능
- 소유자 확인
## 프로젝트 구조

```solidity
// 핵심 기능 (OpenZeppelin 사용 가능)
function mint() external { ... }
function tokenURI(uint256 tokenId) public view returns (string memory) { ... }
```

### 5. 에스크로 컨트랙트
- 구매자가 ETH 예치
- 판매자가 배송 후 확인
- 구매자 확인 후 ETH 지급

```solidity
// 핵심 기능
enum State { Created, Funded, Shipped, Completed }
State public state;
function fund() external payable { ... }
function confirmReceived() external { ... }
week-06/dev/
├── src/
│ ├── MilestoneFunding.sol # 개별 프로젝트 컨트랙트
│ └── MilestoneFundingFactory.sol # 프로젝트 생성 팩토리
├── test/
│ └── MilestoneFunding.t.sol # Foundry 테스트 (9개)
├── script/
│ └── Deploy.s.sol # 배포 스크립트
├── frontend/
│ ├── app/
│ │ ├── page.tsx # 메인 (프로젝트 목록)
│ │ ├── create/page.tsx # 프로젝트 생성
│ │ └── project/page.tsx # 프로젝트 상세
│ ├── components/
│ │ ├── ProjectCard.tsx # 프로젝트 카드
│ │ ├── FundProject.tsx # 후원 폼
│ │ ├── ActionPanel.tsx # 투표/확정/환불
│ │ ├── Countdown.tsx # 마감 카운트다운
│ │ └── MyContribution.tsx # 내 기여 정보
│ └── config/
│ ├── wagmi.ts # wagmi + Sepolia 설정
│ └── contract.ts # ABI + 컨트랙트 주소
└── README.md
```

## 참고 자료

- [최종 프로젝트 상세 가이드](/eth-materials/week-06/dev/final-project.md)
- [wagmi 가이드](/eth-materials/week-04/dev/wagmi-basics.md)
- [RainbowKit 가이드](/eth-materials/week-05/dev/rainbowkit-guide.md)
- [프론트엔드 템플릿](/eth-materials/resources/frontend-template/)

## 제출 방법
## 컨트랙트 주요 함수

1. `week-06/dev/` 폴더에 프로젝트 코드 작성
2. README.md에 프로젝트 설명, 기술 스택, 컨트랙트 주소 기재
3. [CHECKLIST.md](./CHECKLIST.md)를 PR 본문에 복사하고 완료 항목 체크
4. PR 생성
| 함수 | 설명 | 호출자 |
|------|------|--------|
| `fund()` | ETH 후원 | 후원자 (크리에이터 제외) |
| `submitMilestone()` | 마일스톤 완료 제출 | 크리에이터 |
| `vote(bool)` | 찬성/반대 투표 | 후원자 |
| `finalizeMilestone()` | 투표 결과 확정 | 누구나 |
| `claimRefund()` | 환불 청구 | 후원자 |

## 제출 마감
## 보안

**마감일: [TBD]**
- **CEI 패턴**: 모든 ETH 전송 함수에 Checks-Effects-Interactions 적용
- **재진입 방지**: 상태 변경 후 외부 호출 (hasRefunded 플래그)
- **가중 투표**: 기여금 비례 투표로 시빌 공격 방지
- **자기 후원 방지**: 크리에이터가 자기 프로젝트에 후원 불가
- **비례 환불**: 이미 릴리즈된 자금을 제외한 잔여 금액 비례 분배

마감 후에는 PR을 생성할 수 없습니다. 여유를 두고 미리 제출하세요!
## 테스트 결과

## 발표

최종 발표에서 프로젝트를 시연합니다:
- 5분 발표 + 2분 Q&A
- 데모 시연 필수
- 코드 설명 선택

---

> **응원의 말씀:**
> 6주간 열심히 달려왔습니다. 마지막 프로젝트는 여러분이 배운 모든 것을 보여줄 기회입니다.
> 완벽하지 않아도 괜찮습니다. 도전하고, 실패하고, 배우는 과정 자체가 가치 있습니다.
> 화이팅!
```
9 tests passed (0 failed)

- test_Fund_UpdatesContribution
- test_Fund_TransitionsToActiveWhenGoalMet
- test_Fund_EmitsEvent
- test_SubmitMilestone_SetsVotingState
- test_Vote_AndFinalize_ApproveMilestone
- test_Vote_AndFinalize_RejectMilestone
- test_ClaimRefund_AfterMilestoneRejection
- test_ClaimRefund_AfterDeadlineExpiry
- test_RevertWhen_ReentrancyOnClaimRefund
```
41 changes: 41 additions & 0 deletions week-06/dev/frontend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/versions

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# env files (can opt-in for committing if needed)
.env*

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
5 changes: 5 additions & 0 deletions week-06/dev/frontend/AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<!-- BEGIN:nextjs-agent-rules -->
# This is NOT the Next.js you know

This version has breaking changes — APIs, conventions, and file structure may all differ from your training data. Read the relevant guide in `node_modules/next/dist/docs/` before writing any code. Heed deprecation notices.
<!-- END:nextjs-agent-rules -->
1 change: 1 addition & 0 deletions week-06/dev/frontend/CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@AGENTS.md
36 changes: 36 additions & 0 deletions week-06/dev/frontend/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).

## Getting Started

First, run the development server:

```bash
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.

You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.

This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.

## Learn More

To learn more about Next.js, take a look at the following resources:

- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.

You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!

## Deploy on Vercel

The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.

Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.
Loading