Skip to content

XGPher35/SetuX

Repository files navigation

SetuX — Sovereign Trade Document Verification Engine

"The missing verification layer for emerging market PayFi"

Hackathon Side Track Network Privacy Models


Table of Contents

  1. The Problem
  2. What is SetuX
  3. System Architecture
  4. Full Pipeline Walkthrough
  5. QVAC AI Models (4 of 7)
  6. Token-2022 On-Chain Design
  7. Trust Model: V1 vs V2
  8. Business Model
  9. Transfer Hook Program (Anchor)
  10. Tether WDK Integration
  11. Pyth Network Oracle
  12. Solana Blinks & Dashboard
  13. Project Structure
  14. Setup & Installation
  15. Tech Stack
  16. Compliance & Legal

1. The Problem

┌─────────────────────────────────────────────────────────────────────┐
│                                                                     │
│  A Nepali carpet exporter ships $17,000 worth of hand-knotted      │
│  rugs to a buyer in New York.                                       │
│                                                                     │
│  Standard letter-of-credit terms: payment in 60–90 days.           │
│                                                                     │
│  The exporter needs liquidity NOW — wages, materials, next order.   │
│                                                                     │
│  PayFi protocols exist (Huma, Credix) but require uploading         │
│  sensitive trade documents to centralized cloud APIs:               │
│                                                                     │
│       buyer contact lists  ·  profit margins  ·  supply chain      │
│                                                                     │
│  → Exporter must choose: liquidity OR privacy. Never both.          │
│                                                                     │
└─────────────────────────────────────────────────────────────────────┘

The Trust Gap

                    EXISTING PAYFI FLOW
                    ═══════════════════

  Exporter                         PayFi Protocol
     │                                   │
     │  "Here are my trade documents"    │
     │ ─────────────────────────────► ☁️ │  ← Cloud API
     │                                   │    (centralised)
     │                                   │    (data exposed)
     │                                   │    (privacy breach)
     │                                   │
     │  "Verified ✓ — here's capital"    │
     │ ◄───────────────────────────── 💸 │
     │                                   │

  PROBLEM: Buyer list + margins + supply chain → centralised server

SetuX is the missing verification layer — it proves invoice legitimacy without ever uploading a single byte of trade data to any cloud.


2. What is SetuX

SetuX (from "Setu" — सेतु, Sanskrit for "bridge") is a sovereign trade document verification engine built for emerging market exporters.

Core Proposition

Property Detail
Privacy Zero data leaves the exporter's device during AI verification
Speed From scan to funded: ~90 seconds vs 2–3 weeks at a bank
Collateral None required (banks require collateral; SetuX does not)
Compliance Every transaction on public Solana Explorer; Nepal FERA 2019 enforced
AI Stack 4 offline QVAC models: OCR + Translation + RAG + LLM
On-Chain Token-2022 asset with 4 advanced extensions on Solana

What It Verifies

SetuX cross-references three trade documents and flags any mismatch:

  ┌──────────────┐    ┌──────────────────┐    ┌──────────────────┐
  │   INVOICE    │    │  PURCHASE ORDER  │    │ BILL OF LADING   │
  │              │    │                  │    │                  │
  │  Amounts ✓   │◄──►│  Amounts match?  │◄──►│  Shipped qty?    │
  │  Parties ✓   │    │  Parties match?  │    │  Route correct?  │
  │  Dates   ✓   │    │  Dates align?    │    │  Dates align?    │
  └──────────────┘    └──────────────────┘    └──────────────────┘
         │                     │                       │
         └─────────────────────┴───────────────────────┘
                               │
                    Nepal Export Law RAG check
                               │
                    SHA-256 attestation hash
                               │
                    Token-2022 mint on Solana

3. System Architecture

High-Level Architecture

