Step 5 of 9

Step 5: Create Contract Page

Buyer creates a new contract with product details, pricing, and counterparty information. When contract is created, an email notification is automatically sent to the supplier.

📍 Page Location

URL: /create-contract

📸 Visual Representation of the Page

Step 5: Create Contract Page
Market Average: $520.00 | Difference: 1.06% above market ✓
TGT
Tangent Token
USDT
Tether USD
USDC
USD Coin

🎨 Detailed Visual Description

Form includes: PDF upload (optional auto-fill), product dropdown (Rice, Wheat, Corn, etc. or "Other"), quantity, unit, price per unit with market comparison, currency selection (TGT/USDT/USDC), counterparty email, deposit percentage, voyage time, and description. Price comparison shows market average and variance warning if >5%. After submission, buyer sees confirmation message.

Key Visual Elements:

  • PDF contract upload with auto-extraction
  • Product dropdown with "Other" option
  • Real-time price comparison with exchanges
  • Currency selection (TGT/USDT/USDC)
  • Form validation
  • Email notification to supplier

⚙️ Backend Process

API Endpoint: POST /api/contracts/create

Process Flow:
1. Validates all required fields
2. Checks counterparty exists in database
3. Calculates totalValue = quantity × price
4. Calculates depositAmount = totalValue × (depositPercent/100)
5. Creates contract in database.contracts Map
6. Sets status: "pending_supplier_confirmation"
7. Sends email notification to supplier email address
8. Email contains contract details and link to dashboard
9. Logs audit event: contract_created
10. Returns contract ID and full contract object

Database Operations:

  • Table: database.contracts
  • Action: Create new contract
  • Fields: id, product, quantity, unit, pricePerUnit, totalValue, currency, buyerEmail, supplierEmail, depositPercent, depositAmount, status, createdAt

➡️ Next Action

Email sent to supplier. Contract appears in supplier dashboard waiting for confirmation. Contract also appears in buyer dashboard with status "Waiting for Supplier Confirmation".