A PDA-based, milestone-driven escrow smart contract for Web3 freelance marketplaces, built on Solana using Anchor.
This protocol enables trustless job creation, milestone funding in USDC, automatic payouts with platform fees, and refunds on timeout - without centralized custody.
- PDA-based Escrow
- USDC (SPL Token v1) Milestone Funding
- Milestone Approval with Platform Fee
- Timeout Refunds
- Full End-to-End Anchor Tests
- Rust Code Coverage (llvm-cov)
- Security Linting (cargo audit)
- CI-ready GitHub Actions
| Concept | Description |
|---|---|
| Job PDA | Represents a freelance job |
| Milestone PDA | Escrows funds per milestone |
| Escrow ATA | Token account owned by Milestone PDA |
| Employer | Funds and approves milestones |
| Freelancer | Receives milestone payout |
| Platform | Receives protocol fee |
-
Create Job
Employer creates a Job PDA bound to their wallet. -
Fund Milestone
Employer deposits USDC into an Escrow ATA owned by a Milestone PDA. -
Approve Milestone
Funds are released to the Freelancer with a protocol fee deducted. -
Cancel Milestone (Timeout)
If the deadline passes without approval, the Employer can reclaim funds.
- Solana
- Anchor v0.32
- Rust
- SPL Token v1 (USDC)
- TypeScript (Mocha + Chai)
rm -rf test-ledger
anchor testPDA-based programs must reset the local validator between runs.
This project uses cargo llvm-cov to measure Rust smart contract coverage.
rustup component add llvm-tools-preview
cargo install cargo-llvm-cov
anchor test
cargo llvm-cov report --htmlOutput:
target/llvm-cov/html/index.html
Target coverage: ≥ 80% (audit-grade)
We use cargo audit to scan Rust dependencies against RustSec advisories.
cargo install cargo-audit
cargo audit --severity high- CI fails on HIGH / CRITICAL vulnerabilities
- Allowlisting supported via
.cargo/audit.toml
GitHub Actions automatically run:
anchor buildanchor testcargo llvm-covcargo audit
Local validator state is reset on every CI run to avoid PDA reuse.
- No custodial wallets
- Funds always held by PDA-owned escrow accounts
- Explicit CPI program IDs
- No
init_if_neededon critical state - No admin backdoors
- Inline PDA seeds (no lifetime bugs)
- Deterministic escrow logic
- Explicit system & token program passing
- No unsafe Rust
- Dispute DAO (milestone-level arbitration)
- Reputation System (Soulbound Token-2022)
- Reputation-weighted voting
- Frontend (Next.js + Wallet Adapter)
Pull requests welcome.
All contributions must include tests.
MIT License