╔═══════════════════════════════════════════════════════════════════════════╗
║                         EXPORTER'S MACHINE                               ║
║  ┌────────────┐  ┌────────────┐  ┌─────────────────────────────────┐    ║
║  │ invoice.jpg│  │   PO.jpg   │  │       bill-of-lading.jpg        │    ║
║  └─────┬──────┘  └─────┬──────┘  └──────────────┬──────────────────┘    ║
║        └───────────────┴──────────────────────────┘                      ║
║                                  │                                        ║
║                        ┌─────────▼──────────┐                            ║
║                        │  QVAC OCR (ONNX)   │  ← @qvac/ocr-onnx         ║
║                        │  Offline / No API  │    ONNX Runtime            ║
║                        └─────────┬──────────┘                            ║
║                                  │  raw text (Devanagari + English)       ║
║                        ┌─────────▼──────────┐                            ║
║                        │  QVAC Translate     │  ← @qvac/translation-nmtcpp║
║                        │  Nepali → English  │    CTranslate2             ║
║                        └─────────┬──────────┘                            ║
║                                  │  English-normalised text               ║
║                        ┌─────────▼──────────┐                            ║
║                        │  QVAC RAG Pipeline  │  ← @qvac/embed-llamacpp   ║
║                        │  Embed + Retrieve  │    @qvac/llm-llamacpp      ║
║                        │  Nepal Export Law  │    Llama 3.2 1B Q4_0       ║
║                        └─────────┬──────────┘                            ║
║                                  │  compliance verdict + reasoning        ║
║                        ┌─────────▼──────────┐                            ║
║                        │  SHA-256 Attestation│  ← Node.js crypto         ║
║                        └─────────┬──────────┘                            ║
╚════════════════════════╦═════════╧══════════╦══════════════════════════════╝
                         ║    BOUNDARY        ║
                         ║  (first byte out)  ║
╔════════════════════════╩═════════╤══════════╩══════════════════════════════╗
║                SOLANA DEVNET     │                                         ║
║                        ┌─────────▼──────────┐                             ║
║                        │  Pyth Hermes Oracle │  FX.USD/NPR live rate      ║
║                        └─────────┬──────────┘                             ║
║                                  │                                         ║
║                        ┌─────────▼──────────┐                             ║
║                        │  Token-2022 Mint    │  4 extensions:             ║
║                        │  ● MetadataPointer  │  attestation hash on-chain ║
║                        │  ● InterestBearing  │  15% APY (1500 bps)       ║
║                        │  ● PermanentDelegate│  DAO repo rights          ║
║                        │  ● TransferHook     │  on-chain KYC             ║
║                        └─────────┬──────────┘                             ║
║                                  │                                         ║
║              ┌───────────────────┼───────────────────┐                    ║
║              │                   │                   │                    ║
║    ┌─────────▼────┐   ┌─────────▼──────┐   ┌───────▼────────┐           ║
║    │ Solana Blink  │   │  Institutional │   │ Solana Explorer│           ║
║    │ (Twitter btn) │   │  Dashboard     │   │  (public audit)│           ║
║    └──────────────┘   └────────────────┘   └────────────────┘           ║
╚══════════════════════════════════════════════════════════════════════════════╝

Component Interaction Diagram

                  ┌─────────────────┐
                  │   CLI / Web App  │
                  └────────┬────────┘
                           │ triggers pipeline
          ┌────────────────┼────────────────────┐
          │                │                    │
    ┌─────▼──────┐  ┌──────▼──────┐  ┌─────────▼──────┐
    │  qvac/     │  │  solana/    │  │  programs/     │
    │  ocr.js    │  │  mint.js   │  │  transfer-hook/ │
    │  translate │  │  pyth.js   │  │  (Anchor/Rust)  │
    │  rag.js    │  └──────┬──────┘  └────────────────┘
    └─────┬──────┘         │               ▲
          │                │               │ called on every transfer
          │ payload        │ signs + sends │
          └────────────────┘               │
                    │                      │
             ┌──────▼──────────────────────┘
             │       Solana Token-2022      │
             │   (devnet / mainnet-beta)    │
             └──────────────────────────────┘

4. Full Pipeline Walkthrough

Stage-by-Stage Data Flow

INPUT
═════
  invoice.jpg  ──┐
  PO.jpg       ──┼──► [Stage 1: OCR]
  BoL.jpg      ──┘

STAGE 1 — OCR  (@qvac/ocr-onnx · ONNX Runtime · OFFLINE)
══════════════════════════════════════════════════════════
  Extracts raw text from each scanned image.
  Handles handwritten annotations, stamps, mixed scripts.

  Output:
  {
    invoice:  "चालान नं. १२३ | वस्तु: हाते गलैंचा | रकम: २,२७९,०३५ रुपैयाँ",
    po:       "PO-2024-NYC-0892 | Qty: 48 units | USD 17,000",
    bol:      "B/L No. KTM-JFK-20240312 | Vessel: MSC MAYA | ETA: 2024-04-01"
  }

