Escrow lifecycle
The escrow state is not decorative metadata. Every write function depends on it.
enum Status {
Created,
Funded,
Delivered,
Approved,
Refunded
}Created
An escrow enters Created after createEscrow. No tokens have moved yet. The client can fund it; the freelancer cannot deliver yet.
Funded
After fundEscrow, tokens have been transferred into the contract. Two transitions are possible:
Funded → Delivered
Funded → RefundedThe refund route is available only after the deadline.
Delivered
Only the freelancer can enter this state through deliverWork.
The only implemented next transition is:
Delivered → ApprovedThe current contract has no timeout or arbitration path from Delivered. If the client refuses to approve, the escrow remains there indefinitely.
Approved
approveWork calculates the fee, credits the freelancer, credits the platform wallet, stores Approved, and emits WorkApproved. Tokens remain in the escrow contract until withdrawal.
Refunded
requestRefund is valid only when the caller is the client, the escrow is Funded, and block.timestamp > deadline.
The full escrow amount is transferred directly back to the client.
Terminal states
Approved and Refunded are terminal in the current implementation.