π§Ύ Escrow Smart Contract
A secure, milestone-based Escrow system between a Client, Freelancer, and Admin, written in Solidity. It ensures safe payments, dispute resolution, and automated refunds β ideal for freelance or gig-based work.
βοΈ Features
πͺ Milestone-based payments β funds released only after approval
π Reentrancy protection and role-based access
π Auto-refund after deadline if work isnβt completed
βοΈ Admin dispute resolution with a configurable fee
π§Ύ Progress tracking via milestones and completion %
π State Transition Diagram
ββββββββββββββ
β CREATED β
ββββββββ¬ββββββ
β
β addMilestones() + deposit()
βΌ
ββββββββββββββ
β FUNDED β
ββββββββ¬ββββββ
β
β startWork()
βΌ
ββββββββββββββββββ
β IN_PROGRESS β
ββββββββ¬βββββ¬βββββ
β β
β βββββββββββ raiseDispute() βββββββββββββββ
β β
βΌ β
ββββββββββββββββββββββββ β
β AWAITING_APPROVAL β β
ββββββββββββ¬ββββββββββββ β
β approveMilestone() β
βΌ β
ββββββββββββββ ββββββββββββββ
β COMPLETED ββββββββββββ resolveDispute() β DISPUTED β
ββββββββββββββ ββββββββββββββ
β²
β triggerAutoRefund()
β
ββββββββββββββ
β REFUNDED β
ββββββββββββββ
Other transitions:
- cancel() β CANCELLED
- resolveDispute() decides between COMPLETED or REFUNDED
π Basic Flow
Client deploys contract with freelancer, admin, fee %, and duration
Client adds milestones β addMilestone()
Client deposits total β deposit()
Freelancer starts and completes milestones β completeMilestone(id)
Client approves β approveMilestone(id) β payment auto-released
If dispute β raiseDispute() β admin resolves with resolveDispute()
If deadline passes β triggerAutoRefund()
π§ Deployment (Remix)
Compiler: Solidity ^0.8.0 Deploy with:
constructor(address _freelancer, address _admin, uint _adminFeePercent, uint _durationDays)
π License SPDX-License-Identifier: MIT