STAGE 2 — TRANSLATE  (@qvac/translation-nmtcpp · CTranslate2 · OFFLINE)
═════════════════════════════════════════════════════════════════════════
  Nepali/Devanagari → English, field by field.
  Preserves numeric values, codes, and reference numbers exactly.

  Output:
  {
    invoice:  "Invoice No. 123 | Item: Hand-knotted Carpet | Amount: NPR 2,279,035",
    po:       "PO-2024-NYC-0892 | Qty: 48 units | USD 17,000",
    bol:      "B/L No. KTM-JFK-20240312 | Vessel: MSC MAYA | ETA: 2024-04-01"
  }

STAGE 3 — RAG COMPLIANCE  (@qvac/embed-llamacpp + @qvac/llm-llamacpp · OFFLINE)
════════════════════════════════════════════════════════════════════════════════
  Step A: Embed nepal-export-law.txt into vector store
  Step B: Retrieve top-k relevant law sections for this invoice
  Step C: LLM cross-references all 3 documents against retrieved law

  Checks performed:
  ├── Invoice vs PO: amounts, parties, item descriptions match?
  ├── PO vs Bill of Lading: quantities, routing, dates align?
  ├── Nepal FERA 2019: repatriation within 180 days?
  ├── NRB Guidelines: foreign currency declaration correct?
  └── Export Valuation: invoice value consistent with market rate?

  Output:
  {
    verdict:   "PASS",
    confidence: 0.94,
    flags:     [],
    reasoning: "All three documents consistent. NPR 2,279,035 ≈ USD 17,000
                at current rate. 90-day payment term within 180-day NRB
                repatriation window. Export classification correct."
  }

STAGE 4 — ATTESTATION  (Node.js crypto)
════════════════════════════════════════
  SHA-256 hash of full verification payload:
  { documents_hash, verdict, timestamp, exporter_pubkey, amount_usd }

  attestation_hash: "a3f8c2d1e9b74561..."  (64 hex chars)

  ↑ This hash goes on-chain. The underlying data never does.

STAGE 5 — ORACLE  (Pyth Network Hermes API)
════════════════════════════════════════════
  GET https://hermes.pyth.network/v2/updates/price/latest
      ?ids[]=FX.USD/NPR

  Response: { price: 133.87, confidence: 0.12, timestamp: 1712000000 }

  invoice_usd = 2,279,035 NPR ÷ 133.87 = $17,025.43
  (Fallback: 0.00745 USD/NPR if Hermes unavailable)

STAGE 6 — WALLET  (Tether WDK / keypair.json)
═══════════════════════════════════════════════
  Primary:  Tether WDK (BIP-39 seed phrase, non-custodial)
  Fallback: keypair.json (dev/testing)

STAGE 7 — MINT  (Token-2022 · 4 extensions)
════════════════════════════════════════════
  Mints a Token-2022 asset with:
  ├── MetadataPointer → attestation_hash, invoice_usd, trade_route
  ├── InterestBearing → 1500 bps (15% APY, 90-day compounding)
  ├── PermanentDelegate → SetuX Resolution DAO pubkey
  └── TransferHook → programs/transfer-hook (KYC whitelist PDA)

  Mint address logged: "5XmK...9Rzq"
  Explorer: https://explorer.solana.com/address/5XmK...9Rzq?cluster=devnet

STAGE 8 — DISTRIBUTION
═══════════════════════
  ├── Solana Blink  → https://dial.to/?action=setux/fund/5XmK...9Rzq
  │                   (embeds as a Fund button inside Twitter/X)
  └── Dashboard     → http://localhost:3000 (institutional marketplace)

5. QVAC AI Models (4 of 7)

Model Capability Map

  QVAC CAPABILITIES (7 total)
  ════════════════════════════

  ● USED    ○ AVAILABLE FOR V2

  ● @qvac/ocr-onnx            ──── Document scanning & text extraction
  ● @qvac/translation-nmtcpp  ──── Neural machine translation (offline)
  ● @qvac/embed-llamacpp      ──── Vector embeddings for RAG
  ● @qvac/llm-llamacpp        ──── Local LLM inference (Llama 3.2 1B)
  ○ @qvac/asr-whisper         ──── Audio transcription (future: voice invoices)
  ○ @qvac/tts-piper           ──── Text-to-speech (future: accessibility)
  ○ @qvac/vision-clip         ──── Image classification (future: cargo photo verify)

Model Detail Table

