📍 Page Location
URL: /dashboard/authenticated (contract action)
📸 Visual Representation of the Page
My Contracts
| Contract ID | Product | Value | Status | Actions |
|---|---|---|---|---|
| contract-001 | Wheat | $2,627,500 | PENDING DEPOSIT |
🎨 Detailed Visual Description
Buyer sees "Pay Deposit ($X)" button on contract. Clicking it shows MetaMask option (if available) or proceeds with simulation. Button is only visible when contract status is "pending_deposit". After payment, contract status changes to "ACTIVE" in green. Supplier dashboard automatically updates to show "ACTIVE" status with "Deposit Received" indicator.
Key Visual Elements:
- MetaMask integration (optional)
- Blockchain payment support
- Simulation mode fallback
- Balance validation
- Real-time status update for supplier
- Pool wallet deposit
⚙️ Backend Process
API Endpoint: POST /api/contracts/:contractId/deposit
Process Flow:
1. Validates user is the buyer
2. Checks contract status allows deposit
3. Validates wallet balance (wallet.tgtBalance >= depositAmount)
4. Deducts depositAmount (30%) from buyer wallet
5. Transfers depositAmount to pool wallet (escrow)
6. Updates contract: depositPaid = true, status = "active", depositPaidAt = timestamp
7. Pool wallet finances 100% to supplier immediately (supplier receives full amount)
8. Creates transaction record in database.transactions
9. Sends notification to supplier: "Deposit received, contract is now active"
10. Logs audit event: deposit_paid
11. Returns success with updated contractDatabase Operations:
- Table:
database.contracts (update),database.wallets (buyer deduction, pool deposit, supplier credit),database.transactions (create) - Action: undefined
➡️ Next Action
Contract is now ACTIVE. Supplier sees active status and can prepare shipment. Supplier has already received 100% payment (30% from pool + 70% financed). Buyer must pay remaining 70% + fees before delivery period ends.