2026 · Updated 2026-10-05

TradeGuard

Human-reviewed AI trade agreement extraction, delivery-evidence tracking and Solidity escrow prototype on Monad testnet.

My Role
Lead Engineer (DevClans)
Current Status
Testnet prototype · Monad Testnet (Chain ID 10143) & Sandbox
Intended Users
Commodity buyers, suppliers and designated arbitrators rehearsing structured delivery-dispute and split-escrow workflows.

Overview

TradeGuard is a full-stack trade workflow and escrow prototype keeping commercial agreements, delivery evidence and settlement allocations on one auditable trail. AI (Qwen Plus) assists solely with draft field extraction for human approval; it never holds wallet keys, decides disputes or releases funds. Important: TradeGuard is a Monad testnet prototype using valueless TGT test tokens, not an audited or production financial service.

Problem Statement

When physical deliveries fall short of contracted quantities (for example, 90 bags delivered out of 100 ordered), informal chat agreements, delivery receipts and payment releases fragment across disconnected channels, making partial-settlement arbitration slow and error-prone.

Technical Architecture

React and TypeScript frontend on Vite/Vinext backed by Cloudflare Workers, Cloudflare D1 relational storage, Cloudflare R2 evidence object storage, Singapore Qwen Plus structured extraction (with deterministic parser fallback), and OpenZeppelin Solidity escrow contracts on Monad Testnet via viem.

LAYER 01

Human-Reviewed Extraction

Server validates Qwen Plus extracted fields and filters source quotes; buyers and suppliers review and explicitly approve terms before persistence.

LAYER 02

Off-Chain Evidence & State (Cloudflare Worker + D1 + R2)

Stores full trade records in D1 and delivery shortage attachments in R2 while publishing only salted commitments on-chain.

LAYER 03

Monad Testnet Solidity Escrow

Deployed TGT token (0xfcc8...5f3b) and Escrow contract (0x27ba...f83a) on Chain ID 10143 enforcing buyer, supplier and arbitrator wallet signatures via viem.

Technology Stack

  • TypeScript
  • React
  • Cloudflare Workers
  • Cloudflare D1
  • Cloudflare R2
  • Solidity
  • OpenZeppelin
  • viem
  • Qwen Plus

Application & Architecture Captures

TradeGuard dashboard showing active trade overview, agreement status and role workspace controls
TradeGuard overview dashboard from the synthetic 100/90-bag delivery rehearsal.
TradeGuard delivery evidence screen recording 90 bags delivered and 10 bags missing
Delivery evidence record documenting a 10-bag shortage prior to arbitration.
TradeGuard settlement screen showing 2,250 TGT supplier allocation and 250 TGT buyer refund
Audited 90/10 settlement split (2,250 TGT supplier / 250 TGT buyer) in the sandbox workspace.

Key Engineering Decisions & Challenges

Engineering Decisions

  • Strictly separated AI assistance from financial authority: AI drafts structured fields with source quotes, while humans and role-specific wallet signatures control every state transition and withdrawal.
  • Kept sensitive trade documents and evidence blobs off-chain in R2, writing only salted cryptographic commitments to Monad testnet.
  • Built dual workspaces (a persisted local/sandbox rehearsal mode and a three-wallet Monad testnet contract mode), plus a deterministic parser fallback when Qwen is disabled.

Implementation Challenges

  • Preventing stale state transitions across concurrent buyer/supplier approvals and enforcing cross-owner workspace isolation in Worker routes.
  • Designing exact proportional split accounting (e.g., 2,250 TGT to supplier and 250 TGT to buyer in the 90/100-bag shortage scenario) across both D1 sandbox records and 6-decimal Solidity token math.

Testing Strategy & Demonstrated Outcomes

Testing & Verification

  • 11 passing domain state-machine and extraction validation tests (tests/domain.test.ts, tests/extraction.test.ts).
  • 7 passing local EVM smart-contract tests (tests/contracts.test.mjs) verifying funding, dispute arbitration and split withdrawals.
  • Persisted Worker API verification scripts checking cross-owner access denial, stale-version rejection and read-only Monad testnet contract verification (verify-testnet.mjs).

Demonstrated Outcomes

  • Verified deployed contracts on Monad Testnet (Chain ID 10143) passing bytecode, token linkage and decimal checks.
  • End-to-end 100/90-bag delivery shortage rehearsal verified across persisted D1/R2 APIs, TypeScript strict checks and all 7 UI navigation views.

Lessons Learned

  • Explicitly documenting contract and operational limits, such as advisory post-funding deadlines if an arbitrator becomes unavailable, communicates stronger engineering rigor than overstating testnet readiness.