# Model Package Runtime Purpose Privacy
1 OCR @qvac/ocr-onnx ONNX Runtime Extract text from scanned invoice, PO, bill of lading — handles Devanagari script, stamps, handwriting 🔒 Fully offline
2 Translate @qvac/translation-nmtcpp CTranslate2 Neural machine translation Nepali → English; preserves numeric codes exactly 🔒 Fully offline
3 Embed @qvac/embed-llamacpp llama.cpp Creates vector embeddings of chunked Nepal trade law for RAG retrieval 🔒 Fully offline
4 LLM @qvac/llm-llamacpp llama.cpp Llama 3.2 1B Q4_0 — RAG compliance check + cross-document verification 🔒 Fully offline

RAG Compliance Architecture

  nepal-export-law.txt  (10 sections, ~8,000 tokens)
         │
         │  chunk (512 tokens, 64 overlap)
         ▼
  ┌─────────────────────────────────────┐
  │         Vector Store                │
  │  [chunk_0] → embedding_0 (1536-d)  │
  │  [chunk_1] → embedding_1           │
  │  [chunk_2] → embedding_2           │
  │       ...                           │
  │  [chunk_N] → embedding_N           │
  └──────────────┬──────────────────────┘
                 │
  invoice text ──┼──► query embedding ──► cosine similarity
                 │
                 │  top-3 relevant law chunks retrieved
                 ▼
  ┌─────────────────────────────────────────────────────────────────┐
  │  PROMPT TO LLAMA 3.2 1B                                         │
  │                                                                  │
  │  System: You are a Nepal trade compliance expert.               │
  │                                                                  │
  │  Context (RAG):                                                  │
  │    [Section 4 FERA 2019: repatriation within 180 days...]       │
  │    [Section 7 NRB: foreign currency export declaration...]      │
  │    [Section 9: carpet export HS code 5701.10...]                │
  │                                                                  │
  │  Documents:                                                      │
  │    Invoice: NPR 2,279,035 | 48 carpets | buyer: NYC Co.         │
  │    PO:      USD 17,000    | 48 units   | buyer: NYC Co.         │
  │    BoL:     48 units      | KTM→JFK    | ETA Apr 1             │
  │                                                                  │
  │  Task: Cross-reference all documents. Flag any discrepancy.     │
  │        Check against Nepal export law. Return JSON verdict.     │
  └─────────────────────────────────────────────────────────────────┘
                 │
                 ▼
  { verdict: "PASS", confidence: 0.94, flags: [], reasoning: "..." }

6. Token-2022 On-Chain Design

Extension Architecture

  TOKEN-2022 ASSET
  ════════════════

  Mint Address: 5XmK...9Rzq
  │
  ├─── [Extension 1] MetadataPointer
  │         Pointer ──► Metadata Account
  │                         ├── attestation_hash: "a3f8c2d1..."
  │                         ├── invoice_usd:      17025.43
  │                         ├── trade_route:      "KTM → JFK"
  │                         ├── exporter:         "Himalayan Carpets Pvt Ltd"
  │                         ├── buyer:            "NYC Imports LLC"
  │                         ├── compliance:       "PASS"
  │                         └── maturity_date:    "2024-07-01"
  │
  ├─── [Extension 2] InterestBearing
  │         Rate: 1500 bps (15.00% APY)
  │         Compounding: continuous (Token-2022 native)
  │         Day 0:   $14,450.00  ← LP disburses
  │         Day 45:  $14,717.82  ← midpoint value
  │         Day 90:  $14,991.60  ← maturity value
  │         Spread:  $2,550.00   ← SetuX protocol fee
  │
  ├─── [Extension 3] PermanentDelegate
  │         Delegate: SetuX Resolution DAO (9mNr...Kx2q)
  │         Powers:   freeze · burn · seize
  │         Trigger:  off-chain fraud proven → DAO vote → on-chain repo
  │         Mirrors:  BlackRock BUIDL compliance architecture
  │
  └─── [Extension 4] TransferHook
            Program:  programs/transfer-hook (Anchor)
            On every transfer:
               1. Lookup recipient in whitelist PDA
               2. If NOT whitelisted → revert transfer
               3. If whitelisted → allow + log
            Whitelist: KYC'd institutional PayFi LPs only

Token Lifecycle

  TIME ──────────────────────────────────────────────────────────────►

   T=0          T=1 (verify)    T=2 (mint)      T=90d        T=maturity
    │                │               │              │               │
    ●────────────────●───────────────●──────────────●───────────────●
    │                │               │              │               │
  Scan           QVAC AI          Token         Interest        Buyer
  docs           verifies         minted        accruing        pays
  offline        offline          on-chain      (15% APY)       invoice
                                  │
                             LP funds
                          $14,450 USDC
                          to exporter
                          (90 seconds)

