The Diplomat: AI-Powered Email Arbitration on Chainlink CRE

The Diplomat: AI-Powered Email Arbitration on Chainlink CRE

2026-03-02 · BaseMail Team · The Diplomat, Chainlink, CRE, hackathon, AI arbitration, $ATTN, Gemini

We Entered a Hackathon

BaseMail is competing in Chainlink Convergence — a global hackathon for building decentralized applications with Chainlink's Compute Runtime Environment (CRE). We're entered in two tracks:

The feature we built is called The Diplomat 🦞

What The Diplomat Does

Every email on BaseMail costs $ATTN tokens. The Diplomat decides how much — not with a fixed price, but with AI arbitration that reads the email and judges its quality.

Here's the flow:

1. You Compose an Email

You're writing to someone on BaseMail. The Diplomat card appears showing the estimated cost — calculated by our Quadratic Attention Funding (QAF) formula:

base_cost = (n + 1)² + 2

Where n is the number of unread emails you've already sent them. First email? Cheap. Tenth unanswered email? Expensive. This is the anti-spam mechanism — it's economically irrational to keep spamming someone who isn't reading your emails.

2. Gemini Reads Your Email

When you hit Send, the email goes through Gemini 2.0 Flash for classification:

CategoryCoefficientExample
spam"Buy crypto now! Limited offer!"
coldGeneric outreach, no personalization
legit0.5×Genuine inquiry, relevant to recipient
high_value0.3×Collaboration proposal, partnership
replyReply to existing conversation (FREE)
The actual cost is: QAF base × LLM coefficient

A legitimate collaboration proposal to someone you haven't emailed before costs: 3 × 0.5 = 2 ATTN instead of the estimated 3. Good emails get rewarded with discounts — and you see a confetti celebration 🎉🦞🎉 in the UI.

3. Chainlink CRE Verifies It On-Chain

This is where Chainlink comes in. The Diplomat's arbitration doesn't just live in our API — it's verifiable through Chainlink CRE.

The CRE workflow:

  • Fetches the email data from BaseMail's API (using CRE's HTTPClient capability)
  • Calls Gemini for LLM classification (with the API key stored as a CRE secret)
  • Calculates the QAF cost with the LLM coefficient
  • Writes the attestation on-chain to the DiplomatAttestation contract
  • This means any email's pricing can be independently verified. The sender can't game the system. The platform can't silently overcharge. It's trustless email arbitration.

    The Attention Economy in Action

    The Diplomat builds on BaseMail's $ATTN token system (announced in v3):

    Sending Costs ATTN (Temporarily)

    When you send an email, ATTN tokens are escrowed — not burned. What happens next depends on the recipient:

    The QAF Formula Prevents Spam

    The quadratic cost curve means:

    Unread streak (n)Base cost
    03 ATTN
    14 ATTN
    27 ATTN
    312 ATTN
    419 ATTN
    528 ATTN
    By the 5th unanswered email, you're paying 28 ATTN — nearly 10× the first email. This isn't punishment; it's a signal. If someone isn't reading your emails, maybe stop sending them.

    But when they do read? The streak resets. Cost drops back to 3 ATTN. The system rewards healthy communication.

    LLM Arbitration Rewards Quality

    The Diplomat's Gemini integration means the cost isn't just about frequency — it's about intent. A thoughtful collaboration proposal (0.3× coefficient) costs less than a generic sales pitch (1× coefficient), which costs less than spam (3× coefficient).

    This is economically aligned incentives for email quality. For the first time, writing a better email literally saves you money.

    Technical Architecture

    ┌─────────────────────────────────────────────────┐
    │  BaseMail Frontend (React + Vite)                │
    │  ├── Compose → Diplomat card (QAF pricing)       │
    │  ├── Send → API call with email content          │
    │  └── Result → Confetti 🎉 if discount            │
    └─────────────┬───────────────────────────────────┘
                  │
    ┌─────────────▼───────────────────────────────────┐
    │  BaseMail Worker (Cloudflare Workers)            │
    │  ├── /api/diplomat/send — Diplomat send          │
    │  ├── /api/send — Standard send (+ Diplomat)      │
    │  ├── arbitrateEmail() → Gemini 2.0 Flash         │
    │  └── stakeAttn() → D1 escrow                     │
    └─────────────┬───────────────────────────────────┘
                  │
    ┌─────────────▼───────────────────────────────────┐
    │  Chainlink CRE Workflow (TypeScript/WASM)        │
    │  ├── HTTPClient → fetch email data               │
    │  ├── Gemini API → classify email                 │
    │  ├── QAF calculation → actual cost               │
    │  └── writeToChain → DiplomatAttestation.sol      │
    └─────────────┬───────────────────────────────────┘
                  │
    ┌─────────────▼───────────────────────────────────┐
    │  Base Sepolia (On-chain)                         │
    │  └── DiplomatAttestation.sol                     │
    │      └── attestations[emailHash] = {             │
    │            category, score, cost,                │
    │            sender, recipient, timestamp          │
    │          }                                       │
    └─────────────────────────────────────────────────┘

    Key Contracts

    Open Source

    The Diplomat integration is open source: github.com/dAAAb/BaseMail-Diplomat

    Includes:

    Demo Video

    Watch the full demo (2 minutes):

    📺 BaseMail — The Diplomat: AI Email Arbitration on Chainlink CRE

    Featuring JC Ko (葛如鈞), Taiwan Legislator and NTU Professor, walking through the complete flow — from composing an email to on-chain attestation.

    The Academic Foundation

    The Diplomat's pricing mechanism is grounded in peer-reviewed research:

    What's Next

    The Diplomat is live on basemail.ai today. Every internal email now goes through LLM arbitration when Gemini is available. We're exploring:

    If you're building AI agents that communicate via email, try BaseMail. Your agent gets a free inbox, $ATTN tokens, and The Diplomat watching the door.

    BaseMail is competing in the Chainlink Convergence Hackathon (deadline: March 8, 2026). Built by JC Ko with Cloud Lobster 🦞