7. Trust Model: V1 vs V2

The Oracle Problem

  THE ORACLE PROBLEM
  ══════════════════

  SetuX V1 solves PRIVACY (data stays on device).
  But client-side AI raises a new question:

  ┌────────────────────────────────────────────────────────────┐
  │                                                            │
  │  What stops a malicious exporter from feeding             │
  │  the AI a photoshopped invoice?                           │
  │                                                            │
  │  Local LLM verification is only as trustworthy            │
  │  as the inputs it receives.                               │
  │                                                            │
  └────────────────────────────────────────────────────────────┘

V1 — Privacy-First (Current)

  TRUST MECHANISM: ON-CHAIN RECOURSE
  ═══════════════════════════════════

  Fraud occurs              DAO investigates
       │                          │
       ▼                          ▼
  Off-chain proof ──────► PermanentDelegate ──────► Seize / Burn token
  (buyer disputes)         (DAO executes)           (LP protected)

  This mirrors real-world repo agreements and trade finance legal
  structures — including BlackRock's BUIDL fund compliance architecture.

  TransferHook ensures capital only flows to KYC'd institutional LPs
  who have legal standing to enforce off-chain.

V2 — Cryptographic Authenticity (Roadmap)

  TRUST MECHANISM: CRYPTOGRAPHIC PROOF
  ══════════════════════════════════════

  ┌──────────────────────────────────────────────────────────────────┐
  │                                                                  │
  │  zk-TLS (Reclaim Protocol)                                       │
  │  └── Proves invoice data originated from Nepal Customs           │
  │       ASYCUDA government portal — not a Photoshop file           │
  │                                                                  │
  │  Hardware TEE Attestation                                        │
  │  └── Proves QVAC inference was executed inside a trusted         │
  │       execution environment, not tampered with                   │
  │                                                                  │
  │  Switchboard Custom Oracle                                       │
  │  └── NPR/USD exchange rate published on-chain                   │
  │       (replaces Pyth Hermes HTTP call)                          │
  │                                                                  │
  │  Licensed PSP Offramp                                            │
  │  └── Direct USDC → NPR bank transfer via licensed               │
  │       payment service provider (regulatory compliant)            │
  │                                                                  │
  └──────────────────────────────────────────────────────────────────┘

  V1: Privacy ✓ · Fraud recourse ✓ · Crypto proof ✗
  V2: Privacy ✓ · Fraud recourse ✓ · Crypto proof ✓

8. Business Model

Unit Economics (Single Invoice)

  INVOICE: $17,000 USD  (NPR 2,279,035 @ 133.87)
  ════════════════════════════════════════════════

  ┌─────────────────────────────────────────────────────────────┐
  │                                                             │
  │   Exporter receives (Day 0)        $14,450  ← 85% advance  │
  │                                                             │
  │   Buyer pays (Day 90)              $17,000  ← full invoice  │
  │                                                             │
  │   SetuX protocol spread             $2,550  ← 15% fee      │
  │                                                             │
  │   LP earns over 90 days    15% APY × 90/365 = ~3.7%        │
  │                            on $14,450 → ~$534 net to LP     │
  │                                                             │
  └─────────────────────────────────────────────────────────────┘

  VS BANK ALTERNATIVE
  ───────────────────
  Nepal bank:  9–14% annual  ·  requires collateral  ·  2–3 weeks
  SetuX:       15% APY       ·  zero collateral       ·  90 seconds

Market Opportunity

  NEPAL EXPORT MARKET: $3.6 BILLION/YEAR
  ════════════════════════════════════════

     $3.6B ──────────────────────────────────────────────────────┐
                                                                  │
     $36M  ─────────────────────────────────────┐  1% market     │
                                                 │  share target  │
     $1M   ───────────────────┐  pilot volume    │               │
                              │                  │               │
     Protocol revenue:      ~$150k            ~$5.4M         ~$54M
                           (pilot)           (1% share)      (15% share)

Comparison Table

Nepal Bank Huma / Credix SetuX
Advance rate 70–80% 80–90% 85%
Speed 2–3 weeks 3–5 days ~90 seconds
Collateral required Yes Partial None
Privacy High Low (cloud upload) Maximum (local AI)
On-chain proof No Partial Full (Token-2022)
Serves rejected exporters No Sometimes Yes

9. Transfer Hook Program (Anchor)

KYC Whitelist Architecture

  TRANSFER HOOK PROGRAM  (programs/transfer-hook/src/lib.rs)
  ══════════════════════════════════════════════════════════

  Accounts:
  ┌─────────────────────────────────────────────────────────────────┐
  │  whitelist_pda  (PDA derived from mint address)                  │
  │    ├── authority:   SetuX protocol pubkey                        │
  │    └── approved[]:  [lp_1_pubkey, lp_2_pubkey, lp_3_pubkey...]  │
  └─────────────────────────────────────────────────────────────────┘

  Instructions:
  ┌───────────────────────┬──────────────────────────────────────────┐
  │ initialize_whitelist  │ Creates whitelist PDA for a given mint   │
  │ add_to_whitelist      │ Admin adds a KYC'd LP wallet             │
  │ remove_from_whitelist │ Admin removes a wallet (compliance exit) │
  │ transfer_hook         │ Called by Token-2022 on EVERY transfer   │
  └───────────────────────┴──────────────────────────────────────────┘

  Transfer Hook Logic:
  ────────────────────
  Token-2022 runtime calls transfer_hook automatically.

  transfer_hook(ctx, amount) {
    recipient = ctx.accounts.destination_authority
    whitelist = ctx.accounts.whitelist_pda

    if recipient NOT IN whitelist.approved[] {
      return Err(SetuXError::RecipientNotKYC)   // ← transfer reverts
    }

    emit!(TransferEvent { from, to, amount, timestamp })
    Ok(())
  }

Deployment

cd programs/transfer-hook

# Build the Anchor program
anchor build

# Deploy to devnet
anchor deploy --provider.cluster devnet

# Verify deployment
solana program show <PROGRAM_ID> --url devnet

10. Tether WDK Integration

Key Management Flow

  KEY MANAGEMENT
  ══════════════

  PRIMARY PATH (Recommended)
  ──────────────────────────
  SETUX_SEED_PHRASE env var
         │
         ▼
  @tetherto/wdk  ──►  BIP-39 derivation  ──►  Solana keypair
  @tetherto/wdk-wallet-solana
         │
         ▼
  Non-custodial local wallet
  (seed phrase never leaves machine)

  FALLBACK PATH (Dev / Testing)
  ──────────────────────────────
  keypair.json  ──►  read from disk  ──►  Solana keypair
  (standard Solana CLI format)

  DETECTION LOGIC
  ───────────────
  if (process.env.SETUX_SEED_PHRASE) {
    wallet = await WDK.fromMnemonic(process.env.SETUX_SEED_PHRASE)
  } else {
    wallet = Keypair.fromSecretKey(readKeypairJson())
  }

11. Pyth Network Oracle

NPR/USD Exchange Rate Flow

  PYTH HERMES ORACLE
  ══════════════════

  GET https://hermes.pyth.network/v2/updates/price/latest
      ?ids[]=FX.USD/NPR

  Response schema:
  {
    "parsed": [{
      "id":    "FX.USD/NPR",
      "price": {
        "price":      "13387000000",   ← price × 10^-expo
        "conf":       "12000000",      ← confidence interval
        "expo":       -8,
        "publish_time": 1712000000
      }
    }]
  }

  Computation:
  ────────────
  raw_price  = 13387000000
  exponent   = -8
  usd_per_npr = 13387000000 × 10^-8  = 133.87 NPR per USD
  invoice_usd = 2,279,035 NPR ÷ 133.87 = $17,025.43

  Fallback:
  ─────────
  If Hermes API unreachable:
    fallback_rate = 0.00745 USD/NPR  (~134.23 NPR/USD)
    (hardcoded NRB reference rate — logged with warning)

12. Solana Blinks & Dashboard

Blink Architecture

  SOLANA BLINK
  ═════════════

  SetuX generates:
  https://dial.to/?action=setux/fund/5XmK...9Rzq

  When shared on Twitter/X:
  ┌──────────────────────────────────────────────┐
  │  🏔️  SetuX — Himalayan Carpets Invoice       │
  │                                              │
  │  ✅ AI Verified · 15% APY · 90-day term     │
  │  📦 48 hand-knotted carpets  KTM → JFK      │
  │  💰 Fund $14,450 USDC · Earn 15% APY        │
  │                                              │
  │  [  Fund Invoice  ]   [  View on Explorer  ] │
  │                                              │
  └──────────────────────────────────────────────┘

  One click → wallet prompt → devnet transaction → exporter funded

Institutional Dashboard Panels

  DUAL-SIDED DASHBOARD  (Next.js + Tailwind)
  ══════════════════════════════════════════

  ┌────────────────────────┬────────────────────────┐
  │    EXPORTER PANEL      │    INVESTOR PANEL       │
  ├────────────────────────┼────────────────────────┤
  │                        │                        │
  │  Upload Documents      │  Browse Marketplace    │
  │  ├── invoice.jpg       │  ├── Filter by APY     │
  │  ├── po.jpg            │  ├── Filter by country │
  │  └── bol.jpg           │  └── Filter by size    │
  │                        │                        │
  │  Run AI Pipeline       │  KYC Status            │
  │  └── Live progress     │  ├── Wallet verified?  │
  │      display           │  └── Whitelist status  │
  │                        │                        │
  │  View Attestation      │  Fund Invoice          │
  │  ├── Hash: a3f8c2...   │  ├── USDC amount       │
  │  ├── Verdict: PASS ✓   │  ├── Expected return   │
  │  └── Mint address      │  └── Execute on devnet │
  │                        │                        │
  └────────────────────────┴────────────────────────┘

13. Project Structure

setux/
│
├── web-app/                          ← Next.js Dual-Sided Institutional Dashboard
│   ├── app/
│   │   ├── page.tsx                  ← Landing / routing
│   │   ├── exporter/page.tsx         ← Exporter origination panel
│   │   └── investor/page.tsx         ← LP marketplace panel
│   ├── components/
│   │   ├── PipelineProgress.tsx      ← Live QVAC pipeline status
│   │   ├── AttestationCard.tsx       ← On-chain proof display
│   │   └── InvoiceMarketplace.tsx    ← LP browsing interface
│   └── package.json
│
├── web/                              ← Static Marketing Landing Page
│   └── index.html
│
├── qvac/
│   ├── ocr.js                        ← Multi-document OCR (3 docs in parallel)
│   ├── translate.js                  ← Nepali → English (CTranslate2)
│   └── rag.js                        ← RAG: embed law + retrieve + LLM verify
│
├── solana/
│   ├── mint.js                       ← Token-2022 mint with all 4 extensions
│   └── pyth.js                       ← Pyth Hermes NPR/USD oracle query
│
├── programs/
│   └── transfer-hook/                ← Anchor program (Rust)
│       ├── src/
│       │   └── lib.rs                ← KYC whitelist transfer hook logic
│       ├── Cargo.toml
│       └── Anchor.toml
│
├── compliance/
│   └── nepal-export-law.txt          ← 10-section Nepal trade law (RAG corpus)
│
├── test-docs/
│   ├── invoice.jpg                   ← Place your scanned invoice here
│   ├── purchase-order.jpg            ← Place your scanned PO here
│   └── bill-of-lading.jpg           ← Place your scanned BoL here
│
├── keypair.json                      ← Solana keypair (fallback; use WDK in prod)
├── package.json
└── README.md

14. Setup & Installation

Prerequisites

Requirement Version Notes
Node.js >= v22.17 ES modules required
Rust stable For Anchor program compilation
Anchor CLI >= 0.29 Solana program framework
Solana CLI >= 1.18 Devnet deployment

Installation

# 1. Clone and install dependencies
git clone https://github.com/your-org/setux
cd setux
npm install

# 2a. Wallet setup — Option A: Tether WDK (recommended for production)
export SETUX_SEED_PHRASE="word1 word2 word3 ... word24"

# 2b. Wallet setup — Option B: Solana keypair (dev / testing)
solana-keygen new --outfile keypair.json
solana airdrop 2 $(solana-keygen pubkey keypair.json) --url devnet

# 3. Place scanned trade documents
cp /path/to/your/invoice.jpg        test-docs/invoice.jpg
cp /path/to/your/purchase-order.jpg test-docs/purchase-order.jpg
cp /path/to/your/bill-of-lading.jpg test-docs/bill-of-lading.jpg

# 4. (Optional) Deploy transfer hook program
cd programs/transfer-hook
anchor build
anchor deploy --provider.cluster devnet
cd ../..

# 5. Run the full pipeline (CLI)
node index.js

# 6. Run the web dashboard
cd web-app
npm install
npm run dev
# → Open http://localhost:3000

Expected CLI Output

SetuX Sovereign Trade Document Verification Engine
══════════════════════════════════════════════════

[1/7] OCR: Extracting text from 3 documents...
  ✓ invoice.jpg        → 847 chars extracted
  ✓ purchase-order.jpg → 612 chars extracted
  ✓ bill-of-lading.jpg → 493 chars extracted

[2/7] Translate: Nepali → English...
  ✓ invoice.jpg        → translated (1.2s)
  ✓ purchase-order.jpg → no translation needed
  ✓ bill-of-lading.jpg → no translation needed

[3/7] RAG: Loading Nepal export law corpus...
  ✓ nepal-export-law.txt → 10 sections, 23 chunks embedded

[4/7] LLM: Running compliance check...
  ✓ Verdict: PASS (confidence: 0.94)
  ✓ No discrepancies detected

[5/7] Attestation: Hashing verification payload...
  ✓ SHA-256: a3f8c2d1e9b74561...

[6/7] Oracle: Fetching NPR/USD from Pyth Hermes...
  ✓ Rate: 133.87 NPR/USD (confidence ±0.12)
  ✓ Invoice USD value: $17,025.43

[7/7] Mint: Creating Token-2022 asset on devnet...
  ✓ Mint address: 5XmK...9Rzq
  ✓ Extensions: MetadataPointer ✓ InterestBearing ✓ PermanentDelegate ✓ TransferHook ✓

══════════════════════════════════════════════════
✅ VERIFICATION COMPLETE — 91.3 seconds

  Mint:     5XmK...9Rzq
  Explorer: https://explorer.solana.com/address/5XmK...9Rzq?cluster=devnet
  Blink:    https://dial.to/?action=setux/fund/5XmK...9Rzq

15. Tech Stack

Layer Technology Version Role
Runtime Node.js >= v22.17 ES modules, pipeline orchestration
UI Dashboard Next.js + Tailwind CSS 14.x Dual-sided institutional interface
AI — OCR @qvac/ocr-onnx (ONNX Runtime) latest Offline document text extraction
AI — Translate @qvac/translation-nmtcpp (CTranslate2) latest Offline Nepali → English NMT
AI — Embed @qvac/embed-llamacpp (llama.cpp) latest Offline vector embeddings for RAG
AI — LLM @qvac/llm-llamacpp (Llama 3.2 1B Q4_0) latest Offline compliance reasoning
Wallet Tether WDK (@tetherto/wdk) latest BIP-39 non-custodial key management
Blockchain Solana (Token-2022) devnet Token mint with 4 extensions
Smart Contract Anchor (Rust) 0.29.x Transfer hook KYC program
Oracle Pyth Network (Hermes API) v2 Real-time NPR/USD exchange rate
Distribution Solana Actions / Blinks latest Twitter-embeddable fund buttons

16. Compliance & Legal

Why Not Hundi?

  HUNDI (informal hawala)     vs     SetuX
  ═══════════════════════════════════════════

  No paper trail                     Full on-chain audit trail
  Hidden / off-book                  Public Solana Explorer
  Illegal in Nepal                   Compliant with FERA 2019
  Zero regulatory oversight          NRB guidelines enforced
  No KYC                             KYC required at every transfer
  Tax evasion risk                   IRD-auditable on-chain records

Nepal Regulatory Compliance

Regulation Requirement SetuX Implementation
FERA 2019 Foreign exchange repatriation within 180 days RAG check on every invoice; maturity_date encoded in Token-2022 metadata
NRB Guidelines Foreign currency export declaration Checked in Stage 3 RAG compliance
Export Valuation Invoice value must match market rate Pyth oracle cross-reference; LLM cross-document check
IRD (Tax) Taxable export income declaration Full on-chain record; Explorer link as audit proof

Audit Trail

Every SetuX transaction produces:

  1. SHA-256 attestation hash  (on-chain via MetadataPointer)
  2. Token-2022 mint address   (permanent Solana ledger entry)
  3. Transfer log              (emitted by TransferHook on every LP transfer)
  4. Pyth oracle timestamp     (exchange rate provably locked at mint time)

  To provide for IRD / NRB audit:
  → Share mint address → explorer.solana.com shows everything

Category Detail
Key Innovation First sovereign, fully-offline AI verification layer for PayFi
Target Market $3.6B Nepal export market; expandable to any emerging market exporter

Built for the Colosseum Frontier Hackathon 2026. SetuX — सेतु — the bridge between trade and capital.

About

SetuX

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors